diff --git a/tests/WidgetControllerTest.php b/tests/WidgetControllerTest.php index 1f6e47d..cd0c1a1 100644 --- a/tests/WidgetControllerTest.php +++ b/tests/WidgetControllerTest.php @@ -3,14 +3,9 @@ namespace SilverStripe\Widgets\Tests; use SilverStripe\Dev\FunctionalTest; -use SilverStripe\Forms\Form; use SilverStripe\Widgets\Tests\WidgetControllerTest\TestPage; use SilverStripe\Widgets\Tests\WidgetControllerTest\TestWidget; -/** - * @package widgets - * @subpackage tests - */ class WidgetControllerTest extends FunctionalTest { protected static $fixture_file = 'WidgetControllerTest.yml'; @@ -20,11 +15,18 @@ class WidgetControllerTest extends FunctionalTest TestWidget::class, ]; + protected function setUp() + { + parent::setUp(); + + $this->actWithPermission('ADMIN', function () { + $this->objFromFixture(TestPage::class, 'page1')->publishRecursive(); + }); + } + public function testWidgetFormRendering() { $page = $this->objFromFixture(TestPage::class, 'page1'); - $page->copyVersionToStage('Stage', 'Live'); - $widget = $this->objFromFixture(TestWidget::class, 'widget1'); $response = $this->get($page->URLSegment); @@ -40,11 +42,9 @@ class WidgetControllerTest extends FunctionalTest public function testWidgetFormSubmission() { $page = $this->objFromFixture(TestPage::class, 'page1'); - $page->copyVersionToStage('Stage', 'Live'); - $widget = $this->objFromFixture(TestWidget::class, 'widget1'); - $response = $this->get($page->URLSegment); + $this->get($page->URLSegment); $response = $this->submitForm('Form_Form', null, array('TestValue' => 'Updated')); $this->assertContains( diff --git a/tests/WidgetControllerTest/TestPage.php b/tests/WidgetControllerTest/TestPage.php index cdb6417..e996133 100644 --- a/tests/WidgetControllerTest/TestPage.php +++ b/tests/WidgetControllerTest/TestPage.php @@ -4,18 +4,17 @@ namespace SilverStripe\Widgets\Tests\WidgetControllerTest; use Page; use SilverStripe\Dev\TestOnly; -use SilverStripe\View\SSViewer; use SilverStripe\Widgets\Model\WidgetArea; -/** - * @package cms - * @subpackage tests - */ class TestPage extends Page implements TestOnly { private static $table_name = 'TestPage'; - private static $has_one = array( - 'WidgetControllerTestSidebar' => WidgetArea::class - ); + private static $has_one = [ + 'WidgetControllerTestSidebar' => WidgetArea::class, + ]; + + private static $owns = [ + 'WidgetControllerTestSidebar', + ]; } diff --git a/tests/WidgetControllerTest/TestWidget.php b/tests/WidgetControllerTest/TestWidget.php index 3eef8e7..994b65e 100644 --- a/tests/WidgetControllerTest/TestWidget.php +++ b/tests/WidgetControllerTest/TestWidget.php @@ -5,15 +5,11 @@ namespace SilverStripe\Widgets\Tests\WidgetControllerTest; use SilverStripe\Dev\TestOnly; use SilverStripe\Widgets\Model\Widget; -/** - * @package widgets - * @subpackage tests - */ class TestWidget extends Widget implements TestOnly { private static $table_name = 'WidgetControllerTest_TestWidget'; - private static $db = array( - 'TestValue' => 'Text' - ); + private static $db = [ + 'TestValue' => 'Text', + ]; }