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-06 22:47:35 +02:00
|
|
|
class MultiFormObjectDecoratorTest extends SapphireTest
|
|
|
|
{
|
|
|
|
protected static $fixture_file = 'MultiFormObjectDecoratorTest.yml';
|
|
|
|
|
2017-09-07 01:32:55 +02:00
|
|
|
protected $requiredExtensions = [
|
|
|
|
'MultiFormObjectDecoratorDataObject' => ['MultiFormObjectDecorator']
|
|
|
|
];
|
2017-09-06 22:47:35 +02:00
|
|
|
|
2017-09-07 01:32:55 +02:00
|
|
|
protected $extraDataObjects = [
|
|
|
|
'MultiFormObjectDecoratorDataObject'
|
|
|
|
];
|
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
|
|
|
}
|