test__ranked_as_given_priority_parameter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
c 0
b 0
f 0
rs 9.6666
cc 1
nc 1
nop 0
1
<?php
2
3
namespace LightSaml\Tests\Builder\Action;
4
5
use LightSaml\Action\ActionInterface;
6
use LightSaml\Action\CompositeAction;
7
use LightSaml\Builder\Action\CompositeActionBuilder;
8
use LightSaml\Context\ContextInterface;
9
use LightSaml\Tests\BaseTestCase;
10
use LightSaml\Tests\Mock\Action\FooAction;
11
12
class CompositeActionBuilderTest extends BaseTestCase
13
{
14
    public function test__throws_on_priority_true()
15
    {
16
        $this->expectException(\InvalidArgumentException::class);
17
        $compositeBuilder = new CompositeActionBuilder();
18
        $compositeBuilder->add(new FooAction(), true);
19
    }
20
21
    public function test__throws_on_priority_string()
22
    {
23
        $this->expectException(\InvalidArgumentException::class);
24
        $compositeBuilder = new CompositeActionBuilder();
25
        $compositeBuilder->add(new FooAction(), "asc");
26
    }
27
28 View Code Duplication
    public function test__ranked_as_added_with_out_priority_parameter()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $order = 1;
31
        $action1 = $this->getActionMock(1, $order);
32
        $action2 = $this->getActionMock(2, $order);
33
        $action3 = $this->getActionMock(3, $order);
34
35
        $compositeBuilder = new CompositeActionBuilder();
36
        $compositeBuilder->add($action1);
0 ignored issues
show
Documentation introduced by
$action1 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Action\ActionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37
        $compositeBuilder->add($action2);
0 ignored issues
show
Documentation introduced by
$action2 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Action\ActionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
        $compositeBuilder->add($action3);
0 ignored issues
show
Documentation introduced by
$action3 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Action\ActionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
40
        $compositeAction = $compositeBuilder->build();
41
42
        $this->assertInstanceOf(CompositeAction::class, $compositeAction);
43
44
        $compositeAction->execute($this->getMockBuilder(ContextInterface::class)->getMock());
0 ignored issues
show
Documentation introduced by
$this->getMockBuilder(\L...face::class)->getMock() is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Context\ContextInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
    }
46
47 View Code Duplication
    public function test__ranked_as_given_priority_parameter()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $order = 1;
50
        $action1 = $this->getActionMock(3, $order);
51
        $action2 = $this->getActionMock(1, $order);
52
        $action3 = $this->getActionMock(2, $order);
53
54
        $compositeBuilder = new CompositeActionBuilder();
55
        $compositeBuilder->add($action1, 10);
0 ignored issues
show
Documentation introduced by
$action1 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Action\ActionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
        $compositeBuilder->add($action2, 2);
0 ignored issues
show
Documentation introduced by
$action2 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Action\ActionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
57
        $compositeBuilder->add($action3, 7);
0 ignored issues
show
Documentation introduced by
$action3 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Action\ActionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
58
59
        $compositeAction = $compositeBuilder->build();
60
61
        $this->assertInstanceOf(CompositeAction::class, $compositeAction);
62
63
        $compositeAction->execute($this->getMockBuilder(ContextInterface::class)->getMock());
0 ignored issues
show
Documentation introduced by
$this->getMockBuilder(\L...face::class)->getMock() is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<LightSaml\Context\ContextInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
    }
65
66
    /**
67
     * @param int $expectedOrder
68
     * @param int $order
69
     *
70
     * @return \PHPUnit_Framework_MockObject_MockObject|ActionInterface
71
     */
72
    private function getActionMock($expectedOrder, &$order)
73
    {
74
        $action = $this->getMockBuilder(ActionInterface::class)->getMock();
75
        $action->expects($this->once())
76
            ->method('execute')
77
            ->willReturnCallback(function () use ($expectedOrder, &$order) {
78
                $this->assertEquals($expectedOrder, $order);
79
                $order++;
80
            })
81
        ;
82
83
        return $action;
84
    }
85
}
86