fixed tests according to the recent factory changes

This commit is contained in:
pushrbx 2024-04-11 00:01:40 +01:00
parent 9de8ffc9db
commit 9342407bef
3 changed files with 8 additions and 6 deletions

View File

@ -62,6 +62,8 @@ abstract class JikanMediaModelFactory extends JikanModelFactory implements Media
return $this->state($this->serializeStateDefinition($this->getStateOverrides($additionalParams, $doOpposite)));
}
// we want to generate overrides for each manufactured item, so all of them will call the faker for values,
// and they should have their own values, increasing the randomness of the generated data
/** @noinspection PhpParamsInspection */
return $this->state(new Sequence(fn(Sequence $_) => $this->serializeStateDefinition($this->getStateOverrides($additionalParams, $doOpposite))));
}

View File

@ -261,16 +261,16 @@ class AnimeSearchEndpointTest extends TestCase
*/
public function testSearchByEndDate($params)
{
$overrides = $this->generateFiveSpecificAndTenRandomElementsInDb($params);
$this->generateFiveSpecificAndTenRandomElementsInDb($params);
$content = $this->getJsonResponse($params);
$actualEndDate = Carbon::parse(data_get($content, "data.0.aired.to"));
$paramEndDate = Carbon::parse($overrides["aired"]["to"]);
$paramEndDate = Carbon::parse($params['end_date']);
$this->seeStatusCode(200);
$this->assertPaginationData(5);
$this->assertLessThanOrEqual(0, $actualEndDate->diff($paramEndDate)->days);
$this->assertGreaterThanOrEqual(1, $actualEndDate->diff($paramEndDate)->days);
// we created 5 elements according to parameters, so we expect 5 of them.
$this->assertCount(5, $content["data"]);
}

View File

@ -243,16 +243,16 @@ class MangaSearchEndpointTest extends TestCase
*/
public function testSearchByEndDate($params)
{
$overrides = $this->generateFiveSpecificAndTenRandomElementsInDb($params);
$this->generateFiveSpecificAndTenRandomElementsInDb($params);
$content = $this->getJsonResponse($params);
$actualEndDate = Carbon::parse(data_get($content, "data.0.published.to"));
$paramEndDate = Carbon::parse($overrides["published"]["to"]);
$paramEndDate = Carbon::parse($params["end_date"]);
$this->seeStatusCode(200);
$this->assertPaginationData(5);
$this->assertLessThanOrEqual(0, $actualEndDate->diff($paramEndDate)->days);
$this->assertGreaterThanOrEqual(1, $actualEndDate->diff($paramEndDate)->days);
// we created 5 elements according to parameters, so we expect 5 of them.
$this->assertCount(5, $content["data"]);
}