From 7649434b64979503d1b0d81fc4b037fccc48420b Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 12 Oct 2018 17:38:34 +0200 Subject: [PATCH 1/2] FIX Handle cases when trying to lookup TestOnly classes that fail because they have no table --- src/Models/ElementalArea.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Models/ElementalArea.php b/src/Models/ElementalArea.php index 77a7f47d..7b5bc63b 100644 --- a/src/Models/ElementalArea.php +++ b/src/Models/ElementalArea.php @@ -7,6 +7,7 @@ use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\TestOnly; use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\FieldType\DBField; @@ -185,7 +186,17 @@ public function getOwnerPage() foreach ($elementalAreaRelations as $eaRelationship) { $areaID = $eaRelationship . 'ID'; - $page = Versioned::get_by_stage($class, Versioned::DRAFT)->filter($areaID, $this->ID)->first(); + try { + $page = Versioned::get_by_stage($class, Versioned::DRAFT)->filter($areaID, $this->ID)->first(); + } catch (\Exception $ex) { + // Usually this is catching cases where test stubs from other modules are trying to be loaded + // and failing in unit tests. + if (in_array(TestOnly::class, class_implements($class))) { + continue; + } + // Continue as normal... + throw $ex; + } if ($page) { if ($this->OwnerClassName !== $class) { From 15602cfb319b0f359dcf95dc1ef71d982ea033f9 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Tue, 29 Jan 2019 13:33:12 +0200 Subject: [PATCH 2/2] Fix for case insensitive string comparison assertion in checkbox group field test In SilverStripe 4.4 field labels are sentence cased. This changes the assertion to be flexible and pass in 4.4+ as well as <=4.3 --- tests/Forms/TextCheckboxGroupFieldTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Forms/TextCheckboxGroupFieldTest.php b/tests/Forms/TextCheckboxGroupFieldTest.php index 3f46dcb7..a6171e39 100644 --- a/tests/Forms/TextCheckboxGroupFieldTest.php +++ b/tests/Forms/TextCheckboxGroupFieldTest.php @@ -27,7 +27,8 @@ protected function setUp() public function testFieldIsAssignedFirstFieldsTitleInConstructor() { - $this->assertSame('Hello World', $this->field->Title()); + // Note: SilverStripe 4.0-4.3 = "Hello World", 4.4+ "Hello world" + $this->assertTrue(strcasecmp('Hello World', $this->field->Title()) === 0); } public function testFieldReturnsCompositeFieldTemplateOnReadonlyTransformation()