mirror of
https://github.com/wearepixel/laravel-quickbooks.git
synced 2026-11-14 14:01:46 +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:
+10
-27
@@ -4,6 +4,7 @@
|
||||
|
||||
use Mockery;
|
||||
use Mockery\Mock;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use QuickBooksOnline\API\DataService\DataService;
|
||||
use QuickBooksOnline\API\Exception\ServiceException;
|
||||
|
||||
@@ -53,17 +54,13 @@ private function makeClient($configs = null)
|
||||
return new Client($this->configs, $this->token_mock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_can_be_constructed()
|
||||
{
|
||||
$this->assertInstanceOf(Client::class, $this->client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_returns_a_data_service_configured_to_request_oauth_token_when_token_is_empty()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_returns_a_data_service_with_oauth_token_when_valid_access_token_exist()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$this->token_mock
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Wearepixel\QuickBooks;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Wearepixel\QuickBooks\Stubs\User;
|
||||
|
||||
/**
|
||||
@@ -18,21 +19,17 @@ protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = new User();
|
||||
$this->user = new User;
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_can_be_constructed()
|
||||
{
|
||||
$this->assertInstanceOf(User::class, $this->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_has_a_hasOne_relationship_to_token()
|
||||
#[Test]
|
||||
public function it_has_a_has_one_relationship_to_token()
|
||||
{
|
||||
$this->assertInstanceOf(Token::class, $this->user->quickBooksToken()->getModel());
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use Illuminate\Session\Store;
|
||||
use Mockery;
|
||||
use Mockery\Mock;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use QuickBooksOnline\API\DataService\DataService;
|
||||
use Wearepixel\QuickBooks\Client as QuickBooks;
|
||||
use Wearepixel\QuickBooks\TestCase;
|
||||
@@ -50,6 +51,11 @@ class ControllerTest extends TestCase
|
||||
*/
|
||||
protected $session_mock;
|
||||
|
||||
/**
|
||||
* @var Mock
|
||||
*/
|
||||
protected $url_generator_mock;
|
||||
|
||||
/**
|
||||
* @var Mock
|
||||
*/
|
||||
@@ -67,23 +73,20 @@ protected function setUp(): void
|
||||
$this->redirector_mock = Mockery::mock(Redirector::class);
|
||||
$this->request_mock = Mockery::mock(Request::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_mock = Mockery::mock(View::class);
|
||||
|
||||
$this->controller = new Controller();
|
||||
$this->controller = new Controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_can_be_constructed()
|
||||
{
|
||||
$this->assertInstanceOf(Controller::class, $this->controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_shows_view_to_connect_if_account_not_linked()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_shows_view_to_disconnect_if_account_linked()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_disconnects_from_quickbooks_when_requested()
|
||||
{
|
||||
$this->request_mock
|
||||
@@ -192,12 +191,9 @@ public function it_disconnects_from_quickbooks_when_requested()
|
||||
$this->assertInstanceOf(RedirectResponse::class, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
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);
|
||||
|
||||
$this->quickbooks_mock
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Mockery;
|
||||
use Mockery\Mock;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Wearepixel\QuickBooks\Client as QuickBooks;
|
||||
use Wearepixel\QuickBooks\TestCase;
|
||||
|
||||
@@ -62,17 +63,13 @@ protected function setUp(): void
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_can_be_constructed()
|
||||
{
|
||||
$this->assertInstanceOf(Filter::class, $this->filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_just_passes_the_request_to_the_next_middleware_if_account_linked_to_quickbooks()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_redirects_to_quickbooks_connect_route_after_setting_intended_session_if_account_not_linked()
|
||||
{
|
||||
$this->request_mock
|
||||
|
||||
+14
-37
@@ -5,6 +5,7 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use QuickBooksOnline\API\Core\OAuth\OAuth2\OAuth2AccessToken;
|
||||
use Wearepixel\QuickBooks\Stubs\TokenStub;
|
||||
use Wearepixel\QuickBooks\Stubs\User;
|
||||
@@ -21,52 +22,40 @@ class TokenTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->token = new TokenStub();
|
||||
$this->token = new TokenStub;
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_can_be_constructed()
|
||||
{
|
||||
$this->assertInstanceOf(Token::class, $this->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_has_accessor_for_valid_access_token()
|
||||
{
|
||||
$this->assertNotNull($this->token->getHasValidAccessTokenAttribute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_has_accessor_for_valid_refresh_token()
|
||||
{
|
||||
$this->assertNotNull($this->token->getHasValidRefreshTokenAttribute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_knows_that_the_access_token_expires_at_has_to_be_valid()
|
||||
{
|
||||
$this->assertFalse($this->token->getHasValidAccessTokenAttribute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_knows_that_the_refresh_token_expires_at_has_to_be_valid()
|
||||
{
|
||||
$this->assertFalse($this->token->getHasValidRefreshTokenAttribute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_know_if_access_token_expires_at_is_less_than_now_it_is_not_expired()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_know_if_refresh_token_expires_at_is_less_than_now_it_is_not_expired()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_know_if_access_token_expires_at_is_greater_than_or_equal_to_now_it_is_expired()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_know_if_refresh_token_expires_at_is_greater_than_or_equal_to_now_it_is_expired()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_stores_the_oauth_token_parts_in_expected_properties()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_allows_itself_to_be_deleted_and_returns_new_token()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function it_get_related_user_model_from_configuration()
|
||||
{
|
||||
$this->assertInstanceOf(User::class, $this->token->user()->getModel());
|
||||
|
||||
Reference in New Issue
Block a user