mirror of
https://github.com/wearepixel/laravel-quickbooks.git
synced 2026-11-14 22:11:50 +00:00
feat: add Laravel 11/12 and PHP 8.3+ support
- Widen illuminate/* deps to ^10.0|^11.0|^12.0, require PHP ^8.3 - Upgrade PHPUnit to ^10.5|^11.0, Mockery to ^1.6 - Rewrite phpunit.xml.dist for PHPUnit 10+ format (source/include replaces filter/whitelist, removed deprecated attributes) - Replace $dates with $casts on Token model - Implement DeferrableProvider interface instead of $defer property on ClientServiceProvider - Use FQCN route definitions instead of string-based namespace() - Fix migration getColumnType() check for Laravel 11+ native types - Replace @test doc annotations with #[Test] attributes - Fix dynamic property deprecation in ControllerTest
This commit is contained in:
+9
-9
@@ -16,19 +16,19 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0.2",
|
"php": "^8.3",
|
||||||
"illuminate/database": "^10.0",
|
"illuminate/database": "^10.0|^11.0|^12.0",
|
||||||
"illuminate/http": "^10.0",
|
"illuminate/http": "^10.0|^11.0|^12.0",
|
||||||
"illuminate/routing": "^10.0",
|
"illuminate/routing": "^10.0|^11.0|^12.0",
|
||||||
"illuminate/support": "^10.0",
|
"illuminate/support": "^10.0|^11.0|^12.0",
|
||||||
"nesbot/carbon": "^2.62.1",
|
"nesbot/carbon": "^2.62.1|^3.0",
|
||||||
"quickbooks/v3-php-sdk": "^5.4.6"
|
"quickbooks/v3-php-sdk": "^5.4.6"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"laravel/pint": "^1.2",
|
"laravel/pint": "^1.2",
|
||||||
"mockery/mockery": "^1.5.1",
|
"mockery/mockery": "^1.6",
|
||||||
"phpunit/phpunit": "^9.3.3",
|
"phpunit/phpunit": "^10.5|^11.0",
|
||||||
"psy/psysh": "^0.11",
|
"psy/psysh": "^0.12",
|
||||||
"scrutinizer/ocular": "^1.9"
|
"scrutinizer/ocular": "^1.9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
@@ -15,10 +15,9 @@
|
|||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('quickbooks_tokens', function (Blueprint $table) {
|
Schema::create('quickbooks_tokens', function (Blueprint $table) {
|
||||||
$user_id_type =
|
$user_id_type = str_contains(DB::getSchemaBuilder()->getColumnType('users', 'id'), 'bigint')
|
||||||
DB::getSchemaBuilder()->getColumnType('users', 'id') === 'bigint'
|
? 'unsignedBigInteger'
|
||||||
? 'unsignedBigInteger'
|
: 'unsignedInteger';
|
||||||
: 'unsignedInteger';
|
|
||||||
|
|
||||||
$table->bigIncrements('id');
|
$table->bigIncrements('id');
|
||||||
$table->{$user_id_type}('user_id');
|
$table->{$user_id_type}('user_id');
|
||||||
|
|||||||
+10
-27
@@ -8,15 +8,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<phpunit backupGlobals="false"
|
<phpunit backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticProperties="false"
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
|
||||||
convertNoticesToExceptions="true"
|
|
||||||
convertWarningsToExceptions="true"
|
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false">
|
||||||
verbose="true">
|
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Wearepixel's Laravel QuickBooks Client">
|
<testsuite name="Wearepixel's Laravel QuickBooks Client">
|
||||||
@@ -28,26 +24,13 @@
|
|||||||
<!-- <env name="VARIABLE" value="value"/> -->
|
<!-- <env name="VARIABLE" value="value"/> -->
|
||||||
</php>
|
</php>
|
||||||
|
|
||||||
<filter>
|
<source>
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
<include>
|
||||||
<directory suffix=".php">./src</directory>
|
<directory suffix=".php">./src</directory>
|
||||||
<exclude>
|
</include>
|
||||||
<directory>./src/Http/Exceptions</directory>
|
<exclude>
|
||||||
<directory>./src/Providers</directory>
|
<directory>./src/Http/Exceptions</directory>
|
||||||
</exclude>
|
<directory>./src/Providers</directory>
|
||||||
</whitelist>
|
</exclude>
|
||||||
</filter>
|
</source>
|
||||||
|
|
||||||
<logging>
|
|
||||||
<log type="coverage-html"
|
|
||||||
target="./build/phpunit/coverage"
|
|
||||||
lowUpperBound="35"
|
|
||||||
highLowerBound="70"/>
|
|
||||||
<log type="coverage-text"
|
|
||||||
target="php://stdout"
|
|
||||||
showOnlySummary="true"
|
|
||||||
showUncoveredFiles="false"/>
|
|
||||||
<log type="coverage-clover" target="build/phpunit/logs/clover.xml"/>
|
|
||||||
<log type="junit" target="./build/phpunit/logs/junit.xml"/>
|
|
||||||
</logging>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ public function __construct(
|
|||||||
protected Redirector $redirector,
|
protected Redirector $redirector,
|
||||||
protected Session $session,
|
protected Session $session,
|
||||||
protected UrlGenerator $url_generator,
|
protected UrlGenerator $url_generator,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
|
|||||||
@@ -3,19 +3,15 @@
|
|||||||
namespace Wearepixel\QuickBooks\Providers;
|
namespace Wearepixel\QuickBooks\Providers;
|
||||||
|
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
|
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||||
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
|
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
|
||||||
use Wearepixel\QuickBooks\Client;
|
use Wearepixel\QuickBooks\Client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ClientServiceProvider
|
* Class ClientServiceProvider
|
||||||
*/
|
*/
|
||||||
class ClientServiceProvider extends LaravelServiceProvider
|
class ClientServiceProvider extends LaravelServiceProvider implements DeferrableProvider
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Indicates if loading of the provider is deferred.
|
|
||||||
*/
|
|
||||||
protected bool $defer = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the services provided by the provider.
|
* Get the services provided by the provider.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Wearepixel\QuickBooks\Providers;
|
namespace Wearepixel\QuickBooks\Providers;
|
||||||
|
|
||||||
use Illuminate\Routing\Router;
|
|
||||||
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
|
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
|
||||||
|
use Wearepixel\QuickBooks\Http\Controllers\Controller;
|
||||||
use Wearepixel\QuickBooks\Http\Middleware\Filter;
|
use Wearepixel\QuickBooks\Http\Middleware\Filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,19 +89,20 @@ protected function registerRoutes(): void
|
|||||||
->prefix($config['prefix'])
|
->prefix($config['prefix'])
|
||||||
->as('quickbooks.')
|
->as('quickbooks.')
|
||||||
->middleware($config['middleware']['default'])
|
->middleware($config['middleware']['default'])
|
||||||
->namespace('Wearepixel\QuickBooks\Http\Controllers')
|
->group(function () use ($config) {
|
||||||
->group(function (Router $router) use ($config) {
|
$this->app->router
|
||||||
$router
|
->get($config['paths']['connect'], [Controller::class, 'connect'])
|
||||||
->get($config['paths']['connect'], 'Controller@connect')
|
|
||||||
->middleware($config['middleware']['authenticated'])
|
->middleware($config['middleware']['authenticated'])
|
||||||
->name('connect');
|
->name('connect');
|
||||||
|
|
||||||
$router
|
$this->app->router
|
||||||
->delete($config['paths']['disconnect'], 'Controller@disconnect')
|
->delete($config['paths']['disconnect'], [Controller::class, 'disconnect'])
|
||||||
->middleware($config['middleware']['authenticated'])
|
->middleware($config['middleware']['authenticated'])
|
||||||
->name('disconnect');
|
->name('disconnect');
|
||||||
|
|
||||||
$router->get($config['paths']['token'], 'Controller@token')->name('token');
|
$this->app->router
|
||||||
|
->get($config['paths']['token'], [Controller::class, 'token'])
|
||||||
|
->name('token');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -34,11 +34,14 @@ class Token extends Model
|
|||||||
protected $table = 'quickbooks_tokens';
|
protected $table = 'quickbooks_tokens';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be mutated to dates.
|
* The attributes that should be cast.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<string, string>
|
||||||
*/
|
*/
|
||||||
protected $dates = ['access_token_expires_at', 'refresh_token_expires_at'];
|
protected $casts = [
|
||||||
|
'access_token_expires_at' => 'datetime',
|
||||||
|
'refresh_token_expires_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
|
|||||||
+10
-27
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Mockery\Mock;
|
use Mockery\Mock;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use QuickBooksOnline\API\DataService\DataService;
|
use QuickBooksOnline\API\DataService\DataService;
|
||||||
use QuickBooksOnline\API\Exception\ServiceException;
|
use QuickBooksOnline\API\Exception\ServiceException;
|
||||||
|
|
||||||
@@ -53,17 +54,13 @@ private function makeClient($configs = null)
|
|||||||
return new Client($this->configs, $this->token_mock);
|
return new Client($this->configs, $this->token_mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_can_be_constructed()
|
public function it_can_be_constructed()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(Client::class, $this->client);
|
$this->assertInstanceOf(Client::class, $this->client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_returns_a_data_service_configured_to_request_oauth_token_when_token_is_empty()
|
public function it_returns_a_data_service_configured_to_request_oauth_token_when_token_is_empty()
|
||||||
{
|
{
|
||||||
$this->token_mock
|
$this->token_mock
|
||||||
@@ -86,9 +83,7 @@ public function it_returns_a_data_service_configured_to_request_oauth_token_when
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_caches_the_data_service_once_it_is_made()
|
public function it_caches_the_data_service_once_it_is_made()
|
||||||
{
|
{
|
||||||
$this->token_mock
|
$this->token_mock
|
||||||
@@ -107,9 +102,7 @@ public function it_caches_the_data_service_once_it_is_made()
|
|||||||
$this->assertEquals(DataService::class, get_class($this->client->getDataService()));
|
$this->assertEquals(DataService::class, get_class($this->client->getDataService()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_returns_a_data_service_with_oauth_token_when_valid_access_token_exist()
|
public function it_returns_a_data_service_with_oauth_token_when_valid_access_token_exist()
|
||||||
{
|
{
|
||||||
$this->token_mock
|
$this->token_mock
|
||||||
@@ -144,9 +137,7 @@ public function it_returns_a_data_service_with_oauth_token_when_valid_access_tok
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_returns_a_data_service_with_refreshed_token_when_access_token_expired_but_refresh_token_valid()
|
public function it_returns_a_data_service_with_refreshed_token_when_access_token_expired_but_refresh_token_valid()
|
||||||
{
|
{
|
||||||
$this->expectException(ServiceException::class);
|
$this->expectException(ServiceException::class);
|
||||||
@@ -189,9 +180,7 @@ public function it_returns_a_data_service_with_refreshed_token_when_access_token
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_returns_a_report_service_using_the_data_service()
|
public function it_returns_a_report_service_using_the_data_service()
|
||||||
{
|
{
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
@@ -199,9 +188,7 @@ public function it_returns_a_report_service_using_the_data_service()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_has_logging_off_by_default()
|
public function it_has_logging_off_by_default()
|
||||||
{
|
{
|
||||||
$this->markTestSkipped('Have to figure out how to test this with the new code in 5.x');
|
$this->markTestSkipped('Have to figure out how to test this with the new code in 5.x');
|
||||||
@@ -227,9 +214,7 @@ public function it_has_logging_off_by_default()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_allows_logging_turned_on_and_pointed_to_expected_file()
|
public function it_allows_logging_turned_on_and_pointed_to_expected_file()
|
||||||
{
|
{
|
||||||
$this->markTestSkipped('Have to figure out how to test this with the new code in 5.x');
|
$this->markTestSkipped('Have to figure out how to test this with the new code in 5.x');
|
||||||
@@ -273,9 +258,7 @@ public function it_allows_logging_turned_on_and_pointed_to_expected_file()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_returns_self_after_deleting_token()
|
public function it_returns_self_after_deleting_token()
|
||||||
{
|
{
|
||||||
$this->token_mock
|
$this->token_mock
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Wearepixel\QuickBooks;
|
namespace Wearepixel\QuickBooks;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Wearepixel\QuickBooks\Stubs\User;
|
use Wearepixel\QuickBooks\Stubs\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,21 +19,17 @@ protected function setUp(): void
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->user = new User();
|
$this->user = new User;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_can_be_constructed()
|
public function it_can_be_constructed()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(User::class, $this->user);
|
$this->assertInstanceOf(User::class, $this->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
public function it_has_a_has_one_relationship_to_token()
|
||||||
*/
|
|
||||||
public function it_has_a_hasOne_relationship_to_token()
|
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(Token::class, $this->user->quickBooksToken()->getModel());
|
$this->assertInstanceOf(Token::class, $this->user->quickBooksToken()->getModel());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
use Illuminate\Session\Store;
|
use Illuminate\Session\Store;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Mockery\Mock;
|
use Mockery\Mock;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use QuickBooksOnline\API\DataService\DataService;
|
use QuickBooksOnline\API\DataService\DataService;
|
||||||
use Wearepixel\QuickBooks\Client as QuickBooks;
|
use Wearepixel\QuickBooks\Client as QuickBooks;
|
||||||
use Wearepixel\QuickBooks\TestCase;
|
use Wearepixel\QuickBooks\TestCase;
|
||||||
@@ -50,6 +51,11 @@ class ControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected $session_mock;
|
protected $session_mock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Mock
|
||||||
|
*/
|
||||||
|
protected $url_generator_mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Mock
|
* @var Mock
|
||||||
*/
|
*/
|
||||||
@@ -67,23 +73,20 @@ protected function setUp(): void
|
|||||||
$this->redirector_mock = Mockery::mock(Redirector::class);
|
$this->redirector_mock = Mockery::mock(Redirector::class);
|
||||||
$this->request_mock = Mockery::mock(Request::class);
|
$this->request_mock = Mockery::mock(Request::class);
|
||||||
$this->session_mock = Mockery::mock(Store::class);
|
$this->session_mock = Mockery::mock(Store::class);
|
||||||
|
$this->url_generator_mock = Mockery::mock(UrlGenerator::class);
|
||||||
$this->view_factory_mock = Mockery::mock(ViewFactory::class);
|
$this->view_factory_mock = Mockery::mock(ViewFactory::class);
|
||||||
$this->view_mock = Mockery::mock(View::class);
|
$this->view_mock = Mockery::mock(View::class);
|
||||||
|
|
||||||
$this->controller = new Controller();
|
$this->controller = new Controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_can_be_constructed()
|
public function it_can_be_constructed()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(Controller::class, $this->controller);
|
$this->assertInstanceOf(Controller::class, $this->controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_shows_view_to_connect_if_account_not_linked()
|
public function it_shows_view_to_connect_if_account_not_linked()
|
||||||
{
|
{
|
||||||
$this->data_service_mock
|
$this->data_service_mock
|
||||||
@@ -126,9 +129,7 @@ public function it_shows_view_to_connect_if_account_not_linked()
|
|||||||
$this->controller->connect($this->quickbooks_mock, $this->view_factory_mock);
|
$this->controller->connect($this->quickbooks_mock, $this->view_factory_mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_shows_view_to_disconnect_if_account_linked()
|
public function it_shows_view_to_disconnect_if_account_linked()
|
||||||
{
|
{
|
||||||
$this->quickbooks_mock
|
$this->quickbooks_mock
|
||||||
@@ -158,9 +159,7 @@ public function it_shows_view_to_disconnect_if_account_linked()
|
|||||||
$this->controller->connect($this->quickbooks_mock, $this->view_factory_mock);
|
$this->controller->connect($this->quickbooks_mock, $this->view_factory_mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_disconnects_from_quickbooks_when_requested()
|
public function it_disconnects_from_quickbooks_when_requested()
|
||||||
{
|
{
|
||||||
$this->request_mock
|
$this->request_mock
|
||||||
@@ -192,12 +191,9 @@ public function it_disconnects_from_quickbooks_when_requested()
|
|||||||
$this->assertInstanceOf(RedirectResponse::class, $result);
|
$this->assertInstanceOf(RedirectResponse::class, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_finishes_connecting_to_quickbooks_when_given_a_valid_token_by_quickbooks()
|
public function it_finishes_connecting_to_quickbooks_when_given_a_valid_token_by_quickbooks()
|
||||||
{
|
{
|
||||||
$this->url_generator_mock = Mockery::mock(UrlGenerator::class);
|
|
||||||
$realmId = random_int(1, 9999);
|
$realmId = random_int(1, 9999);
|
||||||
|
|
||||||
$this->quickbooks_mock
|
$this->quickbooks_mock
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Mockery\Mock;
|
use Mockery\Mock;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Wearepixel\QuickBooks\Client as QuickBooks;
|
use Wearepixel\QuickBooks\Client as QuickBooks;
|
||||||
use Wearepixel\QuickBooks\TestCase;
|
use Wearepixel\QuickBooks\TestCase;
|
||||||
|
|
||||||
@@ -62,17 +63,13 @@ protected function setUp(): void
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_can_be_constructed()
|
public function it_can_be_constructed()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(Filter::class, $this->filter);
|
$this->assertInstanceOf(Filter::class, $this->filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_just_passes_the_request_to_the_next_middleware_if_account_linked_to_quickbooks()
|
public function it_just_passes_the_request_to_the_next_middleware_if_account_linked_to_quickbooks()
|
||||||
{
|
{
|
||||||
$next_middleware = function ($request) {
|
$next_middleware = function ($request) {
|
||||||
@@ -88,9 +85,7 @@ public function it_just_passes_the_request_to_the_next_middleware_if_account_lin
|
|||||||
$this->filter->handle($this->request_mock, $next_middleware);
|
$this->filter->handle($this->request_mock, $next_middleware);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_redirects_to_quickbooks_connect_route_after_setting_intended_session_if_account_not_linked()
|
public function it_redirects_to_quickbooks_connect_route_after_setting_intended_session_if_account_not_linked()
|
||||||
{
|
{
|
||||||
$this->request_mock
|
$this->request_mock
|
||||||
|
|||||||
+14
-37
@@ -5,6 +5,7 @@
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use QuickBooksOnline\API\Core\OAuth\OAuth2\OAuth2AccessToken;
|
use QuickBooksOnline\API\Core\OAuth\OAuth2\OAuth2AccessToken;
|
||||||
use Wearepixel\QuickBooks\Stubs\TokenStub;
|
use Wearepixel\QuickBooks\Stubs\TokenStub;
|
||||||
use Wearepixel\QuickBooks\Stubs\User;
|
use Wearepixel\QuickBooks\Stubs\User;
|
||||||
@@ -21,52 +22,40 @@ class TokenTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->token = new TokenStub();
|
$this->token = new TokenStub;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_can_be_constructed()
|
public function it_can_be_constructed()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(Token::class, $this->token);
|
$this->assertInstanceOf(Token::class, $this->token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_has_accessor_for_valid_access_token()
|
public function it_has_accessor_for_valid_access_token()
|
||||||
{
|
{
|
||||||
$this->assertNotNull($this->token->getHasValidAccessTokenAttribute());
|
$this->assertNotNull($this->token->getHasValidAccessTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_has_accessor_for_valid_refresh_token()
|
public function it_has_accessor_for_valid_refresh_token()
|
||||||
{
|
{
|
||||||
$this->assertNotNull($this->token->getHasValidRefreshTokenAttribute());
|
$this->assertNotNull($this->token->getHasValidRefreshTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_knows_that_the_access_token_expires_at_has_to_be_valid()
|
public function it_knows_that_the_access_token_expires_at_has_to_be_valid()
|
||||||
{
|
{
|
||||||
$this->assertFalse($this->token->getHasValidAccessTokenAttribute());
|
$this->assertFalse($this->token->getHasValidAccessTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_knows_that_the_refresh_token_expires_at_has_to_be_valid()
|
public function it_knows_that_the_refresh_token_expires_at_has_to_be_valid()
|
||||||
{
|
{
|
||||||
$this->assertFalse($this->token->getHasValidRefreshTokenAttribute());
|
$this->assertFalse($this->token->getHasValidRefreshTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_know_if_access_token_expires_at_is_less_than_now_it_is_not_expired()
|
public function it_know_if_access_token_expires_at_is_less_than_now_it_is_not_expired()
|
||||||
{
|
{
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
@@ -77,9 +66,7 @@ public function it_know_if_access_token_expires_at_is_less_than_now_it_is_not_ex
|
|||||||
$this->assertTrue($this->token->getHasValidAccessTokenAttribute());
|
$this->assertTrue($this->token->getHasValidAccessTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_know_if_refresh_token_expires_at_is_less_than_now_it_is_not_expired()
|
public function it_know_if_refresh_token_expires_at_is_less_than_now_it_is_not_expired()
|
||||||
{
|
{
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
@@ -90,9 +77,7 @@ public function it_know_if_refresh_token_expires_at_is_less_than_now_it_is_not_e
|
|||||||
$this->assertTrue($this->token->getHasValidRefreshTokenAttribute());
|
$this->assertTrue($this->token->getHasValidRefreshTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_know_if_access_token_expires_at_is_greater_than_or_equal_to_now_it_is_expired()
|
public function it_know_if_access_token_expires_at_is_greater_than_or_equal_to_now_it_is_expired()
|
||||||
{
|
{
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
@@ -107,9 +92,7 @@ public function it_know_if_access_token_expires_at_is_greater_than_or_equal_to_n
|
|||||||
$this->assertFalse($this->token->getHasValidAccessTokenAttribute());
|
$this->assertFalse($this->token->getHasValidAccessTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_know_if_refresh_token_expires_at_is_greater_than_or_equal_to_now_it_is_expired()
|
public function it_know_if_refresh_token_expires_at_is_greater_than_or_equal_to_now_it_is_expired()
|
||||||
{
|
{
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
@@ -124,9 +107,7 @@ public function it_know_if_refresh_token_expires_at_is_greater_than_or_equal_to_
|
|||||||
$this->assertFalse($this->token->getHasValidRefreshTokenAttribute());
|
$this->assertFalse($this->token->getHasValidRefreshTokenAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_stores_the_oauth_token_parts_in_expected_properties()
|
public function it_stores_the_oauth_token_parts_in_expected_properties()
|
||||||
{
|
{
|
||||||
$oauth_token_mock = Mockery::mock(OAuth2AccessToken::class);
|
$oauth_token_mock = Mockery::mock(OAuth2AccessToken::class);
|
||||||
@@ -164,9 +145,7 @@ public function it_stores_the_oauth_token_parts_in_expected_properties()
|
|||||||
$this->token->parseOauthToken($oauth_token_mock);
|
$this->token->parseOauthToken($oauth_token_mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_allows_itself_to_be_deleted_and_returns_new_token()
|
public function it_allows_itself_to_be_deleted_and_returns_new_token()
|
||||||
{
|
{
|
||||||
$this->token->user = Mockery::mock(User::class);
|
$this->token->user = Mockery::mock(User::class);
|
||||||
@@ -191,9 +170,7 @@ public function it_allows_itself_to_be_deleted_and_returns_new_token()
|
|||||||
$this->assertEquals($token_mock, $this->token->remove());
|
$this->assertEquals($token_mock, $this->token->remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function it_get_related_user_model_from_configuration()
|
public function it_get_related_user_model_from_configuration()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(User::class, $this->token->user()->getModel());
|
$this->assertInstanceOf(User::class, $this->token->user()->getModel());
|
||||||
|
|||||||
Reference in New Issue
Block a user