diff --git a/tests/WordPress/Concerns/HasMetasTest.php b/tests/WordPress/Concerns/HasMetasTest.php index a51e476b..506e79dc 100644 --- a/tests/WordPress/Concerns/HasMetasTest.php +++ b/tests/WordPress/Concerns/HasMetasTest.php @@ -15,19 +15,12 @@ use Dbout\WpOrm\Models\Meta\PostMeta; use Dbout\WpOrm\Models\Post; use Dbout\WpOrm\Tests\WordPress\TestCase; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; - -#[CoversClass(HasMetas::class)] -#[CoversFunction('getMeta')] -#[CoversFunction('setMeta')] -#[CoversFunction('hasMeta')] -#[CoversFunction('getMetaValue')] -#[CoversFunction('deleteMeta')] + class HasMetasTest extends TestCase { /** * @return void + * @covers HasMetas::getMeta */ public function testGetMeta(): void { @@ -46,6 +39,7 @@ public function testGetMeta(): void /** * @return void + * @covers HasMetas::setMeta */ public function testSetMeta(): void { @@ -63,6 +57,7 @@ public function testSetMeta(): void /** * @return void + * @covers HasMetas::hasMeta */ public function testHasMeta(): void { @@ -81,6 +76,7 @@ public function testHasMeta(): void /** * @return void + * @covers HasMetas::getMetaValue */ public function testGetMetaValueWithoutCast(): void { @@ -96,6 +92,7 @@ public function testGetMetaValueWithoutCast(): void /** * @return void + * @covers HasMetas::getMetaValue */ public function testGetMetaValueWithGenericCasts(): void { @@ -124,6 +121,7 @@ public function testGetMetaValueWithGenericCasts(): void /** * @return void + * @covers HasMetas::getMetaValue */ public function testGetMetaValueWithEnumCasts(): void { @@ -147,6 +145,7 @@ public function testGetMetaValueWithEnumCasts(): void /** * @return void + * @covers HasMetas::getMetaValue */ public function testGetMetaValueWithDatetimeCasts(): void { @@ -176,6 +175,7 @@ public function testGetMetaValueWithDatetimeCasts(): void /** * @return void + * @covers HasMetas::getMetaValue */ public function testGetMetaValueWithInvalidCasts(): void { @@ -195,6 +195,7 @@ public function testGetMetaValueWithInvalidCasts(): void /** * @return void + * @covers HasMetas::deleteMeta */ public function testDeleteMeta(): void { @@ -210,6 +211,7 @@ public function testDeleteMeta(): void /** * @return void + * @covers HasMetas::deleteMeta */ public function testDeleteUndefinedMeta(): void { diff --git a/tests/WordPress/Models/CustomCommentTest.php b/tests/WordPress/Models/CustomCommentTest.php index ca217a73..e719127c 100644 --- a/tests/WordPress/Models/CustomCommentTest.php +++ b/tests/WordPress/Models/CustomCommentTest.php @@ -10,18 +10,12 @@ use Dbout\WpOrm\Models\CustomComment; use Dbout\WpOrm\Tests\WordPress\TestCase; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; - -#[CoversClass(CustomComment::class)] -#[CoversFunction('find')] -#[CoversFunction('save')] -#[CoversFunction('all')] -#[CoversFunction('update')] + class CustomCommentTest extends TestCase { /** * @return void + * @covers CustomComment::find */ public function testFindValidType(): void { @@ -41,6 +35,7 @@ public function testFindValidType(): void /** * @return void + * @covers CustomComment::find */ public function testFindWithDifferentType(): void { @@ -58,6 +53,7 @@ public function testFindWithDifferentType(): void /** * @return void + * @covers CustomComment::save */ public function testSave(): void { @@ -81,6 +77,7 @@ public function testSave(): void /** * @return void + * @covers CustomComment::all */ public function testQueryAll(): void { @@ -108,6 +105,7 @@ public function testQueryAll(): void /** * @return void + * @covers CustomComment::update */ public function testUpdate(): void { diff --git a/tests/WordPress/Models/CustomPostTest.php b/tests/WordPress/Models/CustomPostTest.php index c29bc65d..91c18246 100644 --- a/tests/WordPress/Models/CustomPostTest.php +++ b/tests/WordPress/Models/CustomPostTest.php @@ -10,16 +10,12 @@ use Dbout\WpOrm\Models\CustomPost; use Dbout\WpOrm\Tests\WordPress\TestCase; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; -#[CoversClass(CustomPost::class)] -#[CoversFunction('find')] -#[CoversFunction('save')] class CustomPostTest extends TestCase { /** * @return void + * @covers CustomPost::find */ public function testFindWithValidPostType(): void { @@ -39,6 +35,7 @@ public function testFindWithValidPostType(): void /** * @return void + * @covers CustomPost::find */ public function testFindWithDifferentType(): void { @@ -56,6 +53,7 @@ public function testFindWithDifferentType(): void /** * @return void + * @covers CustomPost::save */ public function testSave(): void { diff --git a/tests/WordPress/Models/OptionTest.php b/tests/WordPress/Models/OptionTest.php index 862e9f68..d247fa83 100644 --- a/tests/WordPress/Models/OptionTest.php +++ b/tests/WordPress/Models/OptionTest.php @@ -10,13 +10,10 @@ use Dbout\WpOrm\Models\Option; use Dbout\WpOrm\Tests\WordPress\TestCase; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; -#[CoversClass(Option::class)] -#[CoversFunction('findOneByName')] -#[CoversFunction('getOptionName')] -#[CoversFunction('getOptionValue')] +/** + * @coversDefaultClass \Dbout\WpOrm\Models\Option + */ class OptionTest extends TestCase { private const OPTION_NAME = 'my_custom_option'; @@ -32,6 +29,9 @@ public static function setUpBeforeClass(): void /** * @return void + * @covers ::findOneByName + * @covers ::getOptionName + * @covers ::getOptionValue */ public function testFindOneByName(): void { diff --git a/tests/WordPress/Models/UserTest.php b/tests/WordPress/Models/UserTest.php index 1b596ef0..10abd707 100644 --- a/tests/WordPress/Models/UserTest.php +++ b/tests/WordPress/Models/UserTest.php @@ -11,14 +11,10 @@ use Dbout\WpOrm\Models\User; use Dbout\WpOrm\Tests\WordPress\Helpers\WithHasManyRelation; use Dbout\WpOrm\Tests\WordPress\TestCase; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; - -#[CoversClass(User::class)] -#[CoversFunction('findOneByEmail')] -#[CoversFunction('findOneByLogin')] -#[CoversFunction('comments')] -#[CoversFunction('posts')] + +/** + * @coversDefaultClass \Dbout\WpOrm\Models\User + */ class UserTest extends TestCase { use WithHasManyRelation; @@ -50,6 +46,7 @@ public static function setUpBeforeClass(): void /** * @return void + * @covers ::findOneByEmail */ public function testFindOneByEmailWithExistingUser(): void { @@ -62,6 +59,7 @@ public function testFindOneByEmailWithExistingUser(): void /** * @return void + * @covers ::findOneByLogin */ public function testFindOneByLoginWithExistingUser(): void { @@ -74,6 +72,7 @@ public function testFindOneByLoginWithExistingUser(): void /** * @return void + * @covers ::comments */ public function testComments(): void { @@ -102,6 +101,7 @@ public function testComments(): void /** * @return void + * @covers ::posts */ public function testPosts(): void { diff --git a/tests/WordPress/Orm/AbstractModelTest.php b/tests/WordPress/Orm/AbstractModelTest.php index cd084f9a..90ce8a40 100644 --- a/tests/WordPress/Orm/AbstractModelTest.php +++ b/tests/WordPress/Orm/AbstractModelTest.php @@ -11,30 +11,21 @@ use Dbout\WpOrm\Models\Article; use Dbout\WpOrm\Models\Option; use Dbout\WpOrm\Models\Post; -use Dbout\WpOrm\Orm\AbstractModel; use Dbout\WpOrm\Tests\WordPress\TestCase; use Illuminate\Database\QueryException; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; -use PHPUnit\Framework\Attributes\DataProvider; /** * @coversDefaultClass \Dbout\WpOrm\Orm\AbstractModel */ -#[CoversClass(AbstractModel::class)] -#[CoversFunction('saveOrFail')] -#[CoversFunction('save')] -#[CoversFunction('delete')] -#[CoversFunction('fill')] -#[CoversFunction('guard')] -#[CoversFunction('upsert')] class AbstractModelTest extends TestCase { /** * @param string $saveMethod * @return void + * @covers ::save + * @covers ::saveOrFail + * @dataProvider providerTestSaveNewObject */ - #[DataProvider('providerTestSaveNewObject')] public function testSuccessSaveNewObject(string $saveMethod): void { $model = new Article(); @@ -53,8 +44,10 @@ public function testSuccessSaveNewObject(string $saveMethod): void /** * @param string $saveMethod * @return void + * @covers ::save + * @covers ::saveOrFail + * @dataProvider providerTestSaveNewObject */ - #[DataProvider('providerTestSaveNewObject')] public function testSaveWithInvalidProperty(string $saveMethod): void { $fakeColumn = 'custom_column'; @@ -70,7 +63,7 @@ public function testSaveWithInvalidProperty(string $saveMethod): void /** * @return \Generator */ - public static function providerTestSaveNewObject(): \Generator + protected function providerTestSaveNewObject(): \Generator { yield 'With save function' => [ 'save', @@ -83,6 +76,7 @@ public static function providerTestSaveNewObject(): \Generator /** * @return void + * @covers ::delete */ public function testDelete(): void { @@ -100,6 +94,8 @@ public function testDelete(): void * Test if all attributes have been overridden. * * @return void + * @covers ::fill + * @covers ::guard */ public function testFillWithEmptyGuarded(): void { @@ -121,6 +117,8 @@ public function testFillWithEmptyGuarded(): void /** * @return void + * @covers ::fill + * @covers ::guard */ public function testFillWithGuardedAttributes(): void { @@ -144,6 +142,7 @@ public function testFillWithGuardedAttributes(): void /** * @return void + * @covers ::upsert */ public function testUpsertWithOneNewObjects(): void { @@ -167,6 +166,7 @@ public function testUpsertWithOneNewObjects(): void /** * @return void + * @covers ::upsert */ public function testUpsertWithExistingObjects(): void { @@ -201,6 +201,7 @@ public function testUpsertWithExistingObjects(): void /** * @return void + * @covers ::upsert */ public function testUpsertWithUpdateKey(): void { diff --git a/tests/WordPress/Orm/DatabaseTest.php b/tests/WordPress/Orm/DatabaseTest.php index d5b05831..aa0efd91 100644 --- a/tests/WordPress/Orm/DatabaseTest.php +++ b/tests/WordPress/Orm/DatabaseTest.php @@ -11,17 +11,10 @@ use Dbout\WpOrm\Models\Post; use Dbout\WpOrm\Orm\Database; use Dbout\WpOrm\Tests\WordPress\TestCase; -use PHPUnit\Framework\Attributes\CoversClass; -use PHPUnit\Framework\Attributes\CoversFunction; -use PHPUnit\Framework\Attributes\DataProvider; -#[CoversClass(Database::class)] -#[CoversFunction('getTablePrefix')] -#[CoversFunction('getDatabaseName')] -#[CoversFunction('getConfig')] -#[CoversFunction('getName')] -#[CoversFunction('table')] -#[CoversFunction('lastInsertId')] +/** + * @coversDefaultClass \Dbout\WpOrm\Orm\Database + */ class DatabaseTest extends TestCase { private Database $database; @@ -36,6 +29,7 @@ public function setUp(): void /** * @return void + * @covers ::getTablePrefix */ public function testGetTablePrefix(): void { @@ -45,6 +39,8 @@ public function testGetTablePrefix(): void /** * @return void + * @covers ::getDatabaseName + * @covers ::getConfig */ public function testGetDatabaseName(): void { @@ -53,6 +49,8 @@ public function testGetDatabaseName(): void /** * @return void + * @covers ::getName + * @covers ::getConfig */ public function testGetName(): void { @@ -64,8 +62,9 @@ public function testGetName(): void * @param string|null $alias * @param string $expectedQuery * @return void + * @covers ::table + * @dataProvider providerTestTable */ - #[DataProvider('providerTestTable')] public function testTable(string $table, ?string $alias, string $expectedQuery): void { $builder = $this->database->table($table, $alias); @@ -75,23 +74,24 @@ public function testTable(string $table, ?string $alias, string $expectedQuery): /** * @return \Generator */ - public static function providerTestTable(): \Generator + protected function providerTestTable(): \Generator { yield 'Without alias' => [ 'options', null, - sprintf('select * from "%s"', self::getTable('options')), + sprintf('select * from "%s"', $this->getTable('options')), ]; yield 'With alias' => [ 'options', 'opts', - sprintf('select * from "%s" as "opts"', self::getTable('options')), + sprintf('select * from "%s" as "opts"', $this->getTable('options')), ]; } /** * @return void + * @covers ::lastInsertId */ public function testLastInsertId(): void {