silverstripe /
silverstripe-cms
| 1 | <?php |
||||||||
| 2 | |||||||||
| 3 | namespace SilverStripe\CMS\Tests\Behaviour; |
||||||||
| 4 | |||||||||
| 5 | use SilverStripe\BehatExtension\Context\FixtureContext as BehatFixtureContext; |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 6 | use SilverStripe\CMS\Model\RedirectorPage; |
||||||||
| 7 | use SilverStripe\CMS\Model\SiteTree; |
||||||||
| 8 | use SilverStripe\Core\ClassInfo; |
||||||||
| 9 | use SilverStripe\Core\Injector\Injector; |
||||||||
| 10 | use SilverStripe\Dev\FixtureBlueprint; |
||||||||
| 11 | use SilverStripe\Versioned\Versioned; |
||||||||
| 12 | |||||||||
| 13 | /** |
||||||||
| 14 | * Context used to create fixtures in the SilverStripe ORM. |
||||||||
| 15 | */ |
||||||||
| 16 | class FixtureContext extends BehatFixtureContext |
||||||||
| 17 | { |
||||||||
| 18 | protected function scaffoldDefaultFixtureFactory() |
||||||||
| 19 | { |
||||||||
| 20 | $factory = parent::scaffoldDefaultFixtureFactory(); |
||||||||
| 21 | |||||||||
| 22 | // Use blueprints which auto-publish all subclasses of SiteTree |
||||||||
| 23 | foreach (ClassInfo::subclassesFor(SiteTree::class) as $class) { |
||||||||
| 24 | $blueprint = Injector::inst()->create(FixtureBlueprint::class, $class); |
||||||||
| 25 | $blueprint->addCallback('afterCreate', function ($obj, $identifier, &$data, &$fixtures) { |
||||||||
|
0 ignored issues
–
show
The parameter
$identifier is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$data is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$fixtures is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 26 | /** @var SiteTree $obj */ |
||||||||
| 27 | $obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||||||||
| 28 | }); |
||||||||
| 29 | $factory->define($class, $blueprint); |
||||||||
| 30 | } |
||||||||
| 31 | |||||||||
| 32 | return $factory; |
||||||||
| 33 | } |
||||||||
| 34 | |||||||||
| 35 | /** |
||||||||
| 36 | * Find or create a redirector page and link to another existing page. |
||||||||
| 37 | * Example: Given a "page" "My Redirect" which redirects to a "page" "Page 1" |
||||||||
| 38 | * |
||||||||
| 39 | * @Given /^(?:(an|a|the) )"(?<type>[^"]+)" "(?<id>[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?<targetType>[^"]+)" "(?<targetId>[^"]+)"$/ |
||||||||
| 40 | * @param string $type |
||||||||
| 41 | * @param string $id |
||||||||
| 42 | * @param string $targetType |
||||||||
| 43 | * @param string $targetId |
||||||||
| 44 | */ |
||||||||
| 45 | public function stepCreateRedirectorPage($type, $id, $targetType, $targetId) |
||||||||
| 46 | { |
||||||||
| 47 | $class = RedirectorPage::class; |
||||||||
| 48 | $targetClass = $this->convertTypeToClass($targetType); |
||||||||
| 49 | |||||||||
| 50 | $targetObj = $this->fixtureFactory->get($targetClass, $targetId); |
||||||||
| 51 | if (!$targetObj) { |
||||||||
| 52 | $targetObj = $this->fixtureFactory->get($targetClass, $targetId); |
||||||||
| 53 | } |
||||||||
| 54 | |||||||||
| 55 | $fields = array('LinkToID' => $targetObj->ID); |
||||||||
| 56 | /** @var RedirectorPage $obj */ |
||||||||
| 57 | $obj = $this->fixtureFactory->get($class, $id); |
||||||||
| 58 | if ($obj) { |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 59 | $obj->update($fields); |
||||||||
| 60 | } else { |
||||||||
| 61 | $obj = $this->fixtureFactory->createObject($class, $id, $fields); |
||||||||
| 62 | } |
||||||||
| 63 | $obj->write(); |
||||||||
| 64 | $obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||||||||
| 65 | } |
||||||||
| 66 | } |
||||||||
| 67 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths