-
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.
- support PHP attributes as metadata source
- changes for PSR-11 container integration to simplify metadata provider switch
- Loading branch information
Arthur Mogliev
committed
Apr 4, 2021
1 parent
1fa3b07
commit 467ec6d
Showing
56 changed files
with
3,302 additions
and
870 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
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,16 @@ | ||
bootstrap: spec/bootstrap.php | ||
formatter.name: pretty | ||
matchers: | ||
- spec\Matcher\PropertyValue | ||
- spec\Matcher\PropertyValueType | ||
extensions: | ||
FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension: | ||
format: | ||
#- html | ||
- text | ||
- clover | ||
output: | ||
#html: spec_output/phpspec.coverage | ||
clover: spec_output/phpspec.coverage.xml | ||
whitelist: | ||
- src |
61 changes: 61 additions & 0 deletions
61
spec/Articus/PathHandler/Attribute/Factory/PluginManagerSpec.php
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,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace spec\Articus\PathHandler\Attribute\Factory; | ||
|
||
use Articus\PathHandler as PH; | ||
use Interop\Container\ContainerInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
/** | ||
* TODO add expected text for LogicExceptions | ||
*/ | ||
class PluginManagerSpec extends ObjectBehavior | ||
{ | ||
public function it_gets_configuration_from_default_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = PH\Attribute\PluginManager::class; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$service = $this->__invoke($container, ''); | ||
$service->shouldBeAnInstanceOf(PH\Attribute\PluginManager::class); | ||
} | ||
|
||
public function it_gets_configuration_from_custom_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$this->beConstructedWith($configKey); | ||
$service = $this->__invoke($container, ''); | ||
$service->shouldBeAnInstanceOf(PH\Attribute\PluginManager::class); | ||
} | ||
|
||
public function it_constructs_itself_and_gets_configuration_from_custom_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$service = $this::__callStatic($configKey, [$container, '', null]); | ||
$service->shouldBeAnInstanceOf(PH\Attribute\PluginManager::class); | ||
} | ||
|
||
public function it_throws_on_too_few_arguments_during_self_construct(ContainerInterface $container) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$error = new \InvalidArgumentException(\sprintf( | ||
'To invoke %s with custom configuration key statically 3 arguments are required: container, service name and options.', | ||
PH\Attribute\Factory\PluginManager::class | ||
)); | ||
|
||
$this::shouldThrow($error)->during('__callStatic', [$configKey, []]); | ||
$this::shouldThrow($error)->during('__callStatic', [$configKey, [$container]]); | ||
$this::shouldThrow($error)->during('__callStatic', [$configKey, [$container, '']]); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace spec\Articus\PathHandler\Consumer\Factory; | ||
|
||
use Articus\PathHandler as PH; | ||
use Interop\Container\ContainerInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class JsonSpec extends ObjectBehavior | ||
{ | ||
public function it_builds_json_consumer_with_default_options(ContainerInterface $container) | ||
{ | ||
$service = $this->__invoke($container, 'test'); | ||
$service->shouldBeAnInstanceOf(PH\Consumer\Json::class); | ||
$service->shouldHaveProperty('parseAsStdClass', false); | ||
} | ||
|
||
public function it_builds_json_consumer_with_specified_options(ContainerInterface $container) | ||
{ | ||
$service = $this->__invoke($container, 'test', ['parse_as_std_class' => true]); | ||
$service->shouldBeAnInstanceOf(PH\Consumer\Json::class); | ||
$service->shouldHaveProperty('parseAsStdClass', true); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
spec/Articus/PathHandler/Consumer/Factory/PluginManagerSpec.php
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,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace spec\Articus\PathHandler\Consumer\Factory; | ||
|
||
use Articus\PathHandler as PH; | ||
use Interop\Container\ContainerInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
/** | ||
* TODO add expected text for LogicExceptions | ||
*/ | ||
class PluginManagerSpec extends ObjectBehavior | ||
{ | ||
public function it_gets_configuration_from_default_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = PH\Consumer\PluginManager::class; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$service = $this->__invoke($container, ''); | ||
$service->shouldBeAnInstanceOf(PH\Consumer\PluginManager::class); | ||
} | ||
|
||
public function it_gets_configuration_from_custom_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$this->beConstructedWith($configKey); | ||
$service = $this->__invoke($container, ''); | ||
$service->shouldBeAnInstanceOf(PH\Consumer\PluginManager::class); | ||
} | ||
|
||
public function it_constructs_itself_and_gets_configuration_from_custom_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$service = $this::__callStatic($configKey, [$container, '', null]); | ||
$service->shouldBeAnInstanceOf(PH\Consumer\PluginManager::class); | ||
} | ||
|
||
public function it_throws_on_too_few_arguments_during_self_construct(ContainerInterface $container) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$error = new \InvalidArgumentException(\sprintf( | ||
'To invoke %s with custom configuration key statically 3 arguments are required: container, service name and options.', | ||
PH\Consumer\Factory\PluginManager::class | ||
)); | ||
|
||
$this::shouldThrow($error)->during('__callStatic', [$configKey, []]); | ||
$this::shouldThrow($error)->during('__callStatic', [$configKey, [$container]]); | ||
$this::shouldThrow($error)->during('__callStatic', [$configKey, [$container, '']]); | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
spec/Articus/PathHandler/Handler/Factory/PluginManagerSpec.php
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,61 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace spec\Articus\PathHandler\Handler\Factory; | ||
|
||
use Articus\PathHandler as PH; | ||
use Interop\Container\ContainerInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
/** | ||
* TODO add expected text for LogicExceptions | ||
*/ | ||
class PluginManagerSpec extends ObjectBehavior | ||
{ | ||
public function it_gets_configuration_from_default_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = PH\Handler\PluginManager::class; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$service = $this->__invoke($container, ''); | ||
$service->shouldBeAnInstanceOf(PH\Handler\PluginManager::class); | ||
} | ||
|
||
public function it_gets_configuration_from_custom_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$this->beConstructedWith($configKey); | ||
$service = $this->__invoke($container, ''); | ||
$service->shouldBeAnInstanceOf(PH\Handler\PluginManager::class); | ||
} | ||
|
||
public function it_constructs_itself_and_gets_configuration_from_custom_config_key(ContainerInterface $container, \ArrayAccess $config) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$container->get('config')->shouldBeCalledOnce()->willReturn($config); | ||
$config->offsetExists($configKey)->shouldBeCalledOnce()->willReturn(true); | ||
$config->offsetGet($configKey)->shouldBeCalledOnce(); | ||
|
||
$service = $this::__callStatic($configKey, [$container, '', null]); | ||
$service->shouldBeAnInstanceOf(PH\Handler\PluginManager::class); | ||
} | ||
|
||
public function it_throws_on_too_few_arguments_during_self_construct(ContainerInterface $container) | ||
{ | ||
$configKey = 'test_config_key'; | ||
$error = new \InvalidArgumentException(\sprintf( | ||
'To invoke %s with custom configuration key statically 3 arguments are required: container, service name and options.', | ||
PH\Handler\Factory\PluginManager::class | ||
)); | ||
|
||
$this::shouldThrow($error)->during('__callStatic', [$configKey, []]); | ||
$this::shouldThrow($error)->during('__callStatic', [$configKey, [$container]]); | ||
$this::shouldThrow($error)->during('__callStatic', [$configKey, [$container, '']]); | ||
} | ||
} |
Oops, something went wrong.