-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#225] Replace driver string values to constants
- Loading branch information
Showing
12 changed files
with
458 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,12 @@ | |
"authors": [ | ||
{ | ||
"name": "kpicaza" | ||
}, | ||
{ | ||
"name": "pcs289" | ||
}, | ||
{ | ||
"name": "xserrat" | ||
} | ||
], | ||
"require": { | ||
|
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
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
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pheature\Test\Community\Mezzio; | ||
|
||
use Pheature\Community\Mezzio\CommandRunnerFactory; | ||
use Pheature\Core\Toggle\Read\FeatureFinder; | ||
use Pheature\Sdk\CommandRunner; | ||
use Pheature\Test\Community\Mezzio\Fixtures\TestContainerFactory; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
|
||
final class CommandRunnerFactoryTest extends TestCase | ||
{ | ||
public function testItShouldThrowAnExceptionWhenFeatureFinderNotFoundInContainer(): void | ||
{ | ||
$this->expectException(NotFoundExceptionInterface::class); | ||
|
||
$emptyContainer = TestContainerFactory::create(); | ||
|
||
$commandRunnerFactory = new CommandRunnerFactory(); | ||
$commandRunnerFactory->__invoke($emptyContainer); | ||
} | ||
|
||
public function testItShouldCreateACommandRunner(): void | ||
{ | ||
/** @var FeatureFinder|MockObject $featureFinder */ | ||
$featureFinder = $this->createMock(FeatureFinder::class); | ||
$container = TestContainerFactory::create([FeatureFinder::class => $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pheature\Test\Community\Mezzio\Fixtures; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
use RuntimeException; | ||
|
||
final class TestContainerFactory | ||
{ | ||
public static function createWithEmptyConfiguration(): ContainerInterface | ||
{ | ||
return self::create(['config' => []]); | ||
} | ||
|
||
public static function createWithPheatureFlagsConfiguration(): ContainerInterface | ||
{ | ||
$pheatureFlagsConfig = ToggleConfiguration::create()['pheature_flags']; | ||
|
||
return self::create(['config' => ['pheature_flags' => $pheatureFlagsConfig]]); | ||
} | ||
|
||
public static function create(array $content = []): ContainerInterface | ||
{ | ||
return new class ($content) implements ContainerInterface { | ||
private array $content; | ||
|
||
public function __construct(array $content = []) | ||
{ | ||
$this->content = $content; | ||
} | ||
|
||
public function get(string $id) | ||
{ | ||
if ($this->has($id)) { | ||
return $this->content[$id]; | ||
} | ||
|
||
$errorMessage = sprintf('Service "%s" not found in test container', $id); | ||
throw new class ($errorMessage) extends RuntimeException implements NotFoundExceptionInterface { | ||
}; | ||
} | ||
|
||
public function has(string $id) | ||
{ | ||
return array_key_exists($id, $this->content); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.