From 7c539d06c278d06acb5bd69a0cbfaf29c49d5a1a Mon Sep 17 00:00:00 2001 From: pushrbx Date: Wed, 31 Jan 2024 18:52:27 +0000 Subject: [PATCH] added tests --- tests/Unit/JikanApiSearchableModelTest.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/Unit/JikanApiSearchableModelTest.php diff --git a/tests/Unit/JikanApiSearchableModelTest.php b/tests/Unit/JikanApiSearchableModelTest.php new file mode 100644 index 0000000..861615c --- /dev/null +++ b/tests/Unit/JikanApiSearchableModelTest.php @@ -0,0 +1,52 @@ +titleAttributeNameFixture; + } +} + +final class JikanApiSearchableModelTest extends TestCase +{ + public function titleFieldDataProvider() + { + return [ + ["name"], + ["username"], + ["title"] + ]; + } + + /** + * @dataProvider titleFieldDataProvider + */ + public function testGetCollectionSchemaShouldReturnSortableTitleFieldInSchemaConfig($titleAttributeNameFixture) + { + $fixture = new JikanApiSearchableModelFixture(); + $fixture->titleAttributeNameFixture = $titleAttributeNameFixture; + $schema = $fixture->getCollectionSchema(); + + $this->assertArrayHasKey('fields', $schema); + $this->assertArrayHasKey('name', $schema['fields'][1]); + $this->assertArrayHasKey('type', $schema['fields'][1]); + $this->assertArrayHasKey('sort', $schema['fields'][1]); + $this->assertArrayHasKey('optional', $schema['fields'][1]); + $this->assertEquals($titleAttributeNameFixture, $schema['fields'][1]['name']); + $this->assertEquals('string', $schema['fields'][1]['type']); + $this->assertTrue($schema['fields'][1]['sort']); + $this->assertFalse($schema['fields'][1]['optional']); + } +}