-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWireHelperTest.php
More file actions
64 lines (54 loc) · 1.91 KB
/
Copy pathWireHelperTest.php
File metadata and controls
64 lines (54 loc) · 1.91 KB
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
<?php
namespace SoureCode\Wire\Tests;
use PHPUnit\Framework\TestCase;
use SoureCode\Wire\WireHelper;
class WireHelperTest extends TestCase
{
public function testScopeIdDebugReturnsTemplateName(): void
{
$this->assertSame(
'wire_test/user.html.twig',
WireHelper::scopeId('wire_test/user.html.twig', true)
);
}
public function testScopeIdProdReturnsSha256Prefix(): void
{
$name = 'wire_test/user.html.twig';
$expected = substr(hash('sha256', $name), 0, 8);
$this->assertSame($expected, WireHelper::scopeId($name, false));
}
public function testScopeIdProdIsEightCharacters(): void
{
$this->assertSame(8, strlen(WireHelper::scopeId('any/template.html.twig', false)));
}
public function testScopeIdProdIsLowercaseHexadecimal(): void
{
$id = WireHelper::scopeId('any/template.html.twig', false);
$this->assertMatchesRegularExpression('/^[0-9a-f]{8}$/', $id);
}
public function testScopeIdProdIsDeterministic(): void
{
$id1 = WireHelper::scopeId('template.html.twig', false);
$id2 = WireHelper::scopeId('template.html.twig', false);
$this->assertSame($id1, $id2);
}
public function testScopeIdDifferentTemplatesHaveDifferentIds(): void
{
$id1 = WireHelper::scopeId('template_a.html.twig', false);
$id2 = WireHelper::scopeId('template_b.html.twig', false);
$this->assertNotSame($id1, $id2);
}
public function testScopeIdProdContainsNoSlashes(): void
{
$id = WireHelper::scopeId('wire_test/user.html.twig', false);
$this->assertStringNotContainsString('/', $id);
}
public function testScopeIdDebugAndProdAreDifferent(): void
{
$name = 'wire_test/user.html.twig';
$this->assertNotSame(
WireHelper::scopeId($name, true),
WireHelper::scopeId($name, false)
);
}
}