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\Service; |
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
|
|
|
use Cake\Http\Response; |
20
|
|
|
use Cake\Http\ServerRequest; |
21
|
|
|
|
22
|
|
|
class ServiceRegistryTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
use ConfigTrait; |
26
|
|
|
use FixturesTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* setUp method |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function setUp() |
34
|
|
|
{ |
35
|
|
|
parent::setUp(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* tearDown method |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function tearDown() |
44
|
|
|
{ |
45
|
|
|
ServiceRegistry::clear(); |
|
|
|
|
46
|
|
|
parent::tearDown(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Test load value method |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function testLoad() |
55
|
|
|
{ |
56
|
|
|
$this->_initializeRequest([ |
57
|
|
|
'params' => [ |
58
|
|
|
'service' => 'authors', |
59
|
|
|
] |
60
|
|
|
]); |
61
|
|
|
$service = $this->request->getParam('service'); |
|
|
|
|
62
|
|
|
$options = [ |
63
|
|
|
'version' => null, |
64
|
|
|
'service' => $service, |
65
|
|
|
'request' => $this->request, |
66
|
|
|
'response' => $this->response, |
|
|
|
|
67
|
|
|
'baseUrl' => '/authors' |
68
|
|
|
]; |
69
|
|
|
$Service = ServiceRegistry::get($service, $options); |
|
|
|
|
70
|
|
|
$this->assertTrue($Service instanceof Service); |
71
|
|
|
$this->assertEquals('authors', $Service->getName()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Test load value method |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function testLoadNested() |
80
|
|
|
{ |
81
|
|
|
$this->_initializeRequest([ |
82
|
|
|
'params' => [ |
83
|
|
|
'service' => 'authors', |
84
|
|
|
'pass' => [ |
85
|
|
|
'1', |
86
|
|
|
'articles' |
87
|
|
|
] |
88
|
|
|
] |
89
|
|
|
]); |
90
|
|
|
$service = 'authors'; |
91
|
|
|
$options = [ |
92
|
|
|
'version' => null, |
93
|
|
|
'service' => $service, |
94
|
|
|
'request' => $this->request, |
95
|
|
|
'response' => $this->response, |
96
|
|
|
'baseUrl' => '/authors/1/articles', |
97
|
|
|
]; |
98
|
|
|
$Service = ServiceRegistry::get($service, $options); |
|
|
|
|
99
|
|
|
$this->assertTrue($Service instanceof Service); |
100
|
|
|
$this->assertTextEquals('/authors/1/articles', $Service->getBaseUrl()); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
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.