Skip to content

Commit

Permalink
Rollback tests\WordPress migration to phpunit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitriBouteille committed Oct 5, 2024
1 parent ccc7414 commit 80b00d9
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 64 deletions.
20 changes: 11 additions & 9 deletions tests/WordPress/Concerns/HasMetasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -46,6 +39,7 @@ public function testGetMeta(): void

/**
* @return void
* @covers HasMetas::setMeta
*/
public function testSetMeta(): void
{
Expand All @@ -63,6 +57,7 @@ public function testSetMeta(): void

/**
* @return void
* @covers HasMetas::hasMeta
*/
public function testHasMeta(): void
{
Expand All @@ -81,6 +76,7 @@ public function testHasMeta(): void

/**
* @return void
* @covers HasMetas::getMetaValue
*/
public function testGetMetaValueWithoutCast(): void
{
Expand All @@ -96,6 +92,7 @@ public function testGetMetaValueWithoutCast(): void

/**
* @return void
* @covers HasMetas::getMetaValue
*/
public function testGetMetaValueWithGenericCasts(): void
{
Expand Down Expand Up @@ -124,6 +121,7 @@ public function testGetMetaValueWithGenericCasts(): void

/**
* @return void
* @covers HasMetas::getMetaValue
*/
public function testGetMetaValueWithEnumCasts(): void
{
Expand All @@ -147,6 +145,7 @@ public function testGetMetaValueWithEnumCasts(): void

/**
* @return void
* @covers HasMetas::getMetaValue
*/
public function testGetMetaValueWithDatetimeCasts(): void
{
Expand Down Expand Up @@ -176,6 +175,7 @@ public function testGetMetaValueWithDatetimeCasts(): void

/**
* @return void
* @covers HasMetas::getMetaValue
*/
public function testGetMetaValueWithInvalidCasts(): void
{
Expand All @@ -195,6 +195,7 @@ public function testGetMetaValueWithInvalidCasts(): void

/**
* @return void
* @covers HasMetas::deleteMeta
*/
public function testDeleteMeta(): void
{
Expand All @@ -210,6 +211,7 @@ public function testDeleteMeta(): void

/**
* @return void
* @covers HasMetas::deleteMeta
*/
public function testDeleteUndefinedMeta(): void
{
Expand Down
14 changes: 6 additions & 8 deletions tests/WordPress/Models/CustomCommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -41,6 +35,7 @@ public function testFindValidType(): void

/**
* @return void
* @covers CustomComment::find
*/
public function testFindWithDifferentType(): void
{
Expand All @@ -58,6 +53,7 @@ public function testFindWithDifferentType(): void

/**
* @return void
* @covers CustomComment::save
*/
public function testSave(): void
{
Expand All @@ -81,6 +77,7 @@ public function testSave(): void

/**
* @return void
* @covers CustomComment::all
*/
public function testQueryAll(): void
{
Expand Down Expand Up @@ -108,6 +105,7 @@ public function testQueryAll(): void

/**
* @return void
* @covers CustomComment::update
*/
public function testUpdate(): void
{
Expand Down
8 changes: 3 additions & 5 deletions tests/WordPress/Models/CustomPostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -39,6 +35,7 @@ public function testFindWithValidPostType(): void

/**
* @return void
* @covers CustomPost::find
*/
public function testFindWithDifferentType(): void
{
Expand All @@ -56,6 +53,7 @@ public function testFindWithDifferentType(): void

/**
* @return void
* @covers CustomPost::save
*/
public function testSave(): void
{
Expand Down
12 changes: 6 additions & 6 deletions tests/WordPress/Models/OptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -32,6 +29,9 @@ public static function setUpBeforeClass(): void

/**
* @return void
* @covers ::findOneByName
* @covers ::getOptionName
* @covers ::getOptionValue
*/
public function testFindOneByName(): void
{
Expand Down
16 changes: 8 additions & 8 deletions tests/WordPress/Models/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +46,7 @@ public static function setUpBeforeClass(): void

/**
* @return void
* @covers ::findOneByEmail
*/
public function testFindOneByEmailWithExistingUser(): void
{
Expand All @@ -62,6 +59,7 @@ public function testFindOneByEmailWithExistingUser(): void

/**
* @return void
* @covers ::findOneByLogin
*/
public function testFindOneByLoginWithExistingUser(): void
{
Expand All @@ -74,6 +72,7 @@ public function testFindOneByLoginWithExistingUser(): void

/**
* @return void
* @covers ::comments
*/
public function testComments(): void
{
Expand Down Expand Up @@ -102,6 +101,7 @@ public function testComments(): void

/**
* @return void
* @covers ::posts
*/
public function testPosts(): void
{
Expand Down
29 changes: 15 additions & 14 deletions tests/WordPress/Orm/AbstractModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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';
Expand All @@ -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',
Expand All @@ -83,6 +76,7 @@ public static function providerTestSaveNewObject(): \Generator

/**
* @return void
* @covers ::delete
*/
public function testDelete(): void
{
Expand All @@ -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
{
Expand All @@ -121,6 +117,8 @@ public function testFillWithEmptyGuarded(): void

/**
* @return void
* @covers ::fill
* @covers ::guard
*/
public function testFillWithGuardedAttributes(): void
{
Expand All @@ -144,6 +142,7 @@ public function testFillWithGuardedAttributes(): void

/**
* @return void
* @covers ::upsert
*/
public function testUpsertWithOneNewObjects(): void
{
Expand All @@ -167,6 +166,7 @@ public function testUpsertWithOneNewObjects(): void

/**
* @return void
* @covers ::upsert
*/
public function testUpsertWithExistingObjects(): void
{
Expand Down Expand Up @@ -201,6 +201,7 @@ public function testUpsertWithExistingObjects(): void

/**
* @return void
* @covers ::upsert
*/
public function testUpsertWithUpdateKey(): void
{
Expand Down
Loading

0 comments on commit 80b00d9

Please sign in to comment.