@@ 3-79 (lines=77) @@ | ||
1 | <?php |
|
2 | ||
3 | class AccordionPanelTest extends SapphireTest |
|
4 | { |
|
5 | /** |
|
6 | * @var string |
|
7 | */ |
|
8 | protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml'; |
|
9 | ||
10 | /** |
|
11 | * |
|
12 | */ |
|
13 | public function testGetCMSFields() |
|
14 | { |
|
15 | $object = $this->objFromFixture('AccordionPanel', 'one'); |
|
16 | $fields = $object->getCMSFields(); |
|
17 | $this->assertInstanceOf('FieldList', $fields); |
|
18 | $this->assertNull($fields->dataFieldByName('SortOrder')); |
|
19 | } |
|
20 | ||
21 | /** |
|
22 | * |
|
23 | */ |
|
24 | public function testValidateTitle() |
|
25 | { |
|
26 | $object = $this->objFromFixture('AccordionPanel', 'one'); |
|
27 | $object->Title = ''; |
|
28 | $this->setExpectedException('ValidationException'); |
|
29 | $object->write(); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * |
|
34 | */ |
|
35 | public function testCanView() |
|
36 | { |
|
37 | $object = $this->objFromFixture('AccordionPanel', 'one'); |
|
38 | $admin = $this->objFromFixture('Member', 'admin'); |
|
39 | $this->assertTrue($object->canView($admin)); |
|
40 | $member = $this->objFromFixture('Member', 'default'); |
|
41 | $this->assertTrue($object->canView($member)); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * |
|
46 | */ |
|
47 | public function testCanEdit() |
|
48 | { |
|
49 | $object = $this->objFromFixture('AccordionPanel', 'one'); |
|
50 | $admin = $this->objFromFixture('Member', 'admin'); |
|
51 | $this->assertTrue($object->canEdit($admin)); |
|
52 | $member = $this->objFromFixture('Member', 'default'); |
|
53 | $this->assertTrue($object->canEdit($member)); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * |
|
58 | */ |
|
59 | public function testCanDelete() |
|
60 | { |
|
61 | $object = $this->objFromFixture('AccordionPanel', 'one'); |
|
62 | $admin = $this->objFromFixture('Member', 'admin'); |
|
63 | $this->assertTrue($object->canDelete($admin)); |
|
64 | $member = $this->objFromFixture('Member', 'default'); |
|
65 | $this->assertTrue($object->canDelete($member)); |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * |
|
70 | */ |
|
71 | public function testCanCreate() |
|
72 | { |
|
73 | $object = $this->objFromFixture('AccordionPanel', 'one'); |
|
74 | $admin = $this->objFromFixture('Member', 'admin'); |
|
75 | $this->assertTrue($object->canCreate($admin)); |
|
76 | $member = $this->objFromFixture('Member', 'default'); |
|
77 | $this->assertTrue($object->canCreate($member)); |
|
78 | } |
|
79 | } |
|
80 |
@@ 3-79 (lines=77) @@ | ||
1 | <?php |
|
2 | ||
3 | class PageSectionObjectTest extends SapphireTest |
|
4 | { |
|
5 | /** |
|
6 | * @var string |
|
7 | */ |
|
8 | protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml'; |
|
9 | ||
10 | /** |
|
11 | * |
|
12 | */ |
|
13 | public function testGetCMSFields() |
|
14 | { |
|
15 | $object = $this->objFromFixture('PageSectionObject', 'one'); |
|
16 | $fields = $object->getCMSFields(); |
|
17 | $this->assertInstanceOf('FieldList', $fields); |
|
18 | $this->assertNotNull($fields->dataFieldByName('BlockLinkID')); |
|
19 | } |
|
20 | ||
21 | /** |
|
22 | * |
|
23 | */ |
|
24 | public function testValidateName() |
|
25 | { |
|
26 | $object = $this->objFromFixture('PageSectionObject', 'one'); |
|
27 | $object->Name = ''; |
|
28 | $this->setExpectedException('ValidationException'); |
|
29 | $object->write(); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * |
|
34 | */ |
|
35 | public function testCanView() |
|
36 | { |
|
37 | $object = $this->objFromFixture('PageSectionObject', 'one'); |
|
38 | $admin = $this->objFromFixture('Member', 'admin'); |
|
39 | $this->assertTrue($object->canView($admin)); |
|
40 | $member = $this->objFromFixture('Member', 'default'); |
|
41 | $this->assertTrue($object->canView($member)); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * |
|
46 | */ |
|
47 | public function testCanEdit() |
|
48 | { |
|
49 | $object = $this->objFromFixture('PageSectionObject', 'one'); |
|
50 | $admin = $this->objFromFixture('Member', 'admin'); |
|
51 | $this->assertTrue($object->canEdit($admin)); |
|
52 | $member = $this->objFromFixture('Member', 'default'); |
|
53 | $this->assertTrue($object->canEdit($member)); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * |
|
58 | */ |
|
59 | public function testCanDelete() |
|
60 | { |
|
61 | $object = $this->objFromFixture('PageSectionObject', 'one'); |
|
62 | $admin = $this->objFromFixture('Member', 'admin'); |
|
63 | $this->assertTrue($object->canDelete($admin)); |
|
64 | $member = $this->objFromFixture('Member', 'default'); |
|
65 | $this->assertTrue($object->canDelete($member)); |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * |
|
70 | */ |
|
71 | public function testCanCreate() |
|
72 | { |
|
73 | $object = $this->objFromFixture('PageSectionObject', 'one'); |
|
74 | $admin = $this->objFromFixture('Member', 'admin'); |
|
75 | $this->assertTrue($object->canCreate($admin)); |
|
76 | $member = $this->objFromFixture('Member', 'default'); |
|
77 | $this->assertTrue($object->canCreate($member)); |
|
78 | } |
|
79 | } |
@@ 3-79 (lines=77) @@ | ||
1 | <?php |
|
2 | ||
3 | class PromoObjectTest extends SapphireTest |
|
4 | { |
|
5 | /** |
|
6 | * @var string |
|
7 | */ |
|
8 | protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml'; |
|
9 | ||
10 | /** |
|
11 | * |
|
12 | */ |
|
13 | public function testGetCMSFields() |
|
14 | { |
|
15 | $object = $this->objFromFixture('PromoObject', 'one'); |
|
16 | $fields = $object->getCMSFields(); |
|
17 | $this->assertInstanceOf('FieldList', $fields); |
|
18 | $this->assertNotNull($fields->dataFieldByName('BlockLinkID')); |
|
19 | } |
|
20 | ||
21 | /** |
|
22 | * |
|
23 | */ |
|
24 | public function testValidateName() |
|
25 | { |
|
26 | $object = $this->objFromFixture('PromoObject', 'one'); |
|
27 | $object->Name = ''; |
|
28 | $this->setExpectedException('ValidationException'); |
|
29 | $object->write(); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * |
|
34 | */ |
|
35 | public function testCanView() |
|
36 | { |
|
37 | $object = $this->objFromFixture('PromoObject', 'one'); |
|
38 | $admin = $this->objFromFixture('Member', 'admin'); |
|
39 | $this->assertTrue($object->canView($admin)); |
|
40 | $member = $this->objFromFixture('Member', 'default'); |
|
41 | $this->assertTrue($object->canView($member)); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * |
|
46 | */ |
|
47 | public function testCanEdit() |
|
48 | { |
|
49 | $object = $this->objFromFixture('PromoObject', 'one'); |
|
50 | $admin = $this->objFromFixture('Member', 'admin'); |
|
51 | $this->assertTrue($object->canEdit($admin)); |
|
52 | $member = $this->objFromFixture('Member', 'default'); |
|
53 | $this->assertTrue($object->canEdit($member)); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * |
|
58 | */ |
|
59 | public function testCanDelete() |
|
60 | { |
|
61 | $object = $this->objFromFixture('PromoObject', 'one'); |
|
62 | $admin = $this->objFromFixture('Member', 'admin'); |
|
63 | $this->assertTrue($object->canDelete($admin)); |
|
64 | $member = $this->objFromFixture('Member', 'default'); |
|
65 | $this->assertTrue($object->canDelete($member)); |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * |
|
70 | */ |
|
71 | public function testCanCreate() |
|
72 | { |
|
73 | $object = $this->objFromFixture('PromoObject', 'one'); |
|
74 | $admin = $this->objFromFixture('Member', 'admin'); |
|
75 | $this->assertTrue($object->canCreate($admin)); |
|
76 | $member = $this->objFromFixture('Member', 'default'); |
|
77 | $this->assertTrue($object->canCreate($member)); |
|
78 | } |
|
79 | } |