function it_logs_fixture_name_on_before_fixture_event(LoggerInterface $logger, SuiteInterface $suite, FixtureInterface $fixture) { $fixture->getName()->willReturn('uber_fixture'); $logger->notice(Argument::that(function ($argument) use($fixture) { return false !== strpos($argument, $fixture->getWrappedObject()->getName()); }))->shouldBeCalled(); $this->beforeFixture(new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), []), []); }
function it_throws_an_exception_if_trying_to_another_fixture_with_the_same_name(FixtureInterface $fixture, FixtureInterface $anotherFixture) { $fixture->getName()->willReturn('fixture'); $anotherFixture->getName()->willReturn('fixture'); $this->addFixture($fixture); $this->shouldThrow(\InvalidArgumentException::class)->during('addFixture', [$fixture]); $this->shouldThrow(\InvalidArgumentException::class)->during('addFixture', [$anotherFixture]); }
function it_loads_suite_fixtures(FixtureLoaderInterface $fixtureLoader, SuiteInterface $suite, FixtureInterface $firstFixture, FixtureInterface $secondFixture) { $suite->getFixtures()->will(function () use($firstFixture, $secondFixture) { (yield $firstFixture->getWrappedObject() => ['options 1']); (yield $secondFixture->getWrappedObject() => ['options 2']); }); $fixtureLoader->load($suite, $firstFixture, ['options 1'])->shouldBeCalled(); $fixtureLoader->load($suite, $secondFixture, ['options 2'])->shouldBeCalled(); $this->load($suite); }
function it_executes_customized_fixture_listeners(FixtureLoaderInterface $decoratedFixtureLoader, SuiteInterface $suite, FixtureInterface $fixture, BeforeFixtureListenerInterface $beforeFixtureListener, AfterFixtureListenerInterface $afterFixtureListener) { $suite->getListeners()->will(function () use($beforeFixtureListener, $afterFixtureListener) { (yield $beforeFixtureListener->getWrappedObject() => ['listener_option1' => 'listener_value1']); (yield $afterFixtureListener->getWrappedObject() => ['listener_option2' => 'listener_value2']); }); $fixtureEvent = new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), ['fixture_option' => 'fixture_value']); $beforeFixtureListener->beforeFixture($fixtureEvent, ['listener_option1' => 'listener_value1'])->shouldBeCalledTimes(1); $decoratedFixtureLoader->load($suite, $fixture, ['fixture_option' => 'fixture_value'])->shouldBeCalled(); $afterFixtureListener->afterFixture($fixtureEvent, ['listener_option2' => 'listener_value2'])->shouldBeCalledTimes(1); $this->load($suite, $fixture, ['fixture_option' => 'fixture_value']); }
/** * {@inheritdoc} */ public function load(SuiteInterface $suite, FixtureInterface $fixture, array $options) { $fixture->load($options); }
/** * @param FixtureInterface $fixture */ public function addFixture(FixtureInterface $fixture) { Assert::keyNotExists($this->fixtures, $fixture->getName(), 'Fixture with name "%s" is already registered.'); $this->fixtures[$fixture->getName()] = $fixture; }
function it_loads_a_fixture(SuiteInterface $suite, FixtureInterface $fixture) { $fixture->load(['options'])->shouldBeCalled(); $this->load($suite, $fixture, ['options']); }