generated from silverstripe/silverstripe-module
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TESTS CarouselPageExtensionTest initial (#14)
- Loading branch information
Showing
4 changed files
with
96 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Dynamic\Carousel\Test\Extension; | ||
|
||
use Dynamic\Carousel\Model\ImageSlide; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Dev\SapphireTest; | ||
use Dynamic\Carousel\Test\Test\Page\TestPage; | ||
use Dynamic\Carousel\Extension\CarouselPageExtension; | ||
|
||
class CarouselPageExtensionTest extends SapphireTest | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected static $extra_dataobjects = [ | ||
TestPage::class, | ||
]; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected static $fixture_file = 'carousel.yml'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected static $required_extensions = [ | ||
TestPage::class => [ | ||
CarouselPageExtension::class, | ||
], | ||
]; | ||
|
||
/** | ||
* Tests updateCMSFields(). | ||
*/ | ||
public function testUpdateCMSFields() | ||
{ | ||
$object = TestPage::create(); | ||
$fields = $object->getCMSFields(); | ||
$this->assertFalse($object->exists()); | ||
$this->assertNull($fields->dataFieldByName('Slides')); | ||
|
||
$object->write(); | ||
$fields = $object->getCMSFields(); | ||
$this->assertInstanceOf(FieldList::class, $fields); | ||
$this->assertNotNull($fields->dataFieldbyName('Slides')); | ||
} | ||
|
||
/** | ||
* Tests getSlides(). | ||
*/ | ||
public function testGetSlides() | ||
{ | ||
$object = TestPage::create(); | ||
$object->write(); | ||
$object->Slides()->add($this->objFromFixture(ImageSlide::class, 'one')); | ||
$this->assertEquals(1, $object->Slides()->count()); | ||
} | ||
} |
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,4 @@ | ||
Dynamic\Carousel\Model\ImageSlide: | ||
one: | ||
Title: 'Image Slide 1' | ||
Content: 'Image Slide 1 Content' |
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,10 @@ | ||
<?php | ||
|
||
namespace Dynamic\Carousel\Test\Test\Page; | ||
|
||
use SilverStripe\Dev\TestOnly; | ||
|
||
class TestPage extends \Page implements TestOnly | ||
{ | ||
private static $table_name = 'Carousel_TestPage'; | ||
} |