ListActionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 71
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 20 1
A tearDown() 0 5 1
A testExecuteSuccess() 0 17 1
1
<?php
2
/**
3
 * Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
4
 *
5
 * Licensed under The MIT License
6
 * Redistributions of files must retain the above copyright notice.
7
 *
8
 * @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
9
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
10
 */
11
12
namespace CakeDC\Api\Test\TestCase\Service\Action;
13
14
use CakeDC\Api\Service\Action\ListAction;
15
use CakeDC\Api\Service\ServiceRegistry;
16
use CakeDC\Api\TestSuite\TestCase;
17
use CakeDC\Api\Test\ConfigTrait;
18
use CakeDC\Api\Test\FixturesTrait;
19
20
/**
21
 * Class ListActionTest
22
 *
23
 * @package CakeDC\Api\Test\TestCase\Service\Action
24
 */
25
class ListActionTest extends TestCase
26
{
27
28
    use ConfigTrait;
29
    use FixturesTrait;
30
31
    /**
32
     * @var ListAction
33
     */
34
    public $Action;
35
36
    /**
37
     * setUp method
38
     *
39
     * @return void
40
     */
41
    public function setUp()
42
    {
43
        parent::setUp();
44
45
        $this->_initializeRequest([
46
            'params' => [
47
                'service' => 'listing',
48
                'pass' => []
49
            ]
50
        ]);
51
        $service = $this->request->getParam('service');
0 ignored issues
show
Bug introduced by
The property request does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
52
        $options = [
53
            'version' => null,
54
            'service' => $service,
55
            'request' => $this->request,
56
            'response' => $this->response,
0 ignored issues
show
Bug introduced by
The property response does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
57
            'baseUrl' => '/listing'
58
        ];
59
        $this->Service = ServiceRegistry::get($service, $options);
0 ignored issues
show
Bug introduced by
The property Service does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Deprecated Code introduced by
The method CakeDC\Api\Service\ServiceRegistry::get() has been deprecated with message: 3.6.0 Use \CakeDC\Api\Service\Locator\ServiceLocator::get() instead.

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

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

Loading history...
60
    }
61
62
    /**
63
     * tearDown method
64
     *
65
     * @return void
66
     */
67
    public function tearDown()
68
    {
69
        unset($this->Action);
70
        parent::tearDown();
71
    }
72
73
    /**
74
     * Test load value method
75
     *
76
     * @return void
77
     */
78
    public function testExecuteSuccess()
79
    {
80
        $this->Action = new ListAction([
81
            'service' => $this->Service,
82
        ]);
83
84
        $result = $this->Action->execute();
85
        $expected = [
86
            'articles',
87
            'articles_tags',
88
            'authors',
89
            'tags',
90
        ];
91
        sort($expected);
92
        sort($result);
93
        $this->assertEquals($expected, $result);
94
    }
95
}
96