2014-06-17 06:55:07 +02:00
|
|
|
<?php
|
2017-09-07 01:32:55 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\MultiForm\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
2017-09-07 03:44:31 +02:00
|
|
|
use SilverStripe\MultiForm\Extensions\MultiFormObjectDecorator;
|
2017-09-07 01:32:55 +02:00
|
|
|
|
2017-09-06 22:47:35 +02:00
|
|
|
class MultiFormObjectDecoratorTest extends SapphireTest
|
|
|
|
{
|
|
|
|
protected static $fixture_file = 'MultiFormObjectDecoratorTest.yml';
|
|
|
|
|
2017-09-07 03:44:31 +02:00
|
|
|
protected static $required_extensions = [
|
|
|
|
MultiFormObjectDecoratorDataObject::class => [MultiFormObjectDecorator::class]
|
2017-09-07 01:32:55 +02:00
|
|
|
];
|
2017-09-06 22:47:35 +02:00
|
|
|
|
2017-09-08 03:57:33 +02:00
|
|
|
protected static $extra_dataobjects = [
|
2017-09-07 03:44:31 +02:00
|
|
|
MultiFormObjectDecoratorDataObject::class
|
2017-09-07 01:32:55 +02:00
|
|
|
];
|
2017-09-06 22:47:35 +02:00
|
|
|
|
|
|
|
public function testTemporaryDataFilteredQuery()
|
|
|
|
{
|
2017-09-07 01:32:55 +02:00
|
|
|
$records = MultiFormObjectDecoratorDataObject::get()
|
2017-09-06 22:47:35 +02:00
|
|
|
->map('Name')
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
$this->assertContains('Test 1', $records);
|
|
|
|
$this->assertContains('Test 2', $records);
|
|
|
|
$this->assertNotContains('Test 3', $records);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTemporaryDataQuery()
|
|
|
|
{
|
2017-09-07 01:32:55 +02:00
|
|
|
$records = MultiFormObjectDecoratorDataObject::get()
|
|
|
|
->filter(['MultiFormIsTemporary' => 1])
|
2017-09-06 22:47:35 +02:00
|
|
|
->map('Name')
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
$this->assertNotContains('Test 1', $records);
|
|
|
|
$this->assertNotContains('Test 2', $records);
|
|
|
|
$this->assertContains('Test 3', $records);
|
|
|
|
}
|
2014-06-17 06:55:07 +02:00
|
|
|
}
|