mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 17:05:54 +02:00
FIX Update tests to ensure TestPage owns its widget area
This commit is contained in:
parent
5ca288c9a3
commit
8583b894a1
@ -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(
|
||||
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user