Skip to content

Commit 1711699

Browse files
Supporting New query of multi-ct reference in reference field
1 parent eea178e commit 1711699

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ composer.json
66
vendor/
77
test/report.html
88
test/AssetsTestReport.html
9+
test/Assetsreport.html
910
test/EntryTestReport.html
10-
test/ImagetransformTestReport.html
11+
test/Entryreport.html
12+
test/Entriesreport.html
13+
test/ImageTransformreport.html
1114
test/result.json

src/lib/models/base_query.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ public function includeSchema() {
186186
return $this->queryObject;
187187
}
188188

189+
/*
190+
* IncludeReferenceContentTypeUID
191+
* @deprecated since verion 1.1.0
192+
* @Alternate includeContentType
193+
* This method includes the content type UIDs of the referenced entries returned in the response.
194+
* @param
195+
* @return Query
196+
* */
197+
public function includeReferenceContentTypeUID() {
198+
$this->queryObject->_query = call_user_func('contentstackAddBoolean', 'include_reference_content_type_uid', $this->queryObject->_query);
199+
return $this->queryObject;
200+
}
201+
189202
/*
190203
* includeContentType
191204
* To include content_type along with entries

src/lib/utility.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,7 @@ function wrapResult($result = '', $queryObject = '') {
258258

259259
function contentstackRequest($queryObject = '', $type = ''){
260260
$server_output = '';
261-
// \Contentstack\Utility\debug(($queryObject));
262-
// \Contentstack\Utility\debug(($type));
263-
261+
264262
if($queryObject) {
265263
$http = curl_init(contentstackUrl($queryObject, $type));
266264

test/AssetsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public static function tearDownAfterClass() {
3131

3232
public function testAssetsFind() {
3333
$_assets = self::$Stack->Assets()->Query()->toJSON()->find();
34-
3534
$this->assertArrayHasKey(0, $_assets);
3635
$this->assertTrue(checkAssetsSorting($_assets[0]));
3736
}
@@ -161,8 +160,9 @@ public function testAssetsFindDescending() {
161160
}
162161

163162
public function testAssetsFindLessThan() {
164-
$_set = 9684;
163+
$_set = 7575;
165164
$assets = self::$Stack->Assets()->Query()->toJSON()->lessThan('file_size', $_set)->find();
165+
\Contentstack\Utility\debug($assets);
166166
$this->assertArrayHasKey(0, $assets);
167167
if(count($assets[0]) !== 0){
168168
foreach ($assets[0] as $key => $val) {
@@ -174,7 +174,7 @@ public function testAssetsFindLessThan() {
174174
}
175175

176176
public function testAssetsFindLessThanEqualTo() {
177-
$_set = 9684;
177+
$_set = 12;
178178
$assets = self::$Stack->Assets()->Query()->toJSON()->lessThanEqualTo('file_size', $_set)->find();
179179
$this->assertArrayHasKey(0, $assets);
180180
if(count($assets[0]) !== 0) {
@@ -187,7 +187,7 @@ public function testAssetsFindLessThanEqualTo() {
187187
}
188188

189189
public function testAssetsFindGreaterThan() {
190-
$_set = 7575;
190+
$_set = 12;
191191
$assets = self::$Stack->Assets()->Query()->toJSON()->greaterThan('file_size', $_set)->find();
192192
$this->assertArrayHasKey(0, $assets);
193193
if(count($assets[0]) !== 0) {

test/EntriesTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ public function testFindIncludeContentType() {
129129
$this->assertTrue($_entries[1]['uid'] === CT_ContentType);
130130
}
131131

132+
public function testFindIncludeReferenceContentTypeUID() {
133+
$_entries = self::$Stack->ContentType(CT_ContentType)->Query()->toJSON()->includeReferenceContentTypeUID()->find();
134+
$_flag = "false";
135+
$this->assertArrayHasKey(0, $_entries);
136+
if($_entries[0][1]["reference"][0]['_content_type_uid']) {
137+
$_flag = "true";
138+
}
139+
$this->assertTrue($_flag === "true");
140+
}
141+
142+
132143
public function testFindIncludeContentTypeIncludeCount() {
133144
$_entries = self::$Stack->ContentType(CT_ContentType)->Query()->toJSON()->includeCount()->includeContentType()->find();
134145
$this->assertArrayHasKey(0, $_entries);

0 commit comments

Comments
 (0)