From 6df2a983e352a7f4cd830e4db7f42ab9ac98c9f2 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Wed, 29 Apr 2020 09:54:45 +1200 Subject: [PATCH] BUG Avoid trying to get singletons fon non-existan classes (#192) BUG Avoid trying to get singletons for non-existant classes --- .travis.yml | 19 ++++++------------- src/Context/FixtureContext.php | 6 +++--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31200a5e..20a57eda 100644 --- a/.travis.yml +++ b/.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 diff --git a/src/Context/FixtureContext.php b/src/Context/FixtureContext.php index d60dbca5..007c344e 100644 --- a/src/Context/FixtureContext.php +++ b/src/Context/FixtureContext.php @@ -897,13 +897,13 @@ protected function convertTypeToClass($type) // 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; } }