-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from tractorcow/pulls/validate-extensions
API Add tests for incorrectly applied extensions
- Loading branch information
Showing
3 changed files
with
100 additions
and
0 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,43 @@ | ||
<?php | ||
|
||
class FluentValidateTaskTest extends SapphireTest | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
// Tweak configuration | ||
Config::inst()->update('Fluent', 'locales', array('fr_CA', 'en_NZ', 'en_US', 'es_ES')); | ||
} | ||
|
||
public function testNonBaseClass() { | ||
$config = Config::inst(); | ||
$config->update('Page', 'extensions', array('FluentExtension')); | ||
$validator = new FluentValidateTask(); | ||
$result = $validator->validateConfig($config); | ||
$this->assertFalse($result->valid()); | ||
$this->assertContains( | ||
'Class Page is not a base data class but has the following FluentExtensions: FluentExtension', | ||
$result->messageList() | ||
); | ||
} | ||
|
||
public function testMultipleExtensions() { | ||
$config = Config::inst(); | ||
$config->update('SiteTree', 'extensions', array('FluentExtension')); | ||
$validator = new FluentValidateTask(); | ||
$result = $validator->validateConfig($config); | ||
$this->assertFalse($result->valid()); | ||
$this->assertContains( | ||
'Class SiteTree has multiple FluentExtension classes: FluentExtension, FluentSiteTree', | ||
$result->messageList() | ||
); | ||
} | ||
|
||
public function testDefaultConfigValid() { | ||
$config = Config::inst(); | ||
$validator = new FluentValidateTask(); | ||
$result = $validator->validateConfig($config); | ||
$this->assertTrue($result->valid()); | ||
} | ||
} |