|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the Functional\ViewTest class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Bundle\EzPublishRestBundle\Tests\Functional; |
|
10
|
|
|
|
|
11
|
|
|
class ViewTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Covers POST /views. |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testViewRequestWithOrStatement() |
|
17
|
|
|
{ |
|
18
|
|
|
$fooRemoteId = md5('View test content foo'); |
|
19
|
|
|
$barRemoteId = md5('View test content bar'); |
|
20
|
|
|
$this->createFolder('View test content foo', '/api/ezp/v2/content/locations/1/2', $fooRemoteId); |
|
21
|
|
|
$this->createFolder('View test content bar', '/api/ezp/v2/content/locations/1/2', $barRemoteId); |
|
22
|
|
|
|
|
23
|
|
|
$body = <<< XML |
|
24
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
25
|
|
|
<ViewInput> |
|
26
|
|
|
<identifier>TitleView</identifier> |
|
27
|
|
|
<Query> |
|
28
|
|
|
<Filter> |
|
29
|
|
|
<OR> |
|
30
|
|
|
<ContentRemoteIdCriterion>{$fooRemoteId}</ContentRemoteIdCriterion> |
|
31
|
|
|
<ContentRemoteIdCriterion>{$barRemoteId}</ContentRemoteIdCriterion> |
|
32
|
|
|
</OR> |
|
33
|
|
|
</Filter> |
|
34
|
|
|
<limit>10</limit> |
|
35
|
|
|
<offset>0</offset> |
|
36
|
|
|
</Query> |
|
37
|
|
|
</ViewInput> |
|
38
|
|
|
XML; |
|
39
|
|
|
$request = $this->createHttpRequest( |
|
40
|
|
|
'POST', |
|
41
|
|
|
'/api/ezp/v2/views', |
|
42
|
|
|
'ViewInput+xml', |
|
43
|
|
|
'View+json', |
|
44
|
|
|
$body |
|
45
|
|
|
); |
|
46
|
|
|
$response = $this->sendHttpRequest($request); |
|
47
|
|
|
$responseData = json_decode($response->getBody(), true); |
|
48
|
|
|
|
|
49
|
|
|
self::assertEquals(2, $responseData['View']['Result']['count']); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Covers POST /views. |
|
54
|
|
|
* |
|
55
|
|
|
* @depends testViewRequestWithOrStatement |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testViewRequestWithAndStatement() |
|
58
|
|
|
{ |
|
59
|
|
|
$fooRemoteId = md5('View test content foo'); |
|
60
|
|
|
$barRemoteId = md5('View test content bar'); |
|
61
|
|
|
|
|
62
|
|
|
$body = <<< XML |
|
63
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
64
|
|
|
<ViewInput> |
|
65
|
|
|
<identifier>TitleView</identifier> |
|
66
|
|
|
<Query> |
|
67
|
|
|
<Filter> |
|
68
|
|
|
<AND> |
|
69
|
|
|
<OR> |
|
70
|
|
|
<ContentRemoteIdCriterion>{$fooRemoteId}</ContentRemoteIdCriterion> |
|
71
|
|
|
<ContentRemoteIdCriterion>{$barRemoteId}</ContentRemoteIdCriterion> |
|
72
|
|
|
</OR> |
|
73
|
|
|
<ContentRemoteIdCriterion>{$fooRemoteId}</ContentRemoteIdCriterion> |
|
74
|
|
|
</AND> |
|
75
|
|
|
</Filter> |
|
76
|
|
|
<limit>10</limit> |
|
77
|
|
|
<offset>0</offset> |
|
78
|
|
|
</Query> |
|
79
|
|
|
</ViewInput> |
|
80
|
|
|
XML; |
|
81
|
|
|
$request = $this->createHttpRequest( |
|
82
|
|
|
'POST', |
|
83
|
|
|
'/api/ezp/v2/views', |
|
84
|
|
|
'ViewInput+xml', |
|
85
|
|
|
'View+json', |
|
86
|
|
|
$body |
|
87
|
|
|
); |
|
88
|
|
|
$response = $this->sendHttpRequest($request); |
|
89
|
|
|
$responseData = json_decode($response->getBody(), true); |
|
90
|
|
|
|
|
91
|
|
|
self::assertEquals(1, $responseData['View']['Result']['count']); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|