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

ShortURLTest::testGetValidate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
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
}