Completed
Pull Request — master (#1)
by Jason
01:28 queued 19s
created

ShortURLTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCMSFields() 0 6 1
A testGetValidate() 0 17 1
A testGetLongURL() 0 6 1
1
<?php
2
3
namespace Dynamic\ShortURL\Tests;
4
5
class ShortURLTest extends \SapphireTest
6
{
7
    /**
8
     * @var array
9
     */
10
    protected static $fixture_file = array(
11
        'shorturl/tests/fixtures.yml',
12
    );
13
14
    /**
15
     *
16
     */
17
    public function testGetCMSFields()
18
    {
19
        $object = $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
20
        $fields = $object->getCMSFields();
21
        $this->assertInstanceOf('FieldList', $fields);
22
    }
23
24
    /**
25
     *
26
     */
27
    public function testGetValidate()
28
    {
29
        $object = $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
30
        $object->Title = '';
31
        $this->setExpectedException('ValidationException');
32
        $object->write();
33
34
        $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
35
        $object->URL = '';
36
        $this->setExpectedException('ValidationException');
37
        $object->write();
38
39
        $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
40
        $object->CampaignSource = '';
41
        $this->setExpectedException('ValidationException');
42
        $object->write();
43
    }
44
45
    /**
46
     *
47
     */
48
    function testGetLongURL()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
49
    {
50
        $object = $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
51
        $expected = $object->URL . '?utm_source=' . $object->CampaignSource;
52
        $this->assertEquals($expected, $object->getLongURL());
53
    }
54
}