Skip to content

Commit

Permalink
[#123] AddStrategyFactoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
pheaturebot committed Apr 20, 2021
1 parent e3b4854 commit 01e6667
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/AddStrategyFactory.php
Expand Up @@ -15,6 +15,11 @@ public function __invoke(ContainerInterface $container): AddStrategy
/** @var FeatureRepository $featureRepository */
$featureRepository = $container->get(FeatureRepository::class);

return self::create($featureRepository);
}

public static function create(FeatureRepository $featureRepository): AddStrategy
{
return new AddStrategy($featureRepository);
}
}
37 changes: 37 additions & 0 deletions test/AddStrategyFactoryTest.php
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Pheature\Test\Crud\Psr11\Toggle;

use Pheature\Core\Toggle\Write\FeatureRepository;
use Pheature\Crud\Psr11\Toggle\AddStrategyFactory;
use Pheature\Crud\Toggle\Handler\AddStrategy;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;

final class AddStrategyFactoryTest extends TestCase
{
public function testItShouldCreateInstanceOfAddStrategy(): void
{
$featureRepository = $this->createMock(FeatureRepository::class);
$container = $this->createMock(ContainerInterface::class);
$container->expects(static::once())
->method('get')
->with(FeatureRepository::class)
->willReturn($featureRepository);

$addStrategyFactory = new AddStrategyFactory();

$addStrategyFactory->__invoke($container);
}

public function testItShouldCreateInstanceOfAddStrategyStatically(): void
{
$featureRepository = $this->createMock(FeatureRepository::class);

$addStrategy = AddStrategyFactory::create($featureRepository);

$this->assertInstanceOf(AddStrategy::class, $addStrategy);
}
}

0 comments on commit 01e6667

Please sign in to comment.