Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitriBouteille committed Mar 10, 2024
1 parent 6f06032 commit f2be490
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
24 changes: 20 additions & 4 deletions tests/Builders/WithMetaBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Dbout\WpOrm\Builders\PostBuilder;
use Dbout\WpOrm\Exceptions\WpOrmException;
use Dbout\WpOrm\Models\Post;
use Dbout\WpOrm\Tests\WpDatabaseInstanceCreator;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

Expand All @@ -21,8 +20,6 @@
*/
class WithMetaBuilderTest extends TestCase
{
use WpDatabaseInstanceCreator;

private PostBuilder $builder;

private Post&MockObject $post;
Expand All @@ -34,7 +31,7 @@ class WithMetaBuilderTest extends TestCase
*/
protected function setUp(): void
{
$this->initWpDatabaseInstance();
$this->initDatabase();
$queryBuilder = new \Illuminate\Database\Query\Builder(
$this->createMock(\Illuminate\Database\MySqlConnection::class),
new \Illuminate\Database\Query\Grammars\Grammar(),
Expand Down Expand Up @@ -164,4 +161,23 @@ public function testAddMetaToFilter(): void
$this->builder->getBindings(),
);
}

/**
* @return void
*/
protected function initDatabase(): void
{
$mock = $this->getMockBuilder(\wpdb::class)
->onlyMethods(['db_version'])
->setConstructorArgs([
'db_user',
'db_password',
'test_database',
'127.0.0.0',
])
->getMock();

$mock->method('db_version')->willReturn('8.0.0');
$GLOBALS['wpdb'] = $mock;
}
}
3 changes: 0 additions & 3 deletions tests/Orm/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Dbout\WpOrm\Tests\Orm;

use Dbout\WpOrm\Orm\Database;
use Dbout\WpOrm\Tests\WpDatabaseInstanceCreator;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -18,8 +17,6 @@

class DatabaseTest extends TestCase
{
use WpDatabaseInstanceCreator;

/**
* @return void
* @covers ::getInstance
Expand Down
20 changes: 0 additions & 20 deletions tests/WpDatabaseInstanceCreator.php

This file was deleted.

0 comments on commit f2be490

Please sign in to comment.