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:
|
||||
directories:
|
||||
- $HOME/.composer/cache/files
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- PHPUNIT_TEST=1
|
||||
- PHPCS_TEST=1
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
- php: 7.1
|
||||
env: PHPUNIT_TEST=1
|
||||
- php: 7.0
|
||||
env: PHPUNIT_TEST=1
|
||||
- php: 7.1.2
|
||||
- php: 7.2
|
||||
env: PHPUNIT_TEST=1
|
||||
- php: 7.3
|
||||
env: PHPUNIT_TEST=1 PHPCS_TEST=1
|
||||
|
||||
|
||||
|
||||
before_script:
|
||||
- export PATH=~/.composer/vendor/bin:$PATH
|
||||
|
@ -897,13 +897,13 @@ YAML;
|
||||
|
||||
// Try direct mapping
|
||||
$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);
|
||||
}
|
||||
|
||||
// Fall back to singular names
|
||||
foreach (array_values(ClassInfo::subclassesFor('SilverStripe\\ORM\\DataObject')) as $candidate) {
|
||||
if (strcasecmp(singleton($candidate)->singular_name(), $type) === 0) {
|
||||
foreach (array_values(ClassInfo::subclassesFor(DataObject::class)) as $candidate) {
|
||||
if (class_exists($candidate) && strcasecmp(singleton($candidate)->singular_name(), $type) === 0) {
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user