Example #1
0
 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);
 }
Example #2
0
 public function testLoadAFileAndReturnsAnObjectSet()
 {
     $file = 'dummy.yml';
     $data = ['Nelmio\\Alice\\Entity\\Dummy' => ['dummy0' => []]];
     $parameters = ['foo' => 'bar'];
     $objects = ['dummy0' => new \stdClass()];
     $objectSet = ObjectSetFactory::create();
     $parserProphecy = $this->prophesize(ParserInterface::class);
     $parserProphecy->parse($file)->willReturn($data);
     /** @var ParserInterface $parser */
     $parser = $parserProphecy->reveal();
     $dataLoaderProphecy = $this->prophesize(DataLoaderInterface::class);
     $dataLoaderProphecy->loadData($data, $parameters, $objects)->willReturn($objectSet);
     /** @var DataLoaderInterface $dataLoader */
     $dataLoader = $dataLoaderProphecy->reveal();
     $loader = new SimpleFileLoader($parser, $dataLoader);
     $result = $loader->loadFile($file, $parameters, $objects);
     $this->assertSame($objectSet, $result);
     $parserProphecy->parse(Argument::cetera())->shouldHaveBeenCalledTimes(1);
     $dataLoaderProphecy->loadData(Argument::cetera())->shouldHaveBeenCalledTimes(1);
 }