Passed
Pull Request — master (#26)
by Jason
02:06
created

FoxyCategoryTest::testValidateCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\Foxy\Test\Model;
4
5
use Dynamic\Foxy\Model\FoxyCategory;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\ORM\ValidationException;
10
11
class FoxyCategoryTest extends SapphireTest
12
{
13
    /**
14
     * @var string
15
     */
16
    protected static $fixture_file = '../fixtures.yml';
17
18
    /**
19
     *
20
     */
21
    public function testGetCMSFields()
22
    {
23
        $object = $this->objFromFixture(FoxyCategory::class, 'one');
24
        $fields = $object->getCMSFields();
25
        $this->assertInstanceOf(FieldList::class, $fields);
26
27
        $object = Injector::inst()->create(FoxyCategory::class);
28
        $object->Code = 'DEFAULT';
29
        $object->write();
30
        $fields = $object->getCMSFields();
31
        $this->assertInstanceOf(FieldList::class, $fields);
32
    }
33
34
    /**
35
     *
36
     */
37
    public function testValidateCode()
38
    {
39
        $object = $this->objFromFixture(FoxyCategory::class, 'one');
40
        $object->Code = '';
41
        $this->setExpectedException(ValidationException::class);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit_Framework_TestCase::setExpectedException() has been deprecated: Method deprecated since Release 5.2.0; use expectException() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

41
        /** @scrutinizer ignore-deprecated */ $this->setExpectedException(ValidationException::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
42
        $object->write();
43
44
        $object = $this->objFromFixture(FoxyCategory::class, 'one');
45
        $object->Code = 'DEFAULT';
46
        $this->setExpectedException(ValidationException::class);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit_Framework_TestCase::setExpectedException() has been deprecated: Method deprecated since Release 5.2.0; use expectException() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

46
        /** @scrutinizer ignore-deprecated */ $this->setExpectedException(ValidationException::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
47
        $object->write();
48
    }
49
}
50