Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Avoid using FQCN #817

Merged
merged 1 commit into from Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ShopifyApp/Actions/AuthorizeShop.php
Expand Up @@ -2,6 +2,7 @@

namespace Osiset\ShopifyApp\Actions;

use Exception;
use Osiset\ShopifyApp\Contracts\Commands\Shop as IShopCommand;
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
use function Osiset\ShopifyApp\getShopifyConfig;
Expand Down Expand Up @@ -106,7 +107,7 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): stdClass
$this->shopSession->setAccess($apiHelper->getAccessData($code));
$return['url'] = null;
$return['completed'] = true;
} catch (\Exception $e) {
} catch (Exception $e) {
// Just return the default setting
}

Expand Down
5 changes: 3 additions & 2 deletions tests/Actions/AfterAuthorizeTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Osiset\ShopifyApp\Test\Actions;

use App\Jobs\AfterAuthorizeJob;
use Illuminate\Support\Facades\Queue;
use Osiset\ShopifyApp\Actions\AfterAuthorize;
use Osiset\ShopifyApp\Test\TestCase;
Expand All @@ -28,7 +29,7 @@ public function testRunDispatch(): void
Queue::fake();

// Create the config
$jobClass = \App\Jobs\AfterAuthorizeJob::class;
$jobClass = AfterAuthorizeJob::class;
$this->app['config']->set('shopify-app.after_authenticate_job', [
[
'job' => $jobClass,
Expand All @@ -55,7 +56,7 @@ public function testRunDispatch(): void
public function testRunInline(): void
{
// Create the config
$jobClass = \App\Jobs\AfterAuthorizeJob::class;
$jobClass = AfterAuthorizeJob::class;
$this->app['config']->set('shopify-app.after_authenticate_job', [
'job' => $jobClass,
'inline' => true,
Expand Down
3 changes: 2 additions & 1 deletion tests/HelpersTest.php
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\Facades\Config;
use LogicException;
use Osiset\ShopifyApp\Test\TestCase;
use stdClass;

class HelpersTest extends TestCase
{
Expand Down Expand Up @@ -46,7 +47,7 @@ public function testRegisterPackageRoutes(): void
$this->assertFalse(registerPackageRoute('home', $routes));

$this->expectExceptionObject(new LogicException('Excluded routes must be an array', 0));
registerPackageRoute('home', \stdClass::class);
registerPackageRoute('home', stdClass::class);
}

public function testRouteNames(): void
Expand Down
34 changes: 23 additions & 11 deletions tests/Stubs/Kernel.php
Expand Up @@ -2,6 +2,18 @@

namespace Osiset\ShopifyApp\Test\Stubs;

use Illuminate\Auth\Middleware\Authenticate;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Orchestra\Testbench\Http\Middleware\RedirectIfAuthenticated;
use Osiset\ShopifyApp\Http\Middleware\AuthProxy;
use Osiset\ShopifyApp\Http\Middleware\AuthShopify;
use Osiset\ShopifyApp\Http\Middleware\AuthToken;
use Osiset\ShopifyApp\Http\Middleware\AuthWebhook;
use Osiset\ShopifyApp\Http\Middleware\Billable;

class Kernel extends \Orchestra\Testbench\Http\Kernel
{
/**
Expand All @@ -12,18 +24,18 @@ class Kernel extends \Orchestra\Testbench\Http\Kernel
* @var array
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'bindings' => SubstituteBindings::class,
'can' => Authorize::class,
'guest' => RedirectIfAuthenticated::class,
'throttle' => ThrottleRequests::class,

// Added for testing
'auth.shopify' => \Osiset\ShopifyApp\Http\Middleware\AuthShopify::class,
'auth.token' => \Osiset\ShopifyApp\Http\Middleware\AuthToken::class,
'auth.webhook' => \Osiset\ShopifyApp\Http\Middleware\AuthWebhook::class,
'auth.proxy' => \Osiset\ShopifyApp\Http\Middleware\AuthProxy::class,
'billable' => \Osiset\ShopifyApp\Http\Middleware\Billable::class,
'auth.shopify' => AuthShopify::class,
'auth.token' => AuthToken::class,
'auth.webhook' => AuthWebhook::class,
'auth.proxy' => AuthProxy::class,
'billable' => Billable::class,
];
}
4 changes: 3 additions & 1 deletion tests/TestCase.php
Expand Up @@ -3,12 +3,14 @@
namespace Osiset\ShopifyApp\Test;

use Closure;
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
use Illuminate\Support\Facades\App;
use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use Osiset\BasicShopifyAPI\Options;
use Osiset\ShopifyApp\ShopifyAppProvider;
use Osiset\ShopifyApp\Test\Stubs\Api as ApiStub;
use Osiset\ShopifyApp\Test\Stubs\Kernel as StubKernel;
use Osiset\ShopifyApp\Test\Stubs\User as UserStub;

abstract class TestCase extends OrchestraTestCase
Expand Down Expand Up @@ -39,7 +41,7 @@ protected function getPackageProviders($app): array
protected function resolveApplicationHttpKernel($app): void
{
// For adding custom the shop middleware
$app->singleton(\Illuminate\Contracts\Http\Kernel::class, \Osiset\ShopifyApp\Test\Stubs\Kernel::class);
$app->singleton(HttpKernelContract::class, StubKernel::class);
}

protected function getEnvironmentSetUp($app): void
Expand Down
6 changes: 4 additions & 2 deletions tests/Traits/WebhookControllerTest.php
Expand Up @@ -2,9 +2,11 @@

namespace Osiset\ShopifyApp\Test\Controllers;

use App\Jobs\OrdersCreateJob;
use Illuminate\Support\Facades\Queue;
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
use Osiset\ShopifyApp\Test\TestCase;
use stdClass;

require_once __DIR__.'/../Stubs/OrdersCreateJob.php';

Expand Down Expand Up @@ -36,9 +38,9 @@ public function testSuccess(): void

// Check it was created and job was pushed
$response->assertStatus(201);
Queue::assertPushed(\App\Jobs\OrdersCreateJob::class, function ($job) use ($shop) {
Queue::assertPushed(OrdersCreateJob::class, function ($job) use ($shop) {
return ShopDomain::fromNative($job->shopDomain)->isSame($shop->getDomain())
&& $job->data instanceof \stdClass
&& $job->data instanceof stdClass
&& $job->data->email === 'jon@doe.ca';
});
}
Expand Down