Skip to content

Commit 536a4f9

Browse files
Merge pull request #107 from sebastienheyd/codex/ajouter-test-pour-channel_hash
Add channel hash helper tests
2 parents 1136116 + 64a861b commit 536a4f9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<testsuite name="Datatables">
2525
<directory suffix="Test.php">./tests/Datatables</directory>
2626
</testsuite>
27+
<testsuite name="Helpers">
28+
<directory suffix="Test.php">./tests/Helpers</directory>
29+
</testsuite>
2730
<testsuite name="Menu">
2831
<directory suffix="Test.php">./tests/Menu</directory>
2932
</testsuite>

tests/Helpers/ChannelHashTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Sebastienheyd\Boilerplate\Tests\Helpers;
4+
5+
use Sebastienheyd\Boilerplate\Tests\TestCase;
6+
7+
class ChannelHashTest extends TestCase
8+
{
9+
public function testChannelHashGeneratesSignature()
10+
{
11+
$signature = md5('Notifications|1'.config('app.key').config('app.url'));
12+
$expected = 'Notifications.1.'.$signature;
13+
14+
$this->assertEquals($expected, channel_hash('Notifications', 1));
15+
}
16+
17+
public function testChannelHashEqualsSuccess()
18+
{
19+
$signature = md5('Notifications|1'.config('app.key').config('app.url'));
20+
21+
$this->assertTrue(channel_hash_equals($signature, 'Notifications', 1));
22+
}
23+
24+
public function testChannelHashEqualsFailure()
25+
{
26+
$signature = md5('Notifications|2'.config('app.key').config('app.url'));
27+
28+
$this->assertFalse(channel_hash_equals($signature, 'Notifications', 1));
29+
}
30+
}

0 commit comments

Comments
 (0)