Debian Codegraph @

tests/classes/CommonTest.php

raw symbols SCIP
1 <?php
2
3 namespace Liuch\DmarcSrg;
4
5 class CommonTest extends \PHPUnit\Framework\TestCase
6 {
7 public function testAlignResultArray(): void
8 {
9 $this->assertCount(3, Common::$align_res);
10 $this->assertEquals('fail', Common::$align_res[0]);
11 $this->assertEquals('unknown', Common::$align_res[1]);
12 $this->assertEquals('pass', Common::$align_res[2]);
13 }
14
15 public function testDispositionArray(): void
16 {
17 $this->assertCount(3, Common::$disposition);
18 $this->assertEquals('reject', Common::$disposition[0]);
19 $this->assertEquals('quarantine', Common::$disposition[1]);
20 $this->assertEquals('none', Common::$disposition[2]);
21 }
22
23 public function testCsvConverting(): void
24 {
25 $this->assertEquals(
26 'qwe' . "\n\r" . '' . "\n\r" . '1,qwe,"q w e","""q""w"""' . "\n\r",
27 Common::arrayToCSV([
28 'qwe',
29 '',
30 [ 1, 'qwe', 'q w e', '"q"w"' ],
31 ])
32 );
33 }
34
35 public function testRandomString(): void
36 {
37 $this->assertEquals(10, strlen(Common::randomString(10)));
38 $this->assertNotEquals(Common::randomString(4), Common::randomString(4));
39 $this->assertMatchesRegularExpression('/^[0-9a-zA-Z]+$/', Common::randomString(64));
40 }
41 }