/** * Navigates to a record based on its identifier set during fixture creation, * using its RelativeLink() method to map the record to a URL. * Example: Given I go to the "page" "My Page" * * @Given /^I go to (?:(an|a|the) )"(?<type>[^"]+)" "(?<id>[^"]+)"/ */ public function stepGoToNamedRecord($type, $id) { $class = $this->convertTypeToClass($type); $record = $this->fixtureFactory->get($class, $id); if (!$record) { throw new \InvalidArgumentException(sprintf('Cannot resolve reference "%s", no matching fixture found', $id)); } if (!$record->hasMethod('RelativeLink')) { throw new \InvalidArgumentException('URL for record cannot be determined, missing RelativeLink() method'); } $this->getSession()->visit($this->getMainContext()->locatePath($record->RelativeLink())); }
/** * Get an object from the fixture. * * @deprecated 4.0 Use writeInto() and FixtureFactory accessors instead * * @param $className The data class, as specified in your fixture file. Parent classes won't work * @param $identifier The identifier string, as provided in your fixture file */ public function objFromFixture($className, $identifier) { Deprecation::notice('4.0', 'Use writeInto() and FixtureFactory accessors instead'); if (!$this->factory) { $this->factory = Injector::inst()->create('FixtureFactory'); } return $this->factory->get($className, $identifier); }
/** * @Given /^there should be an abuse report for "([^"]*)" with reason "([^"]*)"$/ */ public function thereShouldBeAnAbuseReportForWithReason($id, $reason) { $page = $this->fixtureFactory->get('Page', $id); assertEquals(1, $page->PageAbuseReports()->filter('Reason', $reason)->Count()); }