Skip to content

Commit f5d6084

Browse files
committed
Fix bug + Fix other failing tests
1 parent f31158e commit f5d6084

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/actions/ListAction.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected function makeDataProvider()
148148
$query->andWhere($filter);
149149
}
150150

151-
$dataProvider = Yii::createObject($this->dataProvider);
151+
$dataProvider = Yii::createObject($this->dataProvider, ['query' => $query]);
152152
if (!$dataProvider instanceof JsonApiActiveDataProvider && !$dataProvider instanceof CursorActiveDataProvider) {
153153
throw new InvalidConfigException('Invalid dataProvider configuration');
154154
}

tests/codeception/suites/api/ApiCategoryCest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function testListActionWithSort(ApiTester $I)
151151
]
152152
]);
153153
$selfLink = $I->grabDataFromResponseByJsonPath('$.links.self');
154-
$I->assertContains('sort=-name', $selfLink[0]);
154+
$I->assertStringContainsString('sort=-name', $selfLink[0]);
155155
}
156156

157157
public function testCreateInvalidFormat1(ApiTester $I)

tests/codeception/suites/api/ApiDefaultCest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public function testActionWithInternalError(ApiTester $I)
100100
$I->seeResponseCodeIsServerError();
101101
$I->seeResponseIsJsonApiError();
102102
$I->seeResponseHasMeta();
103-
$I->seeResponseContainsJson(['title' => 'PHP Warning', 'detail' => 'json_decode() expects parameter 1 to be string, array given']);
104-
$I->seeResponseContainsJson(['meta' => ['error_type' => "yii\\base\\ErrorException"]]);
103+
// $I->seeResponseContainsJson(['title' => 'PHP Warning', 'detail' => 'json_decode() expects parameter 1 to be string, array given']);
104+
// $I->seeResponseContainsJson(['meta' => ['error_type' => "yii\\base\\ErrorException"]]);
105+
$I->seeResponseContainsJson(['meta' => ['error_type' => "TypeError"]]);
105106
}
106-
}
107+
}

tests/codeception/suites/api/ApiPostCest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public function testCountPostsAction(ApiTester $I)
88
$I->amBearerAuthenticated('Delta_secret_token');
99
$I->sendHEAD('/post/count');
1010
$I->seeResponseCodeIs(204);
11-
$I->seeHttpHeader('X-Pagination-Total-Count', 54);
11+
$I->seeHttpHeader('X-Pagination-Total-Count', '54');
1212

1313
$I->sendHEAD('/post/count', ['filter'=>['category_id'=>['neq'=>3]]]);
1414
$I->seeResponseCodeIs(204);
15-
$I->seeHttpHeader('X-Pagination-Total-Count', 36);
15+
$I->seeHttpHeader('X-Pagination-Total-Count', '36');
1616
}
1717

1818
public function testCountPostsForCategoryAction(ApiTester $I)
@@ -21,10 +21,10 @@ public function testCountPostsForCategoryAction(ApiTester $I)
2121
$I->amBearerAuthenticated('Delta_secret_token');
2222
$I->sendHEAD('/categories/1/posts-count');
2323
$I->seeResponseCodeIs(204);
24-
$I->seeHttpHeader('X-Pagination-Total-Count', 18);
24+
$I->seeHttpHeader('X-Pagination-Total-Count', '18');
2525
$I->sendHEAD('/categories/2/posts-count');
2626
$I->seeResponseCodeIs(204);
27-
$I->seeHttpHeader('X-Pagination-Total-Count', 0);
27+
$I->seeHttpHeader('X-Pagination-Total-Count', '0');
2828
}
2929

3030
public function testListHasDataWithRelationships(ApiTester $I)
@@ -53,10 +53,10 @@ public function testListHasDataWithRelationships(ApiTester $I)
5353

5454
$I->sendHEAD('/post');
5555
$I->seeResponseCodeIs(200);
56-
$I->seeHttpHeader('X-Pagination-Total-Count', 54);
57-
$I->seeHttpHeader('X-Pagination-Current-Page', 1);
58-
$I->seeHttpHeader('X-Pagination-Per-Page', 20);
59-
$I->seeHttpHeader('X-Pagination-Page-Count', 3);
56+
$I->seeHttpHeader('X-Pagination-Total-Count', '54');
57+
$I->seeHttpHeader('X-Pagination-Current-Page', '1');
58+
$I->seeHttpHeader('X-Pagination-Per-Page', '20');
59+
$I->seeHttpHeader('X-Pagination-Page-Count', '3');
6060
}
6161

6262
public function testListFilterWithNotAllowedAttrs(ApiTester $I)

0 commit comments

Comments
 (0)