public static create ( |
||
$loadedParameters | ||
$injectedParameters | ||
$fixtures | ||
$objects | ||
Résultat |
public function testRemovesConflictingObjectsByIteratingFixturesIfThereIsLessFixturesThanInjectedObjects() { $set = FixtureSetFactory::create(); $decoratedResolverProphecy = $this->prophesize(FixtureSetResolverInterface::class); $decoratedResolverProphecy->resolve($set)->willReturn($resolvedSet = new ResolvedFixtureSet($parameters = new ParameterBag(['resolved' => true]), $fixtures = (new FixtureBag())->with(new DummyFixture('dummy')), $objects = (new ObjectBag())->with(new SimpleObject('dummy', new \stdClass()))->with(new SimpleObject('another_injected_object', new \stdClass())))); /** @var FixtureSetResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $expected = new ResolvedFixtureSet($parameters, $fixtures, $objects = (new ObjectBag())->with(new SimpleObject('another_injected_object', new \stdClass()))); $resolver = new RemoveConflictingObjectsResolver($decoratedResolver); $actual = $resolver->resolve($set); $this->assertEquals($expected, $actual); }
public function testLoadAFileAndReturnsAnObjectSet() { $data = [new \stdClass()]; $parameters = ['foo' => 'bar']; $objects = ['dummy0' => new \stdClass()]; $fixtureSet = FixtureSetFactory::create(); $objectSet = ObjectSetFactory::create(); $fixtureBuilderProphecy = $this->prophesize(FixtureBuilderInterface::class); $fixtureBuilderProphecy->build($data, $parameters, $objects)->willReturn($fixtureSet); /** @var FixtureBuilderInterface $fixtureBuilder */ $fixtureBuilder = $fixtureBuilderProphecy->reveal(); $generatorProphecy = $this->prophesize(GeneratorInterface::class); $generatorProphecy->generate($fixtureSet)->willReturn($objectSet); /** @var GeneratorInterface $generator */ $generator = $generatorProphecy->reveal(); $loader = new SimpleDataLoader($fixtureBuilder, $generator); $result = $loader->loadData($data, $parameters, $objects); $this->assertSame($objectSet, $result); $fixtureBuilderProphecy->build(Argument::cetera())->shouldHaveBeenCalledTimes(1); $generatorProphecy->generate(Argument::cetera())->shouldHaveBeenCalledTimes(1); }