Skip to content

Commit

Permalink
FIX Allow ElementalAreasExtensionTests to pass in integration envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Garion Herman committed Jan 30, 2019
1 parent e80875f commit 0b13008
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/Extensions/ElementalAreasExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetElementalTypesSortsAlphabetically()
$page = new SiteTree();
$types = $page->getElementalTypes();

$this->assertSame(['A test element', 'Content', 'Unused Element'], array_values($types));
$this->assertContainsInOrder(['A test element', 'Content', 'Unused Element'], array_values($types));
}

public function testGetElementalTypesAreNotSortedAlphabetically()
Expand All @@ -52,6 +52,20 @@ public function testGetElementalTypesAreNotSortedAlphabetically()
$page = new SiteTree();
$types = $page->getElementalTypes();

$this->assertSame(['Content', 'A test element', 'Unused Element'], array_values($types));
$this->assertContainsInOrder(['Content', 'A test element', 'Unused Element'], array_values($types));
}

/**
* We need to check that the order of the elements is correct, but there might be more element types installed than
* we're aware of, so we first extract the elements we want from the source list and check the order afterwards.
*
* @param array $expected
* @param array $actual
*/
private function assertContainsInOrder(array $expected, array $actual)
{
$matches = array_values(array_intersect($actual, $expected));

$this->assertSame($expected, $matches);
}
}

0 comments on commit 0b13008

Please sign in to comment.