mirror of
https://github.com/wearepixel/laravel-quickbooks.git
synced 2026-11-14 22:11:50 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\QuickBooks\Stubs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Mockery;
|
||||
use Wearepixel\QuickBooks\Token;
|
||||
|
||||
/**
|
||||
* Class TokenStub
|
||||
*
|
||||
* Stub for a Laravel Token model
|
||||
*/
|
||||
class TokenStub extends Token
|
||||
{
|
||||
// Put public properties on this stub to keep the Model from trying to get them from db
|
||||
public $access_token = null;
|
||||
|
||||
public $access_token_expires_at = null;
|
||||
|
||||
public $realm_id = null;
|
||||
|
||||
public $refresh_token = null;
|
||||
|
||||
public $refresh_token_expires_at = null;
|
||||
|
||||
public $user = null;
|
||||
|
||||
public function belongsTo(
|
||||
$related,
|
||||
$foreignKey = null,
|
||||
$ownerKey = null,
|
||||
$relation = null,
|
||||
): BelongsTo {
|
||||
$related_mock = Mockery::mock($related);
|
||||
$related_mock->shouldIgnoreMissing();
|
||||
|
||||
$child_mock = Mockery::mock(Model::class);
|
||||
$child_mock->shouldIgnoreMissing();
|
||||
|
||||
$builder_mock = Mockery::mock(Builder::class);
|
||||
$builder_mock->shouldIgnoreMissing();
|
||||
$builder_mock->shouldReceive('getModel')->andReturn($related_mock);
|
||||
|
||||
return new BelongsTo($builder_mock, $child_mock, $foreignKey, $ownerKey, $relation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\QuickBooks\Stubs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Mockery;
|
||||
use Wearepixel\QuickBooks\HasQuickBooksToken;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* Stub for a Laravel User model
|
||||
*/
|
||||
class User
|
||||
{
|
||||
use HasQuickBooksToken;
|
||||
|
||||
public function hasOne($relationship): HasOne
|
||||
{
|
||||
$related_mock = Mockery::mock($relationship);
|
||||
$related_mock->shouldIgnoreMissing();
|
||||
|
||||
$builder_mock = Mockery::mock(Builder::class);
|
||||
$builder_mock->shouldIgnoreMissing();
|
||||
$builder_mock->shouldReceive('getModel')->andReturn($related_mock);
|
||||
|
||||
$parent_mock = Mockery::mock(Model::class);
|
||||
$parent_mock->shouldIgnoreMissing();
|
||||
|
||||
return new HasOne($builder_mock, $parent_mock, 'foreignKey', 'localKey');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user