-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ElementalAreasExtension::getElementalTypes and minor sy…
…ntax tidy up
- Loading branch information
1 parent
405a691
commit e80875f
Showing
3 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace DNADesign\Elemental\Tests\Extensions; | ||
|
||
use DNADesign\Elemental\Extensions\ElementalAreasExtension; | ||
use DNADesign\Elemental\Tests\Src\TestElement; | ||
use DNADesign\Elemental\Tests\Src\TestUnusedElement; | ||
use SilverStripe\CMS\Model\SiteTree; | ||
use SilverStripe\Core\Config\Config; | ||
use SilverStripe\Dev\SapphireTest; | ||
|
||
class ElementalAreasExtensionTest extends SapphireTest | ||
{ | ||
protected static $required_extensions = [ | ||
SiteTree::class => [ | ||
ElementalAreasExtension::class, | ||
], | ||
]; | ||
|
||
protected static $extra_dataobjects = [ | ||
TestElement::class, | ||
TestUnusedElement::class, | ||
]; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->logInWithPermission('ADMIN'); | ||
|
||
SiteTree::config() | ||
->set('allowed_elements', null) | ||
->set('disallowed_elements', []); | ||
} | ||
|
||
public function testGetElementalTypesSortsAlphabetically() | ||
{ | ||
SiteTree::config()->set('sort_types_alphabetically', true); | ||
|
||
/** @var SiteTree|ElementalAreasExtension $page */ | ||
$page = new SiteTree(); | ||
$types = $page->getElementalTypes(); | ||
|
||
$this->assertSame(['A test element', 'Content', 'Unused Element'], array_values($types)); | ||
} | ||
|
||
public function testGetElementalTypesAreNotSortedAlphabetically() | ||
{ | ||
SiteTree::config()->set('sort_types_alphabetically', false); | ||
|
||
/** @var SiteTree|ElementalAreasExtension $page */ | ||
$page = new SiteTree(); | ||
$types = $page->getElementalTypes(); | ||
|
||
$this->assertSame(['Content', 'A test element', 'Unused Element'], array_values($types)); | ||
} | ||
} |