1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\RecipeBook\Test\Model; |
4
|
|
|
|
5
|
|
|
use Dynamic\RecipeBook\Model\RecipeDirection; |
6
|
|
|
use Dynamic\RecipeBook\Page\RecipePage; |
7
|
|
|
use SilverStripe\Dev\SapphireTest; |
8
|
|
|
use SilverStripe\Forms\FieldList; |
9
|
|
|
use SilverStripe\ORM\ValidationException; |
10
|
|
|
|
11
|
|
|
class RecipeDirectionTest extends SapphireTest |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
protected static $fixture_file = '../fixtures.yml'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
public function testGetCMSFields() |
22
|
|
|
{ |
23
|
|
|
$object = $this->objFromFixture(RecipeDirection::class, 'one'); |
24
|
|
|
$fields = $object->getCMSFields(); |
25
|
|
|
$this->assertInstanceOf(FieldList::class, $fields); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @throws ValidationException |
30
|
|
|
*/ |
31
|
|
|
public function testDefaultSortValue() |
32
|
|
|
{ |
33
|
|
|
$recipe = $this->objFromFixture(RecipePage::class, 'two'); |
34
|
|
|
|
35
|
|
|
$direction = RecipeDirection::create(); |
36
|
|
|
$direction->Title = 'My First Direction'; |
37
|
|
|
$direction->RecipeID = $recipe->ID; |
38
|
|
|
|
39
|
|
|
$this->assertEquals(0, $direction->Sort); |
40
|
|
|
|
41
|
|
|
$direction->write(); |
42
|
|
|
|
43
|
|
|
$this->assertNotEquals(0, $direction->Sort); |
44
|
|
|
|
45
|
|
|
$direction2 = RecipeDirection::create(); |
46
|
|
|
$direction2->Title = 'My Second Direction'; |
47
|
|
|
$direction2->RecipeID = $recipe->ID; |
48
|
|
|
|
49
|
|
|
$this->assertEquals(0, $direction2->Sort); |
50
|
|
|
|
51
|
|
|
$direction2->write(); |
52
|
|
|
|
53
|
|
|
$this->assertGreaterThan($direction->Sort, $direction2->Sort); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|