/** * @expectedException \Hautelook\AliceBundle\Alice\DataFixtures\LoadingLimitException */ public function testLoaderWithCustomLimit() { $persisterProphecy = $this->prophesize('Nelmio\\Alice\\PersisterInterface'); $persisterProphecy->persist()->shouldNotBeCalled(); $fixturesLoaderProphecy = $this->prophesize('Hautelook\\AliceBundle\\Alice\\DataFixtures\\Fixtures\\LoaderInterface'); $fixturesLoaderProphecy->load('random/file', [])->willThrow(new \UnexpectedValueException()); $fixturesLoaderProphecy->load('random/file', [])->shouldBeCalledTimes(11); $loader = new Loader($fixturesLoaderProphecy->reveal(), [], false); $loader->setLoadingLimit(10); $loader->load($persisterProphecy->reveal(), ['random/file']); }
/** * @covers ::load() * @covers ::registerErrorMessage() */ public function testLoaderLimitWithMessages() { $this->setExpectedException('\\Hautelook\\AliceBundle\\Alice\\DataFixtures\\LoadingLimitException', 'Loading files limit of 3 reached. Could not load the following files:' . PHP_EOL . 'another/file:' . PHP_EOL . ' - That is a failed' . PHP_EOL . 'empty/message' . PHP_EOL . 'random/file:' . PHP_EOL . ' - Some dummy message'); $persisterProphecy = $this->prophesize('Nelmio\\Alice\\PersisterInterface'); $persisterProphecy->persist()->shouldNotBeCalled(); $fixturesLoaderProphecy = $this->prophesize('Hautelook\\AliceBundle\\Alice\\DataFixtures\\Fixtures\\LoaderInterface'); $fixturesLoaderProphecy->load('random/file', [])->willThrow(new \UnexpectedValueException('Some dummy message')); $fixturesLoaderProphecy->load('another/file', [])->willThrow(new \UnexpectedValueException('That is a failed')); $fixturesLoaderProphecy->load('empty/message', [])->willThrow(new \UnexpectedValueException()); $loader = new Loader($fixturesLoaderProphecy->reveal(), new ProcessorChain([]), false, 3); $loader->load($persisterProphecy->reveal(), ['random/file', 'another/file', 'empty/message']); }
public function testLoaderInterface() { $object = new \stdClass(); $persisterProphecy = $this->prophesize('Nelmio\\Alice\\PersisterInterface'); $persisterProphecy->persist([$object])->shouldBeCalled(); $fixturesLoaderProphecy = $this->prophesize('Hautelook\\AliceBundle\\Alice\\DataFixtures\\Fixtures\\LoaderInterface'); $fixturesLoaderProphecy->load('random/file')->willReturn([$object]); $loader = new Loader($fixturesLoaderProphecy->reveal(), [], false); $objects = $loader->load($persisterProphecy->reveal(), ['random/file']); $this->assertEquals([$object], $objects); }