Completed
Push — master ( c2d471...c0413d )
by Aleksandar
208:47 queued 204:29
created

PageEntityTest::testStandardGettersAndSetters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 51
Code Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 44
nc 1
nop 0
dl 0
loc 51
rs 9.4109
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Page\Test\Entity;
6
7
class PageEntityTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testStandardGettersAndSetters()
10
    {
11
        $page = new \Page\Entity\Page();
12
13
        $date = date('d.m.Y', time());
14
        $dateFormatted = date('Y/m/d', time());
15
16
        $page->setBody('test');
17
        $page->setCreatedAt($date);
18
        $page->setDescription('test');
19
        $page->setHasLayout(1);
20
        $page->setIsActive(1);
21
        $page->setIsHomepage(1);
22
        $page->setIsWysiwygEditor(1);
23
        $page->setMainImg('test');
24
        $page->setPageId(1);
25
        $page->setPageUuid('test');
26
        $page->setSlug('test');
27
        $page->setTitle('test');
28
29
        static::assertSame('test', $page->getBody());
30
        static::assertSame($date, $page->getCreatedAt());
31
        static::assertSame($dateFormatted, $page->getCreatedAt('Y/m/d'));
32
        static::assertSame('test', $page->getDescription());
33
        static::assertSame('te', $page->getDescription(2));
34
        static::assertSame(1, $page->getHasLayout());
35
        static::assertSame(1, $page->getIsActive());
36
        static::assertSame(1, $page->getIsHomepage());
37
        static::assertSame(1, $page->getIsWysiwygEditor());
38
        static::assertSame(1, $page->getPageId());
39
        static::assertSame('test', $page->getMainImg());
40
        static::assertSame('test', $page->getPageUuid());
41
        static::assertSame('test', $page->getSlug());
42
        static::assertSame('test', $page->getTitle());
43
        static::assertSame(
44
            [
45
            'page_uuid'         => 'test',
46
            'page_id'           => '1',
47
            'title'             => 'test',
48
            'body'              => 'test',
49
            'description'       => 'test',
50
            'main_img'          => 'test',
51
            'has_layout'        => true,
52
            'is_homepage'       => true,
53
            'is_active'         => true,
54
            'is_wysiwyg_editor' => true,
55
            'created_at'        => $date,
56
            'slug'              => 'test',
57
            ], $page->getArrayCopy()
58
        );
59
    }
60
}
61