mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
BUG Avoid trying to get singletons fon non-existan classes (#192)
BUG Avoid trying to get singletons for non-existant classes
This commit is contained in:
parent
a1d77988ce
commit
6df2a983e3
19
.travis.yml
19
.travis.yml
@ -7,23 +7,16 @@ sudo: false
|
|||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.composer/cache/files
|
- $HOME/.composer/cache/files
|
||||||
|
|
||||||
php:
|
|
||||||
- 5.6
|
|
||||||
|
|
||||||
env:
|
|
||||||
matrix:
|
|
||||||
- PHPUNIT_TEST=1
|
|
||||||
- PHPCS_TEST=1
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 7.1
|
||||||
env: PHPUNIT_TEST=1
|
env: PHPUNIT_TEST=1
|
||||||
- php: 7.0
|
- php: 7.2
|
||||||
env: PHPUNIT_TEST=1
|
|
||||||
- php: 7.1.2
|
|
||||||
env: PHPUNIT_TEST=1
|
env: PHPUNIT_TEST=1
|
||||||
|
- php: 7.3
|
||||||
|
env: PHPUNIT_TEST=1 PHPCS_TEST=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export PATH=~/.composer/vendor/bin:$PATH
|
- export PATH=~/.composer/vendor/bin:$PATH
|
||||||
|
@ -897,13 +897,13 @@ YAML;
|
|||||||
|
|
||||||
// Try direct mapping
|
// Try direct mapping
|
||||||
$class = str_replace(' ', '', ucwords($type));
|
$class = str_replace(' ', '', ucwords($type));
|
||||||
if (class_exists($class) && is_subclass_of($class, 'SilverStripe\\ORM\\DataObject')) {
|
if (class_exists($class) && is_subclass_of($class, DataObject::class)) {
|
||||||
return ClassInfo::class_name($class);
|
return ClassInfo::class_name($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to singular names
|
// Fall back to singular names
|
||||||
foreach (array_values(ClassInfo::subclassesFor('SilverStripe\\ORM\\DataObject')) as $candidate) {
|
foreach (array_values(ClassInfo::subclassesFor(DataObject::class)) as $candidate) {
|
||||||
if (strcasecmp(singleton($candidate)->singular_name(), $type) === 0) {
|
if (class_exists($candidate) && strcasecmp(singleton($candidate)->singular_name(), $type) === 0) {
|
||||||
return $candidate;
|
return $candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user