|
8 | 8 | use Magento\Framework\Filesystem\Driver\File;
|
9 | 9 | use org\bovigo\vfs\vfsStream;
|
10 | 10 | use org\bovigo\vfs\vfsStreamDirectory;
|
| 11 | +use PhpSpec\Loader\Transformer\TypeHintIndex; |
11 | 12 | use spec\EcomDev\PHPSpec\MagentoDiAdapter\Fixture\Catcher;
|
12 | 13 | use spec\EcomDev\PHPSpec\MagentoDiAdapter\Fixture\SignatureClass;
|
13 | 14 | use PhpSpec\ObjectBehavior;
|
14 | 15 | use Prophecy\Argument;
|
| 16 | +use spec\EcomDev\PHPSpec\MagentoDiAdapter\Fixture\TypeHintClass; |
| 17 | +use spec\EcomDev\PHPSpec\MagentoDiAdapter\Fixture\ValidClass; |
15 | 18 |
|
16 | 19 | class ParameterValidatorSpec extends ObjectBehavior
|
17 | 20 | {
|
@@ -43,14 +46,20 @@ class ParameterValidatorSpec extends ObjectBehavior
|
43 | 46 | */
|
44 | 47 | private $classReflection;
|
45 | 48 |
|
46 |
| - function let() |
| 49 | + /** |
| 50 | + * @var TypeHintIndex |
| 51 | + */ |
| 52 | + private $typeHintIndex; |
| 53 | + |
| 54 | + function let(TypeHintIndex $typeHintIndex) |
47 | 55 | {
|
48 | 56 | $this->vfs = vfsStream::setup('testcase');
|
49 | 57 | $this->io = new Io(new File(), $this->vfs->url());
|
50 | 58 | $this->definedClasses = new SimplifiedDefinedClasses();
|
51 | 59 | $this->classReflection = new \ReflectionClass(SignatureClass::class);
|
| 60 | + $this->typeHintIndex = $typeHintIndex; |
52 | 61 |
|
53 |
| - $this->beConstructedWith($this->io, $this->definedClasses); |
| 62 | + $this->beConstructedWith($this->io, $this->definedClasses, $this->typeHintIndex); |
54 | 63 | }
|
55 | 64 |
|
56 | 65 | function it_is_possible_to_add_multiple_entity_generators()
|
@@ -97,6 +106,21 @@ function it_generates_a_class_via_generator_for_parameter_that_does_not_exits()
|
97 | 106 | $this->shouldCreateFile($this->vfs->url() . '/spec/EcomDev/PHPSpec/MagentoDiAdapter/Fixture/ValidClassFactory.php');
|
98 | 107 | }
|
99 | 108 |
|
| 109 | + function it_supports_type_hint_index_method_data_retrieval() |
| 110 | + { |
| 111 | + $this->typeHintIndex->lookup(SignatureClass::class, 'type_hint_index_resolved_class', '$parameter') |
| 112 | + ->willReturn(TypeHintClass::class . 'Factory') |
| 113 | + ->shouldBeCalled(); |
| 114 | + |
| 115 | + $this->addGenerator(Generator\Factory::class, Generator\Factory::ENTITY_TYPE)->shouldReturn($this); |
| 116 | + |
| 117 | + $functionReflection = $this->classReflection->getMethod('type_hint_index_resolved_class'); |
| 118 | + |
| 119 | + $this->validate($functionReflection)->shouldReturn($this); |
| 120 | + |
| 121 | + $this->shouldCreateFile($this->vfs->url() . '/spec/EcomDev/PHPSpec/MagentoDiAdapter/Fixture/TypeHintClassFactory.php'); |
| 122 | + } |
| 123 | + |
100 | 124 | function it_does_not_generate_a_class_for_which_we_do_not_have_a_rule()
|
101 | 125 | {
|
102 | 126 | $functionReflection = $this->classReflection->getMethod('non_existent_class_param');
|
|
0 commit comments