Initial commit

This commit is contained in:
divakar-rajodiya
2024-06-25 17:45:35 +05:30
commit b145af20c4
28 changed files with 2250 additions and 0 deletions
+49
View File
@@ -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);
}
}
+34
View File
@@ -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');
}
}