|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverStripe\Registry\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Core\Config\Config; |
|
6
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
7
|
|
|
use SilverStripe\Registry\RegistryPage; |
|
8
|
|
|
use SilverStripe\Registry\Tests\Stub\RegistryPageTestContact; |
|
9
|
|
|
use SilverStripe\Registry\Tests\Stub\RegistryPageTestSubclass; |
|
10
|
|
|
|
|
11
|
|
|
class RegistryPageTest extends SapphireTest |
|
12
|
|
|
{ |
|
13
|
|
|
protected static $fixture_file = [ |
|
14
|
|
|
'fixtures/RegistryPageTestContact.yml', |
|
15
|
|
|
'fixtures/RegistryPageTest.yml', |
|
16
|
|
|
]; |
|
17
|
|
|
|
|
18
|
|
|
protected static $extra_dataobjects = [ |
|
19
|
|
|
RegistryPageTestContact::class, |
|
20
|
|
|
RegistryPageTestSubclass::class, |
|
21
|
|
|
]; |
|
22
|
|
|
|
|
23
|
|
|
public function testPageLengthDefault() |
|
24
|
|
|
{ |
|
25
|
|
|
Config::modify()->set(RegistryPage::class, 'page_length_default', 13); |
|
26
|
|
|
$page = $this->objFromFixture(RegistryPage::class, 'contact-registrypage'); |
|
27
|
|
|
$this->assertEquals(13, $page->getPageLength()); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testPageLengthFieldOverridesDefault() |
|
31
|
|
|
{ |
|
32
|
|
|
$page = $this->objFromFixture(RegistryPage::class, 'contact-registrypage-with-length'); |
|
33
|
|
|
$this->assertEquals(20, $page->getPageLength()); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testDataClass() |
|
37
|
|
|
{ |
|
38
|
|
|
$page = $this->objFromFixture(RegistryPage::class, 'contact-registrypage'); |
|
39
|
|
|
$this->assertEquals(RegistryPageTestContact::class, $page->getDataClass()); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testDataSingleton() |
|
43
|
|
|
{ |
|
44
|
|
|
$page = $this->objFromFixture(RegistryPage::class, 'contact-registrypage'); |
|
45
|
|
|
$this->assertInstanceOf(RegistryPageTestContact::class, $page->getDataSingleton()); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|