From 81f292a2b5825da0a006e9cc50b4266b3f415c86 Mon Sep 17 00:00:00 2001 From: Fred Condo Date: Wed, 16 Jul 2014 17:01:45 -0700 Subject: [PATCH] Make SiteTree reference conditional This makes the boilerplate code compatible for testing framework-only sites. --- .../Console/Processor/InitProcessor.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Console/Processor/InitProcessor.php b/src/SilverStripe/BehatExtension/Console/Processor/InitProcessor.php index 8ab91b5..b42c052 100644 --- a/src/SilverStripe/BehatExtension/Console/Processor/InitProcessor.php +++ b/src/SilverStripe/BehatExtension/Console/Processor/InitProcessor.php @@ -197,13 +197,15 @@ class FeatureContext extends SilverStripeContext { $factory->define('Member', $blueprint); // Auto-publish pages - foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) { - $blueprint = \Injector::inst()->create('FixtureBlueprint', $class); - $blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) { - $obj->publish('Stage', 'Live'); - }); - $factory->define($class, $blueprint); - } + if (class_exists('SiteTree')) { + foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) { + $blueprint = \Injector::inst()->create('FixtureBlueprint', $class); + $blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) { + $obj->publish('Stage', 'Live'); + }); + $factory->define($class, $blueprint); + } + } } public function setMinkParameters(array $parameters) {