|
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\AddAction; |
|
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
|
|
|
class ActionTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
use ConfigTrait; |
|
23
|
|
|
use FixturesTrait; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var AddAction |
|
27
|
|
|
*/ |
|
28
|
|
|
public $Action; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* setUp method |
|
32
|
|
|
* |
|
33
|
|
|
* @return void |
|
34
|
|
|
*/ |
|
35
|
|
|
public function setUp() |
|
36
|
|
|
{ |
|
37
|
|
|
parent::setUp(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* tearDown method |
|
42
|
|
|
* |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function tearDown() |
|
46
|
|
|
{ |
|
47
|
|
|
ServiceRegistry::clear(); |
|
|
|
|
|
|
48
|
|
|
unset($this->Service, $this->Action, $this->request); |
|
49
|
|
|
parent::tearDown(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Test action calling. |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testActionCallOnProcess() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->_initializeRequest([ |
|
60
|
|
|
'params' => [ |
|
61
|
|
|
'service' => 'articles', |
|
62
|
|
|
'pass' => [ |
|
63
|
|
|
'tag', |
|
64
|
|
|
'1' |
|
65
|
|
|
], |
|
66
|
|
|
], |
|
67
|
|
|
'post' => [ |
|
68
|
|
|
'tag_id' => 1 |
|
69
|
|
|
], |
|
70
|
|
|
], 'PUT'); |
|
71
|
|
|
$service = $this->request->getParam('service'); |
|
|
|
|
|
|
72
|
|
|
$options = [ |
|
73
|
|
|
'version' => null, |
|
74
|
|
|
'service' => $service, |
|
75
|
|
|
'request' => $this->request, |
|
76
|
|
|
'response' => $this->response, |
|
|
|
|
|
|
77
|
|
|
'baseUrl' => '/articles/tag/1' |
|
78
|
|
|
]; |
|
79
|
|
|
$Service = ServiceRegistry::get($service, $options); |
|
|
|
|
|
|
80
|
|
|
$action = $Service->buildAction(); |
|
81
|
|
|
$result = $action->process(); |
|
82
|
|
|
$this->assertEquals(true, $result); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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.