Completed
Push — master ( ac8ea3...0c3653 )
by André
17:37
created

VersionInfoTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 71.43 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 30
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsDraft() 10 10 1
A testIsPublished() 10 10 1
A testIsArchived() 10 10 1
A createVersionInfoWithStatus() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * File containing the VersionInfoTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Repository\Tests\Values\Content;
10
11
use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
12
use PHPUnit_Framework_TestCase;
13
14
class VersionInfoTest extends PHPUnit_Framework_TestCase
15
{
16 View Code Duplication
    public function testIsDraft()
17
    {
18
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_DRAFT);
19
        self::assertTrue($versionInfo->isDraft());
20
21
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_ARCHIVED);
22
        self::assertFalse($versionInfo->isDraft());
23
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_PUBLISHED);
24
        self::assertFalse($versionInfo->isDraft());
25
    }
26
27 View Code Duplication
    public function testIsPublished()
28
    {
29
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_PUBLISHED);
30
        self::assertTrue($versionInfo->isPublished());
31
32
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_DRAFT);
33
        self::assertFalse($versionInfo->isPublished());
34
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_ARCHIVED);
35
        self::assertFalse($versionInfo->isPublished());
36
    }
37
38 View Code Duplication
    public function testIsArchived()
39
    {
40
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_ARCHIVED);
41
        self::assertTrue($versionInfo->isArchived());
42
43
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_DRAFT);
44
        self::assertFalse($versionInfo->isArchived());
45
        $versionInfo = $this->createVersionInfoWithStatus(VersionInfo::STATUS_PUBLISHED);
46
        self::assertFalse($versionInfo->isArchived());
47
    }
48
49
    private function createVersionInfoWithStatus($status)
50
    {
51
        return new VersionInfo(array(
52
            'status' => $status,
53
        ));
54
    }
55
}
56