-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW Add a couple of basic test classes
- Loading branch information
1 parent
e5a2f76
commit 8f79e65
Showing
2 changed files
with
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
class DocumentConverterDecoratorTest extends SapphireTest | ||
{ | ||
protected $requiredExtensions = array( | ||
'SiteTree' => array( | ||
'DocumentConverterDecorator', | ||
), | ||
); | ||
|
||
public function testFieldListHasDocumentImportField() | ||
{ | ||
$fields = (new SiteTree)->getCMSFields(); | ||
$this->assertInstanceOf( | ||
'DocumentImportField', | ||
$fields->fieldByName('Root.Import')->Fields()->First() | ||
); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
class DocumentImportFieldTest extends SapphireTest | ||
{ | ||
/** | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testConstructorThrowsExceptionWhenGivenString() | ||
{ | ||
new DocumentImportField('exception time!'); | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testConstructorThrowsExceptionWhenGivenChildren() | ||
{ | ||
new DocumentImportField(['i', 'don\'t', 'like', 'kids']); | ||
} | ||
|
||
public function testFieldAddsJavascriptRequirements() | ||
{ | ||
// Start with a clean slate (no global state interference) | ||
Requirements::backend()->clear(); | ||
|
||
new DocumentImportField(); | ||
$javascript = Requirements::backend()->get_javascript(); | ||
$this->assertNotEmpty($javascript); | ||
} | ||
|
||
public function testFieldListGeneration() | ||
{ | ||
$importField = new DocumentImportField(); | ||
|
||
$fields = $importField->getChildren(); | ||
$this->assertInstanceOf('FieldList', $fields); | ||
|
||
// We don't need to check that all of the fields are there, but just check a couple | ||
$this->assertInstanceOf('HeaderField', $fields->fieldByName('FileWarningHeader')); | ||
$innerField = $fields->fieldByName('ImportedFromFile'); | ||
$this->assertInstanceOf('DocumentImportInnerField', $innerField); | ||
|
||
// Check the getter works | ||
$this->assertSame($innerField, $importField->getInnerField()); | ||
|
||
// Check the fields have been given has the change tracker disabled | ||
$splitHeader = $fields->fieldByName('DocumentImportField-SplitHeader'); | ||
$this->assertInstanceOf('DropdownField', $splitHeader); | ||
$this->assertContains('no-change-track', $splitHeader->extraClass()); | ||
} | ||
} |