Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#261] install composer unused in toggle-model package
- Loading branch information
Showing
5 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pheature\Sdk; | ||
|
||
use Pheature\Core\Toggle\Read\FeatureFinder; | ||
use Pheature\Core\Toggle\Read\Toggle; | ||
use Pheature\Sdk\CommandRunner; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class CommandRunnerFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): CommandRunner | ||
{ | ||
/** @var FeatureFinder $featureFinder */ | ||
$featureFinder = $container->get(FeatureFinder::class); | ||
|
||
return new CommandRunner( | ||
new Toggle($featureFinder) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pheature\Test\Sdk; | ||
|
||
use Exception; | ||
use Pheature\Core\Toggle\Read\FeatureFinder; | ||
use Pheature\Sdk\CommandRunner; | ||
use Pheature\Sdk\CommandRunnerFactory; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Container\ContainerInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
|
||
final class CommandRunnerFactoryTest extends TestCase | ||
{ | ||
public function testItShouldThrowAnExceptionWhenFeatureFinderNotFoundInContainer(): void | ||
{ | ||
$this->expectException(NotFoundExceptionInterface::class); | ||
|
||
$notFoundException = new class() extends Exception implements NotFoundExceptionInterface { | ||
}; | ||
|
||
/** @var ContainerInterface|MockObject $emptyContainer */ | ||
$emptyContainer = $this->createMock(ContainerInterface::class); | ||
$emptyContainer | ||
->expects($this->once()) | ||
->method('get') | ||
->with(FeatureFinder::class) | ||
->willThrowException($notFoundException); | ||
|
||
$commandRunnerFactory = new CommandRunnerFactory(); | ||
$commandRunnerFactory->__invoke($emptyContainer); | ||
} | ||
|
||
public function testItShouldCreateACommandRunner(): void | ||
{ | ||
/** @var FeatureFinder|MockObject $featureFinder */ | ||
$featureFinder = $this->createMock(FeatureFinder::class); | ||
|
||
/** @var ContainerInterface|MockObject $container */ | ||
$container = $this->createMock(ContainerInterface::class); | ||
$container | ||
->expects($this->once()) | ||
->method('get') | ||
->with(FeatureFinder::class) | ||
->willReturn($featureFinder); | ||
|
||
$commandRunnerFactory = new CommandRunnerFactory(); | ||
$actual = $commandRunnerFactory->__invoke($container); | ||
|
||
self::assertInstanceOf(CommandRunner::class, $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters