Passed
Push — master ( 37791d...444a9e )
by Robbie
02:28
created

CKANRegistryPageControllerFunctionalTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSchemaFromPageSubUrl() 0 6 1
A testGetSchemaFromPageUrl() 0 6 1
A setUp() 0 8 1
1
<?php
2
3
namespace SilverStripe\CKANRegistry\Tests\Page;
4
5
use SilverStripe\CKANRegistry\Service\ResourcePopulatorInterface;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\Dev\FunctionalTest;
8
9
class CKANRegistryPageControllerFunctionalTest extends FunctionalTest
10
{
11
    protected static $fixture_file = 'CKANRegistryPageControllerTest.yml';
12
13
    protected static $use_draft_site = true;
14
15
    protected function setUp()
16
    {
17
        // Mock the field populator, in case an action we perform in a unit test tries to contact the mock API.
18
        // Done before parent::setUp() so write hooks don't run during fixture population.
19
        $populator = $this->createMock(ResourcePopulatorInterface::class);
20
        Injector::inst()->registerService($populator, ResourcePopulatorInterface::class);
21
22
        parent::setUp();
23
    }
24
25
    public function testGetSchemaFromPageUrl()
26
    {
27
        $response = $this->get('animal-centers/schema');
28
29
        $this->assertSame(200, $response->getStatusCode());
30
        $this->assertJson($response->getBody());
31
    }
32
33
    public function testGetSchemaFromPageSubUrl()
34
    {
35
        $response = $this->get('animal-centers/view/123/schema');
36
37
        $this->assertSame(200, $response->getStatusCode());
38
        $this->assertJson($response->getBody());
39
    }
40
}
41