This repository was archived by the owner on Oct 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathConditionBagTest.php
More file actions
42 lines (34 loc) · 1.33 KB
/
ConditionBagTest.php
File metadata and controls
42 lines (34 loc) · 1.33 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
<?php
namespace DZunke\FeatureFlagsBundle\Tests\Toggle;
use DZunke\FeatureFlagsBundle\Toggle\ConditionBag;
use DZunke\FeatureFlagsBundle\Toggle\Conditions\ConditionInterface;
use PHPUnit\Framework\TestCase;
use IteratorAggregate;
use Countable;
use ArrayIterator;
class ConditionBagTest extends TestCase
{
public function testItImplementsClasses(): void
{
$sut = new ConditionBag();
$this->assertInstanceOf(IteratorAggregate::class, $sut);
$this->assertInstanceOf(Countable::class, $sut);
}
public function testConditionBag(): void
{
$conditionMock = $this->createMock(ConditionInterface::class);
$conditionMock->method('__toString')->willReturn('test_condition');
$sut = new ConditionBag();
$sut->add([$conditionMock]);
$this->assertInstanceOf(ArrayIterator::class, $sut->getIterator());
$this->assertCount(1, $sut);
self::assertIsArray($sut->all());
$this->assertNull($sut->get('test'));
$this->assertInstanceOf(ConditionInterface::class, $sut->get('test_condition'));
self::assertIsArray($sut->keys());
$this->assertCount(1, $sut->keys());
$this->assertFalse($sut->has('test'));
$this->assertTrue($sut->has('test_condition'));
$this->assertCount(0, $sut->remove('test_condition'));
}
}