testCopyIsReturnedWhenShorterThenIntroWordCount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Axstrad library.
5
 *
6
 * (c) Dan Kempster <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @copyright 2014-2015 Dan Kempster <[email protected]>
12
 */
13
14
namespace Axstrad\Component\Content\Tests\Unit\Traits;
15
16
use Axstrad\Component\Content\Tests\Stubs\Traits\CopyBasedIntroductionTraitStub;
17
use Axstrad\Component\Content\Traits\CopyBasedIntroduction;
18
19
/**
20
 * Axstrad\Component\Content\Tests\Unit\Model\CopyIntroductionTest
21
 *
22
 * @author Dan Kempster <[email protected]>
23
 * @license MIT
24
 * @package Axstrad/Content
25
 * @subpackage Tests
26
 * @group unit
27
 */
28
class CopyIntroductionTest extends \PHPUnit_Framework_TestCase
29
{
30
    /**
31
     * @var CopyBasedIntroduction
32
     */
33
    protected $fixture;
34
35
    /**
36
     * @return void
37
     */
38
    public function setUp()
39
    {
40
        $this->fixture = new CopyBasedIntroductionTraitStub;
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Axstrad\Component\C...IntroductionTraitStub() of type object<Axstrad\Component...dIntroductionTraitStub> is incompatible with the declared type object<Axstrad\Component...\CopyBasedIntroduction> of property $fixture.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
    }
42
43
    public function testCopyIsUsedWhenIntroIsNotSet()
44
    {
45
        $this->fixture->setCopy(
46
            "Lorem ipsum Eu nostrud dolor reprehenderit consectetur Duis dolore labore incididunt enim ut aliqua enim ut Duis occaecat nulla in sit qui quis laboris commodo cillum officia reprehenderit ex minim consequat cillum sit veniam aliqua magna sint officia ullamco pariatur.".
47
            "Sed do in pariatur Ut labore ut sint Excepteur quis eu consectetur veniam sed exercitation fugiat quis sit exercitation ex ut et mollit magna in dolor aute in ut amet aute enim aute minim aute magna enim amet eu."
48
        );
49
50
        $this->assertEquals(
51
            "Lorem ipsum Eu nostrud dolor reprehenderit consectetur Duis dolore labore incididunt enim ut aliqua enim ut Duis occaecat nulla in sit qui quis laboris commodo cillum officia reprehenderit ex minim...",
52
            $this->fixture->getIntroduction()
53
        );
54
    }
55
56
    public function testIntroducitonEllipseCanBeSet()
57
    {
58
        $this->fixture->setCopy(
59
            "Lorem ipsum Eu nostrud dolor reprehenderit consectetur Duis dolore labore incididunt enim ut aliqua enim ut Duis occaecat nulla in sit qui quis laboris commodo cillum officia reprehenderit ex minim consequat cillum sit veniam aliqua magna sint officia ullamco pariatur.".
60
            "Sed do in pariatur Ut labore ut sint Excepteur quis eu consectetur veniam sed exercitation fugiat quis sit exercitation ex ut et mollit magna in dolor aute in ut amet aute enim aute minim aute magna enim amet eu."
61
        );
62
63
        $this->assertEquals(
64
            "Lorem ipsum Eu nostrud dolor reprehenderit consectetur Duis dolore labore incididunt enim ut aliqua enim ut Duis occaecat nulla in sit qui quis laboris commodo cillum officia reprehenderit ex minim!!!",
65
            $this->fixture->getIntroduction('!!!')
0 ignored issues
show
Unused Code introduced by
The call to CopyBasedIntroduction::getIntroduction() has too many arguments starting with '!!!'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
66
        );
67
    }
68
69
    public function testCopyIsReturnedWhenShorterThenIntroWordCount()
70
    {
71
        $this->fixture->setCopy(
72
            "Lorem ipsum Deserunt sit ullamco proident dolor qui ex cillum adipisicing sunt deserunt ullamco in magna exercitation mollit."
73
        );
74
75
        $this->assertEquals(
76
            "Lorem ipsum Deserunt sit ullamco proident dolor qui ex cillum adipisicing sunt deserunt ullamco in magna exercitation mollit.",
77
            $this->fixture->getIntroduction()
78
        );
79
    }
80
}
81