|
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; |
|
13
|
|
|
|
|
14
|
|
|
use CakeDC\Api\Service\ListingService; |
|
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 ListingServiceTest |
|
22
|
|
|
* |
|
23
|
|
|
* @package CakeDC\Api\Test\TestCase\Service |
|
24
|
|
|
*/ |
|
25
|
|
|
class ListingServiceTest extends TestCase |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
use ConfigTrait; |
|
29
|
|
|
use FixturesTrait; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* setUp method |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
public function setUp() |
|
37
|
|
|
{ |
|
38
|
|
|
parent::setUp(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* tearDown method |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function tearDown() |
|
47
|
|
|
{ |
|
48
|
|
|
ServiceRegistry::clear(); |
|
|
|
|
|
|
49
|
|
|
parent::tearDown(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Test load value method |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testActionProcess() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->_initializeRequest([ |
|
60
|
|
|
'params' => [ |
|
61
|
|
|
'service' => 'listing', |
|
62
|
|
|
] |
|
63
|
|
|
]); |
|
64
|
|
|
$service = $this->request->getParam('service'); |
|
|
|
|
|
|
65
|
|
|
$options = [ |
|
66
|
|
|
'version' => null, |
|
67
|
|
|
'service' => $service, |
|
68
|
|
|
'request' => $this->request, |
|
69
|
|
|
'response' => $this->response, |
|
|
|
|
|
|
70
|
|
|
'baseUrl' => '/listing' |
|
71
|
|
|
]; |
|
72
|
|
|
$Service = ServiceRegistry::get($service, $options); |
|
|
|
|
|
|
73
|
|
|
$this->assertTrue($Service instanceof ListingService); |
|
74
|
|
|
$this->assertEquals('listing', $Service->getName()); |
|
75
|
|
|
|
|
76
|
|
|
$action = $Service->buildAction(); |
|
77
|
|
|
$result = $action->process(); |
|
78
|
|
|
$expected = [ |
|
79
|
|
|
'articles', |
|
80
|
|
|
'articles_tags', |
|
81
|
|
|
'authors', |
|
82
|
|
|
'tags', |
|
83
|
|
|
]; |
|
84
|
|
|
sort($expected); |
|
85
|
|
|
sort($result); |
|
86
|
|
|
$this->assertEquals($expected, $result); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
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.