/
ChainToggleStrategyFactoryFactoryTest.php
51 lines (44 loc) · 1.95 KB
/
ChainToggleStrategyFactoryFactoryTest.php
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
<?php
declare(strict_types=1);
namespace Pheature\Test\Crud\Psr11\Toggle;
use Pheature\Core\Toggle\Read\ChainToggleStrategyFactory;
use Pheature\Model\Toggle\SegmentFactory;
use Pheature\Crud\Psr11\Toggle\ChainToggleStrategyFactoryFactory;
use Pheature\Crud\Psr11\Toggle\ToggleConfig;
use Pheature\Model\Toggle\StrategyFactory;
use Pheature\Test\Crud\Psr11\Toggle\Fixtures\PheatureFlagsConfig;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
class ChainToggleStrategyFactoryFactoryTest extends TestCase
{
public function testItShouldCreateInstancesOfChainToggleStrategyFactory(): void
{
$segmentFactory = new SegmentFactory();
$strategyFactory = new StrategyFactory();
$container = $this->createMock(ContainerInterface::class);
$container->expects(self::exactly(4))
->method('get')
->withConsecutive(
[SegmentFactory::class],
[ToggleConfig::class],
['enable_by_matching_segment'],
['enable_by_matching_identity_id']
)
->willReturnOnConsecutiveCalls(
$segmentFactory,
new ToggleConfig(PheatureFlagsConfig::createDefault()->build()),
$strategyFactory,
$strategyFactory,
);
$factory = new ChainToggleStrategyFactoryFactory();
$chainToggleStrategyFactory = $factory->__invoke($container);
self::assertInstanceOf(ChainToggleStrategyFactory::class, $chainToggleStrategyFactory);
}
public function testItShouldCreateInstancesOfChainToggleStrategyFactoryStatically(): void
{
$segmentFactory = new SegmentFactory();
$strategyFactory = new StrategyFactory();
$chainToggleStrategyFactory = ChainToggleStrategyFactoryFactory::create($segmentFactory, $strategyFactory, $strategyFactory);
self::assertInstanceOf(ChainToggleStrategyFactory::class, $chainToggleStrategyFactory);
}
}