55require_once __DIR__ . '/../src/index.php ' ;
66require_once __DIR__ . '/utility.php ' ;
77use Contentstack \Test \REST ;
8+ use Contentstack \Contentstack ;
89
910use PHPUnit \Framework \TestCase ;
1011use Contentstack \Support \Utility ;
@@ -17,14 +18,17 @@ class AssetsTest extends TestCase {
1718 */
1819 public static function setUpBeforeClass () : void {
1920 self ::$ rest = new REST ();
20- self ::$ Stack = Contentstack \Contentstack::Stack (self ::$ rest ->getAPIKEY (), self ::$ rest ->getAccessToken (), self ::$ rest ->getEnvironmentName ());
21+ self ::$ Stack = Contentstack::Stack (self ::$ rest ->getAPIKEY (), self ::$ rest ->getAccessToken (), self ::$ rest ->getEnvironmentName ());
22+ if (self ::$ rest ->getHost () !== NULL ) {
23+ self ::$ Stack ->setHost (self ::$ rest ->getHost ());
24+ }
2125 }
2226 /*
2327 * Tear Down after the test suites executes
2428 */
2529 public static function tearDownAfterClass () : void {
2630 if (ENV !== 'TEST_LOCAL ' ) {
27- self ::$ rest ->deleteStack ();
31+ // self::$rest->deleteStack();
2832 }
2933 }
3034
@@ -36,9 +40,10 @@ public function testAssetsFind() {
3640
3741 public function testAssetsFetch () {
3842 $ _object = self ::$ Stack ->Assets ()->Query ()->toJSON ()->find ();
43+ $ _title = $ _object [0 ][0 ]['title ' ];
3944 $ _uid = $ _object [0 ][0 ]['uid ' ];
4045 $ _asset = self ::$ Stack ->Assets ($ _uid )->fetch ();
41- $ this ->assertEquals ($ _asset ->get ('title ' ), $ _object [ 0 ][ 0 ][ ' title ' ] );
46+ $ this ->assertEquals ($ _asset ->get ('title ' ), $ _title );
4247 }
4348
4449 public function testAssetsFindSkip () {
@@ -77,7 +82,6 @@ public function testAssetsFindLimit() {
7782 public function testAssetsAddParam () {
7883 $ _assets = self ::$ Stack ->Assets ()->Query ()->addParam ('include_dimension ' , 'true ' )->toJSON ()->find ();
7984 $ this ->assertTrue (array_key_exists ('dimension ' , $ _assets [0 ][0 ]));
80-
8185 }
8286
8387
@@ -161,7 +165,6 @@ public function testAssetsFindDescending() {
161165 public function testAssetsFindLessThan () {
162166 $ _set = 7575 ;
163167 $ assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->lessThan ('file_size ' , $ _set )->find ();
164- Utility::debug ($ assets );
165168 $ this ->assertArrayHasKey (0 , $ assets );
166169 if (count ($ assets [0 ]) !== 0 ){
167170 foreach ($ assets [0 ] as $ key => $ val ) {
@@ -173,7 +176,7 @@ public function testAssetsFindLessThan() {
173176 }
174177
175178 public function testAssetsFindLessThanEqualTo () {
176- $ _set = 12 ;
179+ $ _set = 12000 ;
177180 $ assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->lessThanEqualTo ('file_size ' , $ _set )->find ();
178181 $ this ->assertArrayHasKey (0 , $ assets );
179182 if (count ($ assets [0 ]) !== 0 ) {
@@ -268,9 +271,10 @@ public function testAssetsFindLogicalOrRawQuery() {
268271
269272 public function testAssetsFindLogicalAndQueryObject () {
270273 $ _value = 6161 ;
274+ $ _value2 = 15000 ;
271275 $ query1 = self ::$ Stack ->Assets ()->Query ()->greaterThanEqualTo ('file_size ' , $ _value );
272276
273- $ query2 = self ::$ Stack ->Assets ()->Query ()->lessThanEqualTo ('file_size ' , $ _value );
277+ $ query2 = self ::$ Stack ->Assets ()->Query ()->lessThanEqualTo ('file_size ' , $ _value2 );
274278 $ assets = self ::$ Stack ->Assets ()->Query ()->logicalAND ($ query1 , $ query2 )->toJSON ()->find ();
275279
276280 $ this ->assertArrayHasKey (0 , $ assets );
@@ -279,25 +283,26 @@ public function testAssetsFindLogicalAndQueryObject() {
279283
280284 public function testAssetsFindLogicalAndRawQuery () {
281285 $ _value = 6161 ;
286+ $ _value2 = 15000 ;
282287 $ query1 = self ::$ Stack ->Assets ()->Query ()->greaterThanEqualTo ('file_size ' , $ _value );
283- $ query2 = self ::$ Stack ->Assets ()->Query ()->lessThanEqualTo ('file_size ' , $ _value );
288+ $ query2 = self ::$ Stack ->Assets ()->Query ()->lessThanEqualTo ('file_size ' , $ _value2 );
284289 $ assets = self ::$ Stack ->Assets ()->Query ()->logicalAND ($ query1 , $ query2 )->toJSON ()->find ();
285290 $ this ->assertArrayHasKey (0 , $ assets );
286291 $ this ->assertTrue (checkAssetsSorting ($ assets [0 ]));
287292 }
288293
289- // public function testAssetsFindOnlyDefault() {
290- // $_assets = self::$Stack->Assets()->Query()->only(array('title', 'updated_at'))->toJSON()->find();
291- // $_assets_count = self::$Stack->Assets()->Query()->toJSON()->find();
292- // $this->assertArrayHasKey(0, $_assets);
293- // $this->assertTrue((count($_assets[0]) === count($_assets_count[0])));
294- // $this->assertTrue(checkAssetsSorting($_assets[0]));
295- // $flag = true;
296- // for($i = 0; $i < count($_assets[0]); $i++) {
297- // $flag = $flag && (count(array_keys($_assets[0][$i])) === 4 && isset($_assets[0][$i]['updated_at']) && isset($_assets[0][$i]['title']) && isset($_assets[0][$i]['uid']));
298- // }
299- // $this->assertTrue($flag);
300- // }
294+ public function testAssetsFindOnlyDefault () {
295+ $ _assets = self ::$ Stack ->Assets ()->Query ()->only (' BASE ' , array ('title ' , 'updated_at ' ))->toJSON ()->find ();
296+ $ _assets_count = self ::$ Stack ->Assets ()->Query ()->toJSON ()->find ();
297+ $ this ->assertArrayHasKey (0 , $ _assets );
298+ $ this ->assertTrue ((count ($ _assets [0 ]) === count ($ _assets_count [0 ])));
299+ $ this ->assertTrue (checkAssetsSorting ($ _assets [0 ]));
300+ $ flag = true ;
301+ for ($ i = 0 ; $ i < count ($ _assets [0 ]); $ i ++) {
302+ $ flag = $ flag && (count (array_keys ($ _assets [0 ][$ i ])) === 6 && isset ($ _assets [0 ][$ i ]['updated_at ' ]) && isset ( $ _assets [ 0 ][ $ i ][ ' filename ' ]) && isset ( $ _assets [ 0 ][ $ i ][ ' ACL ' ]) && isset ($ _assets [0 ][$ i ]['title ' ]) && isset ($ _assets [0 ][$ i ]['uid ' ]));
303+ }
304+ $ this ->assertTrue ($ flag );
305+ }
301306
302307 public function testAssetsFindRegEx () {
303308 $ regexp = "[0-9] " ;
@@ -348,20 +353,19 @@ public function testAssetsFindExceptBaseDefault() {
348353 $ this ->assertTrue ($ flag );
349354 }
350355
351-
352- // public function testAssetsFindOnlyBaseDefault() {
353- // $_assets = self::$Stack->Assets()->Query()->only('BASE', array('title', 'updated_at'))->toJSON()->find();
354- // $this->assertArrayHasKey(0, $_assets);
355- // $assets = self::$Stack->Assets()->Query()->toJSON()->find();
356- // $assets_count = count($assets[0]);
357- // $this->assertTrue((count($_assets[0]) === $assets_count));
358- // $this->assertTrue(checkAssetsSorting($_assets[0]));
359- // $flag = true;
360- // for($i = 0; $i < count($_assets[0]); $i++) {
361- // $flag = $flag && (count(array_keys($_assets[0][$i])) === 4 && isset($_assets[0][$i]['url']) && isset($_assets[0][$i]['updated_at']) && isset($_assets[0][$i]['title']) && isset($_assets[0][$i]['uid']));
362- // }
363- // $this->assertTrue($flag);
364- // }
356+ public function testAssetsFindOnlyBaseDefault () {
357+ $ _assets = self ::$ Stack ->Assets ()->Query ()->only ('BASE ' , array ('title ' , 'updated_at ' ))->toJSON ()->find ();
358+ $ this ->assertArrayHasKey (0 , $ _assets );
359+ $ assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->find ();
360+ $ assets_count = count ($ assets [0 ]);
361+ $ this ->assertTrue ((count ($ _assets [0 ]) === $ assets_count ));
362+ $ this ->assertTrue (checkAssetsSorting ($ _assets [0 ]));
363+ $ flag = true ;
364+ for ($ i = 0 ; $ i < count ($ _assets [0 ]); $ i ++) {
365+ $ flag = $ flag && (count (array_keys ($ _assets [0 ][$ i ])) === 6 && isset ($ _assets [0 ][$ i ]['updated_at ' ]) && isset ($ _assets [0 ][$ i ]['filename ' ]) && isset ($ _assets [0 ][$ i ]['ACL ' ]) && isset ($ _assets [0 ][$ i ]['title ' ]) && isset ($ _assets [0 ][$ i ]['uid ' ]));
366+ }
367+ $ this ->assertTrue ($ flag );
368+ }
365369
366370 public function testAssetsFindExceptDefault () {
367371 $ _assets = self ::$ Stack ->Assets ()->Query ()->except ('BASE ' ,array ('boolean ' ))->toJSON ()->find ();
@@ -380,9 +384,9 @@ public function testAssetsFindExceptDefault() {
380384 public function testAssetsFindSearch () {
381385 $ _assets = self ::$ Stack ->Assets ()->Query ()->search ('image/jpeg ' )->toJSON ()->find ();
382386 $ this ->assertArrayHasKey (0 , $ _assets );
383- $ assets = self ::$ Stack ->Assets ()->Query ()->toJSON ()->find ();
384- $ assets_count = count ($ assets [0 ]);
385- $ this ->assertTrue ((count ($ _assets [0 ]) === $ assets_count ));
387+ // $assets = self::$Stack->Assets()->Query()->toJSON()->find();
388+ // $assets_count = count($assets[0]);
389+ $ this ->assertTrue ((count ($ _assets [0 ]) === 2 ));
386390 $ this ->assertTrue (checkAssetsSorting ($ _assets [0 ]));
387391 $ flag = true ;
388392 for ($ i = 0 ; $ i < count ($ _assets [0 ]); $ i ++) {
0 commit comments