-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathHashCalculationTest.php
75 lines (62 loc) · 2.03 KB
/
HashCalculationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @author Aaron Francis <[email protected]>
*/
namespace AaronFrancis\Airdrop\Tests;
use AaronFrancis\Airdrop\HashGenerator;
use AaronFrancis\Airdrop\Triggers\ConfigTrigger;
use AaronFrancis\Airdrop\Triggers\FileTrigger;
use PHPUnit\Framework\Attributes\Test;
class HashCalculationTest extends BaseTest
{
#[Test]
public function it_tests_basic_file_hash()
{
config()->set('airdrop.triggers', [
FileTrigger::class => [
'include' => [
base_path('tests/Support/primary-webpack.mix.example'),
]
]
]);
$array = (new HashGenerator)->asArray();
$this->assertEquals([
FileTrigger::class => [
'/tests/Support/primary-webpack.mix.example' => '62f6d1bfc836a1536c4869fe8f78249b'
]
], $array);
$hash = (new HashGenerator)->generate();
$this->assertEquals('0cf3788c521e4652ad2ad39ffd7974ec', $hash);
}
#[Test]
public function it_gets_sorted()
{
config()->set('airdrop.triggers', [
ConfigTrigger::class => [
'a_key' => 'test',
'b_key' => 'test'
],
FileTrigger::class => [
'include' => [
base_path('tests/Support/primary-webpack.mix.example'),
base_path('tests/Support/secondary-webpack.mix.example'),
]
]
]);
$hash1 = (new HashGenerator)->generate();
config()->set('airdrop.triggers', [
FileTrigger::class => [
'include' => [
base_path('tests/Support/secondary-webpack.mix.example'),
base_path('tests/Support/primary-webpack.mix.example'),
]
],
ConfigTrigger::class => [
'b_key' => 'test',
'a_key' => 'test',
],
]);
$hash2 = (new HashGenerator)->generate();
$this->assertEquals($hash1, $hash2);
}
}