Completed
Push — master ( 7b4143...7f762c )
by Jason
10s
created

ShortURLTest::testGetLongURL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
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
        'shorturls/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');
0 ignored issues
show
Bug introduced by Jason Irish
The method setExpectedException() does not seem to exist on object<Dynamic\ShortURL\Tests\ShortURLTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        $object->write();
33
34
        $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
35
        $object->URL = '';
36
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by Jason Irish
The method setExpectedException() does not seem to exist on object<Dynamic\ShortURL\Tests\ShortURLTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        $object->write();
38
39
        $this->objFromFixture('Dynamic\\ShortURL\\ShortURL', 'one');
40
        $object->CampaignSource = '';
41
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by Jason Irish
The method setExpectedException() does not seem to exist on object<Dynamic\ShortURL\Tests\ShortURLTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
        $object->write();
43
    }
44
45
    /**
46
     *
47
     */
48
    function testGetLongURL()
0 ignored issues
show
Best Practice introduced by Jason Irish
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());
0 ignored issues
show
Bug introduced by Jason Irish
The method assertEquals() does not seem to exist on object<Dynamic\ShortURL\Tests\ShortURLTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
    }
54
}