1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\Elements\Tests\Model; |
4
|
|
|
|
5
|
|
|
use Dynamic\Elements\Model\Testimonial; |
6
|
|
|
use SilverStripe\Dev\SapphireTest; |
7
|
|
|
use SilverStripe\Security\Member; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class TestimonialTest |
11
|
|
|
* @package Dynamic\Elements\Tests\Model |
12
|
|
|
*/ |
13
|
|
|
class TestimonialTest extends SapphireTest |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected static $fixture_file = '../fixtures.yml'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
public function testProvidePermissions() |
24
|
|
|
{ |
25
|
|
|
$this->assertTrue(is_array(Testimonial::singleton()->providePermissions())); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
public function testCanCreate() |
32
|
|
|
{ |
33
|
|
|
$this->assertTrue(Testimonial::singleton()->canCreate($this->objFromFixture(Member::class, 'site-owner'))); |
34
|
|
|
$this->assertFalse(Testimonial::singleton()->canCreate(Member::singleton())); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* |
39
|
|
|
*/ |
40
|
|
|
public function testCanEdit() |
41
|
|
|
{ |
42
|
|
|
$this->assertTrue($this->objFromFixture(Testimonial::class, 'one')->canEdit($this->objFromFixture(Member::class, 'site-owner'))); |
43
|
|
|
$this->assertFalse($this->objFromFixture(Testimonial::class, 'one')->canEdit(Member::singleton())); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* |
48
|
|
|
*/ |
49
|
|
|
public function testCanDelete() |
50
|
|
|
{ |
51
|
|
|
$this->assertTrue($this->objFromFixture(Testimonial::class, 'one')->canDelete($this->objFromFixture(Member::class, 'site-owner'))); |
52
|
|
|
$this->assertFalse($this->objFromFixture(Testimonial::class, 'one')->canDelete(Member::singleton())); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
*/ |
58
|
|
|
public function testCanView() |
59
|
|
|
{ |
60
|
|
|
$this->assertTrue($this->objFromFixture(Testimonial::class, 'one')->canView($this->objFromFixture(Member::class, 'site-owner'))); |
61
|
|
|
$this->assertTrue($this->objFromFixture(Testimonial::class, 'one')->canView(Member::singleton())); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|