RegistryPageTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 16
c 1
b 0
f 0
dl 0
loc 35
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testDataSingleton() 0 4 1
A testDataClass() 0 4 1
A testPageLengthFieldOverridesDefault() 0 4 1
A testPageLengthDefault() 0 5 1
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