22require_once __DIR__ . '/REST.php ' ;
33require_once __DIR__ . '/constants.php ' ;
44require_once __DIR__ . '/utility.php ' ;
5+
56require_once __DIR__ . '/../lib/index.php ' ;
67
78use Contentstack \Test \REST ;
89
910use PHPUnit \Framework \TestCase ;
10-
1111class ContentStackTestCases extends TestCase {
1212 public static $ rest ;
1313 public static $ Stack ;
@@ -34,9 +34,25 @@ public function testFind() {
3434 $ this ->assertTrue (checkEntriesSorting ($ _entries [0 ]));
3535 }
3636
37+ public function testAssetsFind () {
38+ $ _assets = self ::$ Stack ->Assets ()->QueryAssets ()->toJSON ()->find ();
39+ $ this ->assertArrayHasKey (0 , $ _assets );
40+ // $this->assertTrue((count($_assets[0]) === ENTRY_COUNT));
41+ $ this ->assertTrue (checkAssetsSorting ($ _assets [0 ]));
42+ }
43+
44+
45+ public function testAssetFetch () {
46+ $ _object = self ::$ Stack ->Assets ()->QueryAssets ()->toJSON ()->find ();
47+ $ _uid = $ _object [0 ][0 ]['uid ' ];
48+ $ _asset = self ::$ Stack ->Asset ($ _uid )->fetch ();
49+ //\Contentstack\Utility\debug($_asset);
50+ $ this ->assertEquals ($ _asset ->getTitle (), $ _object [0 ][0 ]['title ' ]);
51+ }
52+
3753 public function testFindOne () {
3854 $ _entry = self ::$ Stack ->ContentType (CT_ContentType)->Query ()->toJSON ()->findOne ();
39- // $this->assertObjectHasAttribute('object', $_entry);
55+ // $this->assertObjectHasAttribute('object', $_entry);
4056 $ this ->assertEquals ($ _entry ['title ' ], getResultEntries (CT_ContentType, ENTRY_COUNT - 1 )['title ' ]);
4157 }
4258
@@ -249,7 +265,7 @@ public function testFindNotExists() {
249265
250266 public function testFindAscending () {
251267 $ field = 'created_at ' ;
252- $ entries = self ::$ Stack ->ContentType (CT_ContentType)->Query ()->toJSON ()->ascending (' created_at ' )->find ();
268+ $ entries = self ::$ Stack ->ContentType (CT_ContentType)->Query ()->toJSON ()->ascending ($ field )->find ();
253269 $ this ->assertArrayHasKey (0 , $ entries );
254270 $ this ->assertTrue ((count ($ entries [0 ]) === ENTRY_COUNT ));
255271 $ this ->assertTrue (checkEntriesSorting ($ entries [0 ], $ field , 'asc ' ));
0 commit comments