Skip to content

Commit

Permalink
~ Improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
tylernathanreed committed Mar 20, 2024
1 parent aa78671 commit 1b62bff
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use Illuminate\Database\Query\Builder as BaseBuilder;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
use Mockery as m;
use Mockery;
use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as TestBase;
use Reedware\LaravelRelationJoins\LaravelRelationJoinServiceProvider;
use Reedware\LaravelRelationJoins\Tests\CustomBuilder;
Expand All @@ -19,10 +20,13 @@ class TestCase extends TestBase
{
/**
* The mocked database connection.
*
* @var \Mockery\Mock
*/
protected $connection;
protected Connection&MockInterface $connection;

/**
* The mocked query results processor.
*/
protected Processor&MockInterface $processor;

/**
* Prepares the test for execution.
Expand All @@ -40,14 +44,16 @@ protected function setUp(): void
*/
protected function setUpConnectionResolver(): void
{
EloquentRelationJoinModelStub::setConnectionResolver($resolver = m::mock(ConnectionResolverInterface::class));
EloquentRelationJoinModelStub::setConnectionResolver(
$resolver = Mockery::mock(ConnectionResolverInterface::class)
);

$this->connection = m::mock(Connection::class);
$this->connection = Mockery::mock(Connection::class);

$processor = m::mock(Processor::class)
$this->processor = Mockery::mock(Processor::class)
->makePartial();

$processor->shouldNotReceive('processInsertGetId');
$this->processor->shouldNotReceive('processInsertGetId');

$resolver
->shouldReceive('connection')
Expand All @@ -59,12 +65,12 @@ protected function setUpConnectionResolver(): void

$this->connection
->shouldReceive('getPostProcessor')
->andReturn($processor);
->andReturn($this->processor);

$this->connection
->shouldReceive('query')
->andReturnUsing(function () use ($grammar, $processor) {
return new BaseBuilder($this->connection, $grammar, $processor);
->andReturnUsing(function () use ($grammar) {
return new BaseBuilder($this->connection, $grammar, $this->processor);
});
}

Expand All @@ -85,15 +91,15 @@ protected function registerServiceProvider(): void
*/
protected function tearDown(): void
{
m::close();
Mockery::close();
}

/**
* Returns the query resolvers for each test.
*
* @return array
* @return array<string,array<mixed>>
*/
public static function queryDataProvider()
public static function queryDataProvider(): array
{
$newQuery = function ($model) {
return $model->useCustomBuilder(false)->newQuery();
Expand Down

0 comments on commit 1b62bff

Please sign in to comment.