forked from php-gettext/Gettext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlagsTest.php
More file actions
72 lines (52 loc) · 1.74 KB
/
FlagsTest.php
File metadata and controls
72 lines (52 loc) · 1.74 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
65
66
67
68
69
70
71
72
<?php
declare(strict_types = 1);
namespace Gettext\Tests;
use Gettext\Flags;
use PHPUnit\Framework\TestCase;
class FlagsTest extends TestCase
{
public function testFlags(): void
{
$flags = new Flags();
$this->assertSame([], $flags->toArray());
$this->assertCount(0, $flags);
$flags->add('foo');
$this->assertSame(['foo'], $flags->toArray());
$this->assertCount(1, $flags);
$flags->add('foo');
$this->assertSame(['foo'], $flags->toArray());
$this->assertCount(1, $flags);
$flags->add('bar');
$this->assertSame(['bar', 'foo'], $flags->toArray());
$this->assertCount(2, $flags);
$flags->add('one', 'two', 'three');
$this->assertSame(['bar', 'foo', 'one', 'three', 'two'], $flags->toArray());
$this->assertCount(5, $flags);
$flags->delete('bar', 'one', 'two');
$this->assertSame(['foo', 'three'], $flags->toArray());
$this->assertCount(2, $flags);
}
public function testMergeFlags(): void
{
$flags1 = new Flags('one', 'two', 'three');
$flags2 = new Flags('three', 'four', 'five');
$merged = $flags1->mergeWith($flags2);
$this->assertCount(5, $merged);
$this->assertSame([
'five',
'four',
'one',
'three',
'two',
], $merged->toArray());
$this->assertNotSame($merged, $flags1);
$this->assertNotSame($merged, $flags2);
}
public function testCreateFromState(): void
{
$state = ['flags' => ['one', 'two']];
$flags = Flags::__set_state($state);
$this->assertCount(2, $flags);
$this->assertSame($state['flags'], $flags->toArray());
}
}