File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed
Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 22## CHANGELOG
33------------------------------------------------
44
5+ ## Version 1.7.0
6+ ###### Date:
7+ ### New Feature
8+ - Entry
9+ - Added support for function 'includeFallback'
10+ - Query
11+ - Added support for function 'includeFallback'
12+
13+ ------------------------------------------------
14+
515## Version 1.6.1
616###### Date: 08-May-2020
717### Bug
Original file line number Diff line number Diff line change @@ -292,6 +292,21 @@ public function exists($field_uid = '')
292292 return $ this ->queryObject ;
293293 }
294294
295+ /**
296+ * To include fallback content if specified locale content is not publish.
297+ *
298+ * @return Query
299+ */
300+ public function includeFallback ()
301+ {
302+ $ this ->queryObject ->_query = call_user_func (
303+ 'contentstackAddBoolean ' ,
304+ 'include_fallback ' ,
305+ $ this ->queryObject ->_query
306+ );
307+
308+ return $ this ->queryObject ;
309+ }
295310 /**
296311 * To include schema along with entries
297312 *
Original file line number Diff line number Diff line change @@ -93,6 +93,24 @@ public function testAssetsFindCount() {
9393 $ this ->assertTrue (($ _assets [0 ]) === $ assets_count );
9494 }
9595
96+ public function testIncludeFallback () {
97+ $ testArray = array ("a " =>"en-us " , "b " => "hi-in " );
98+ $ _assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->language ("hi-in " )->includeFallback ()->find ();
99+ $ this ->assertEquals (count ($ _assets [0 ]), 3 );
100+ for ($ i = 0 ; $ i < count ($ _assets [0 ]); $ i ++) {
101+ $ this ->assertContains ($ _assets [0 ][$ i ]["publish_details " ]["locale " ], $ testArray );
102+ }
103+ }
104+
105+ public function testWithoutIncludeFallback () {
106+ $ _assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->language ("hi-in " )->find ();
107+ $ this ->assertArrayHasKey (0 , $ _assets );
108+ $ this ->assertEquals (count ($ _assets [0 ]), 1 );
109+ for ($ i = 0 ; $ i < count ($ _assets [0 ]); $ i ++) {
110+ $ this ->assertEquals ($ _assets [0 ][$ i ]["publish_details " ]["locale " ], "hi-in " );
111+ }
112+ }
113+
96114 public function testAssetsFindIncludeCount () {
97115 $ _assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->includeCount ()->find ();
98116 $ assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->find ();
Original file line number Diff line number Diff line change @@ -112,6 +112,25 @@ public function testFindIncludeCount() {
112112 $ this ->assertTrue (($ _entries [1 ] === ENTRY_COUNT ));
113113 }
114114
115+ public function testIncludeFallback () {
116+ $ testArray = array ("a " =>"en-us " , "b " => "hi-in " );
117+ $ _entries = self ::$ Stack ->ContentType (CT_ContentType)->Query ()->toJSON ()->language ("hi-in " )->includeFallback ()->find ();
118+ $ this ->assertArrayHasKey (0 , $ _entries );
119+ $ this ->assertEquals (count ($ _entries [0 ]), ENTRY_COUNT );
120+ for ($ i = 0 ; $ i < count ($ _entries [0 ]); $ i ++) {
121+ $ this ->assertContains ($ _entries [0 ][$ i ]["publish_details " ]["locale " ], $ testArray );
122+ }
123+ }
124+
125+ public function testWithoutIncludeFallback () {
126+ $ _entries = self ::$ Stack ->ContentType (CT_ContentType)->Query ()->toJSON ()->language ("hi-in " )->find ();
127+ $ this ->assertArrayHasKey (0 , $ _entries );
128+ $ this ->assertEquals (count ($ _entries [0 ]), 1 );
129+ for ($ i = 0 ; $ i < count ($ _entries [0 ]); $ i ++) {
130+ $ this ->assertEquals ($ _entries [0 ][$ i ]["publish_details " ]["locale " ], "hi-in " );
131+ }
132+ }
133+
115134 public function testFindIncludeSchema () {
116135 $ _entries = self ::$ Stack ->ContentType (CT_ContentType)->Query ()->toJSON ()->includeSchema ()->find ();
117136 $ this ->assertArrayHasKey (0 , $ _entries );
You can’t perform that action at this time.
0 commit comments