|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dynamic\Products\Test\Page; |
|
4
|
|
|
|
|
5
|
|
|
use Dynamic\Products\Page\ProductCategory; |
|
6
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
7
|
|
|
use SilverStripe\Forms\FieldList; |
|
8
|
|
|
use SilverStripe\Security\Member; |
|
9
|
|
|
|
|
10
|
|
|
class ProductCategoryTest extends SapphireTest |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected static $fixture_file = '../fixtures.yml'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* |
|
19
|
|
|
*/ |
|
20
|
|
|
public function testGetCMSFields() |
|
21
|
|
|
{ |
|
22
|
|
|
$object = $this->objFromFixture(ProductCategory::class, 'default'); |
|
23
|
|
|
$fields = $object->getCMSFields(); |
|
24
|
|
|
$this->assertInstanceOf(FieldList::class, $fields); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
public function testGetProductList() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->markTestSkipped('Currently doesn\'t seem to respect the groups/members in automated tests'); |
|
33
|
|
|
|
|
34
|
|
|
$this->logOut(); |
|
35
|
|
|
$member = $this->objFromFixture(Member::class, 'author'); |
|
36
|
|
|
$this->logInAs(Member::get()->byID($member->ID)); |
|
37
|
|
|
$categoryID = $this->objFromFixture(ProductCategory::class, 'restricted')->ID; |
|
38
|
|
|
/** @var ProductCategory $category */ |
|
39
|
|
|
$category = ProductCategory::get()->byID($categoryID); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertEquals(2, $category->getProductList()->count()); |
|
42
|
|
|
|
|
43
|
|
|
$this->logOut(); |
|
44
|
|
|
$member = $this->objFromFixture(Member::class, 'default'); |
|
45
|
|
|
$this->logInAs(Member::get()->byID($member->ID)); |
|
46
|
|
|
/** @var ProductCategory $category */ |
|
47
|
|
|
$category = ProductCategory::get()->byID($categoryID); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertEquals(1, $category->getProductList()->count()); |
|
50
|
|
|
|
|
51
|
|
|
$this->logOut(); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|