From c6fa51e90eabb18db5c4ce8a5956aef90760c82a Mon Sep 17 00:00:00 2001 From: sampoyigi Date: Sat, 10 Aug 2024 12:15:25 +0000 Subject: [PATCH] PHP Linting (Pint) - Fix styling --- src/Cart.php | 2 +- src/CartItem.php | 2 +- src/Extension.php | 2 +- .../Conditions/OrderAttributeTest.php | 14 +++++------ .../Conditions/OrderStatusAttributeTest.php | 4 ++-- .../Events/NewOrderStatusTest.php | 4 ++-- .../Events/OrderAssignedTest.php | 4 ++-- .../Events/OrderPlacedTest.php | 4 ++-- tests/Classes/CartConditionManagerTest.php | 10 ++++---- tests/Classes/CartManagerTest.php | 2 +- tests/Classes/OrderManagerTest.php | 2 +- tests/Classes/OrderTypesTest.php | 14 +++++------ tests/Http/Middleware/CartMiddlewareTest.php | 24 +++++++++---------- tests/Models/CategoryTest.php | 8 +++---- tests/Models/IngredientTest.php | 4 ++-- tests/Models/MenuTest.php | 16 ++++++------- 16 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/Cart.php b/src/Cart.php index 642be3b..ac02aa5 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -652,7 +652,7 @@ protected function createModel() throw new \LogicException(sprintf('Missing model [%s] in %s', $modelClass, get_called_class())); } - return new $modelClass(); + return new $modelClass; } // diff --git a/src/CartItem.php b/src/CartItem.php index 34a4d8d..d5b9812 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -155,7 +155,7 @@ public function hasConditions() public function clearConditions() { - $this->conditions = new CartItemConditions(); + $this->conditions = new CartItemConditions; return $this; } diff --git a/src/Extension.php b/src/Extension.php index 16f74bf..55c97f2 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -130,7 +130,7 @@ public function boot() }); Statistics::registerCards(function() { - return (new RegistersDashboardCards())(); + return (new RegistersDashboardCards)(); }); } diff --git a/tests/AutomationRules/Conditions/OrderAttributeTest.php b/tests/AutomationRules/Conditions/OrderAttributeTest.php index 81ba7f2..038efa8 100644 --- a/tests/AutomationRules/Conditions/OrderAttributeTest.php +++ b/tests/AutomationRules/Conditions/OrderAttributeTest.php @@ -6,7 +6,7 @@ use Igniter\Cart\Models\Order; it('defines model attributes correctly', function() { - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; $attributes = $orderAttribute->defineModelAttributes(); @@ -25,7 +25,7 @@ 'order_time' => Carbon::now()->subHours(5)->toTimeString(), ]); - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; expect($orderAttribute->getHoursSinceAttribute(null, $order))->toBe(5.0); }); @@ -37,7 +37,7 @@ 'order_time' => Carbon::now()->addHours(5)->toTimeString(), ]); - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; expect($orderAttribute->getHoursUntilAttribute(null, $order))->toBe(4.0); }); @@ -49,7 +49,7 @@ 'order_time' => Carbon::now()->toTimeString(), ]); - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; expect($orderAttribute->getDaysSinceAttribute(null, $order))->toBe(3.0); }); @@ -60,13 +60,13 @@ 'order_time' => Carbon::now()->toTimeString(), ]); - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; expect($orderAttribute->getDaysUntilAttribute(null, $order))->toBe(3.0); }); it('gets history status id correctly', function() { - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; $order = Mockery::mock(Order::class); $order->shouldReceive('status_history->pluck')->andReturn(collect([1, 2, 3])); @@ -74,7 +74,7 @@ }); it('throws exception when no order in params', function() { - $orderAttribute = new OrderAttribute(); + $orderAttribute = new OrderAttribute; $this->expectException(\Igniter\Automation\AutomationException::class); diff --git a/tests/AutomationRules/Conditions/OrderStatusAttributeTest.php b/tests/AutomationRules/Conditions/OrderStatusAttributeTest.php index 91dca43..d02ec48 100644 --- a/tests/AutomationRules/Conditions/OrderStatusAttributeTest.php +++ b/tests/AutomationRules/Conditions/OrderStatusAttributeTest.php @@ -6,7 +6,7 @@ use Igniter\Cart\AutomationRules\Conditions\OrderStatusAttribute; it('defines model attributes correctly', function() { - $orderStatusAttribute = new OrderStatusAttribute(); + $orderStatusAttribute = new OrderStatusAttribute; $attributes = $orderStatusAttribute->defineModelAttributes(); @@ -14,7 +14,7 @@ }); it('throws exception when no status in params', function() { - $orderStatusAttribute = new OrderStatusAttribute(); + $orderStatusAttribute = new OrderStatusAttribute; $this->expectException(AutomationException::class); diff --git a/tests/AutomationRules/Events/NewOrderStatusTest.php b/tests/AutomationRules/Events/NewOrderStatusTest.php index 550601d..6838034 100644 --- a/tests/AutomationRules/Events/NewOrderStatusTest.php +++ b/tests/AutomationRules/Events/NewOrderStatusTest.php @@ -7,7 +7,7 @@ use Igniter\Cart\Models\Order; it('has a name and description', function() { - $event = new NewOrderStatus(); + $event = new NewOrderStatus; expect($event->eventDetails())->toHaveKeys(['name', 'description']); }); @@ -31,7 +31,7 @@ expect($params)->toBeArray()->not->toHaveKey('order'); - $params = NewOrderStatus::makeParamsFromEvent([new \stdClass()]); + $params = NewOrderStatus::makeParamsFromEvent([new \stdClass]); expect($params)->toBeArray()->not->toHaveKey('order'); }); diff --git a/tests/AutomationRules/Events/OrderAssignedTest.php b/tests/AutomationRules/Events/OrderAssignedTest.php index 92b2fbc..ead1ba5 100644 --- a/tests/AutomationRules/Events/OrderAssignedTest.php +++ b/tests/AutomationRules/Events/OrderAssignedTest.php @@ -8,7 +8,7 @@ use Igniter\User\Models\User; it('has a name and description', function() { - $event = new OrderAssigned(); + $event = new OrderAssigned; expect($event->eventDetails())->toHaveKeys(['name', 'description']); }); @@ -34,7 +34,7 @@ expect($params)->toBeArray()->not->toHaveKey('order'); - $params = OrderAssigned::makeParamsFromEvent([new \stdClass()]); + $params = OrderAssigned::makeParamsFromEvent([new \stdClass]); expect($params)->toBeArray()->not->toHaveKey('order'); }); diff --git a/tests/AutomationRules/Events/OrderPlacedTest.php b/tests/AutomationRules/Events/OrderPlacedTest.php index b4ea5a8..57ea658 100644 --- a/tests/AutomationRules/Events/OrderPlacedTest.php +++ b/tests/AutomationRules/Events/OrderPlacedTest.php @@ -7,7 +7,7 @@ use Igniter\Cart\Models\Order; it('has a name and description', function() { - $event = new OrderPlaced(); + $event = new OrderPlaced; expect($event->eventDetails())->toHaveKeys(['name', 'description']); }); @@ -31,7 +31,7 @@ expect($params)->toBeArray()->not->toHaveKey('order'); - $params = OrderPlaced::makeParamsFromEvent([new \stdClass()]); + $params = OrderPlaced::makeParamsFromEvent([new \stdClass]); expect($params)->toBeArray()->not->toHaveKey('order'); }); diff --git a/tests/Classes/CartConditionManagerTest.php b/tests/Classes/CartConditionManagerTest.php index f5feddc..54c0113 100644 --- a/tests/Classes/CartConditionManagerTest.php +++ b/tests/Classes/CartConditionManagerTest.php @@ -6,7 +6,7 @@ use Igniter\Cart\Tests\Classes\Fixtures\TestCartCondition; it('makes condition', function() { - $manager = new CartConditionManager(); + $manager = new CartConditionManager; $manager->registerCondition(TestCartCondition::class, [ 'name' => 'testCartCondition', 'label' => 'Test Cart Condition', @@ -19,13 +19,13 @@ }); it('throws exception for unregistered condition', function() { - $manager = new CartConditionManager(); + $manager = new CartConditionManager; expect(fn() => $manager->makeCondition('NonExistentClass'))->toThrow(\LogicException::class); }); it('lists registered conditions', function() { - $manager = new CartConditionManager(); + $manager = new CartConditionManager; $manager->registerCondition(TestCartCondition::class, [ 'name' => 'testCartCondition', 'label' => 'Test Cart Condition', @@ -38,7 +38,7 @@ }); it('loads registered conditions', function() { - $manager = new CartConditionManager(); + $manager = new CartConditionManager; $manager->registerCallback(function($manager) { $manager->registerCondition(TestCartCondition::class, [ 'name' => 'testCartCondition', @@ -54,7 +54,7 @@ }); it('registers conditions', function() { - $manager = new CartConditionManager(); + $manager = new CartConditionManager; $manager->registerConditions([ TestCartCondition::class => [ 'name' => 'testCartCondition', diff --git a/tests/Classes/CartManagerTest.php b/tests/Classes/CartManagerTest.php index 6913c41..29e19cf 100644 --- a/tests/Classes/CartManagerTest.php +++ b/tests/Classes/CartManagerTest.php @@ -16,7 +16,7 @@ $this->location = LocationModel::factory()->create(); resolve('location')->setModel($this->location); - $this->manager = new CartManager(); + $this->manager = new CartManager; }); it('gets cart', function() { diff --git a/tests/Classes/OrderManagerTest.php b/tests/Classes/OrderManagerTest.php index 4219786..929908c 100644 --- a/tests/Classes/OrderManagerTest.php +++ b/tests/Classes/OrderManagerTest.php @@ -20,7 +20,7 @@ resolve('location')->setModel($this->location); $this->customer = Customer::factory()->create(); - $this->manager = new OrderManager(); + $this->manager = new OrderManager; }); it('gets customer id', function() { diff --git a/tests/Classes/OrderTypesTest.php b/tests/Classes/OrderTypesTest.php index 846f0ca..abc5c27 100644 --- a/tests/Classes/OrderTypesTest.php +++ b/tests/Classes/OrderTypesTest.php @@ -8,8 +8,8 @@ use Illuminate\Support\Collection; it('makes order types', function() { - $orderTypes = new OrderTypes(); - $location = new LocationModel(); + $orderTypes = new OrderTypes; + $location = new LocationModel; $result = $orderTypes->makeOrderTypes($location); @@ -17,7 +17,7 @@ }); it('gets order type', function() { - $orderTypes = new OrderTypes(); + $orderTypes = new OrderTypes; $result = $orderTypes->getOrderType('delivery'); @@ -28,7 +28,7 @@ }); it('lists order types', function() { - $orderTypes = new OrderTypes(); + $orderTypes = new OrderTypes; $result = $orderTypes->listOrderTypes(); @@ -36,7 +36,7 @@ }); it('registers order types', function() { - $orderTypes = new OrderTypes(); + $orderTypes = new OrderTypes; $orderTypes->registerOrderTypes([ Delivery::class => ['code' => 'delivery', 'name' => 'Delivery'], @@ -48,7 +48,7 @@ }); it('registers order type', function() { - $orderTypes = new OrderTypes(); + $orderTypes = new OrderTypes; $orderTypes->registerOrderType(Delivery::class, ['code' => 'delivery', 'name' => 'Delivery']); @@ -58,7 +58,7 @@ }); it('registers callback', function() { - $orderTypes = new OrderTypes(); + $orderTypes = new OrderTypes; $orderTypes->registerCallback(function($orderTypes) { $orderTypes->registerOrderType('TestOrderType', ['code' => 'test']); diff --git a/tests/Http/Middleware/CartMiddlewareTest.php b/tests/Http/Middleware/CartMiddlewareTest.php index d6c40ae..ba4e159 100644 --- a/tests/Http/Middleware/CartMiddlewareTest.php +++ b/tests/Http/Middleware/CartMiddlewareTest.php @@ -19,8 +19,8 @@ Location::shouldReceive('getId')->andReturn(1); Cart::shouldReceive('instance')->with('location-1'); - $middleware = new CartMiddleware(); - $response = $middleware->handle(new Request(), function() { + $middleware = new CartMiddleware; + $response = $middleware->handle(new Request, function() { return true; }); @@ -31,8 +31,8 @@ Location::shouldReceive('current')->andReturn(null); Cart::expects('instance')->never(); - $middleware = new CartMiddleware(); - $response = $middleware->handle(new Request(), function() { + $middleware = new CartMiddleware; + $response = $middleware->handle(new Request, function() { return true; }); @@ -49,8 +49,8 @@ Auth::shouldReceive('getUser')->andReturn($userMock); Cart::shouldReceive('store')->with(1); - $middleware = new CartMiddleware(); - expect($middleware->terminate(new Request(), new Response()))->toBeNull(); + $middleware = new CartMiddleware; + expect($middleware->terminate(new Request, new Response))->toBeNull(); }); it('terminates without abandoned cart', function() { @@ -58,8 +58,8 @@ Auth::expects('check')->never(); Cart::expects('store')->never(); - $middleware = new CartMiddleware(); - expect($middleware->terminate(new Request(), new Response()))->toBeNull(); + $middleware = new CartMiddleware; + expect($middleware->terminate(new Request, new Response))->toBeNull(); }); it('terminates with abandoned cart but unauthenticated user', function() { @@ -67,8 +67,8 @@ Auth::shouldReceive('check')->andReturn(false); Cart::expects('content')->never(); - $middleware = new CartMiddleware(); - expect($middleware->terminate(new Request(), new Response()))->toBeNull(); + $middleware = new CartMiddleware; + expect($middleware->terminate(new Request, new Response))->toBeNull(); }); it('terminates with abandoned cart, authenticated user but empty cart', function() { @@ -77,6 +77,6 @@ Cart::shouldReceive('content')->andReturn(collect()); Cart::expects('store')->never(); - $middleware = new CartMiddleware(); - expect($middleware->terminate(new Request(), new Response()))->toBeNull(); + $middleware = new CartMiddleware; + expect($middleware->terminate(new Request, new Response))->toBeNull(); }); diff --git a/tests/Models/CategoryTest.php b/tests/Models/CategoryTest.php index 981e51b..44a47bf 100644 --- a/tests/Models/CategoryTest.php +++ b/tests/Models/CategoryTest.php @@ -37,7 +37,7 @@ }); it('belongs to parent category', function() { - $category = new Category(); + $category = new Category; $relation = $category->parent_cat(); expect($relation->getRelated())->toBeInstanceOf(Category::class) @@ -46,7 +46,7 @@ }); it('belongs to many menus', function() { - $category = new Category(); + $category = new Category; $relation = $category->menus(); expect($relation->getRelated())->toBeInstanceOf(Menu::class) @@ -54,7 +54,7 @@ }); it('morphs to many locations', function() { - $category = new Category(); + $category = new Category; $relation = $category->locations(); expect($relation->getMorphType())->toBe('locationable_type') @@ -90,7 +90,7 @@ }); it('configures category model correctly', function() { - $category = new Category(); + $category = new Category; expect(class_uses_recursive($category)) ->toContain(HasMedia::class) diff --git a/tests/Models/IngredientTest.php b/tests/Models/IngredientTest.php index 612b442..a713c6d 100644 --- a/tests/Models/IngredientTest.php +++ b/tests/Models/IngredientTest.php @@ -22,7 +22,7 @@ }); it('morphs to many menus', function() { - $ingredient = new Ingredient(); + $ingredient = new Ingredient; $relation = $ingredient->menus(); expect($relation->getRelated())->toBeInstanceOf(Menu::class) @@ -30,7 +30,7 @@ }); it('morphs to many menu option values', function() { - $ingredient = new Ingredient(); + $ingredient = new Ingredient; $relation = $ingredient->menu_option_values(); expect($relation->getRelated())->toBeInstanceOf(MenuOptionValue::class) diff --git a/tests/Models/MenuTest.php b/tests/Models/MenuTest.php index cfe0507..33e6c1a 100644 --- a/tests/Models/MenuTest.php +++ b/tests/Models/MenuTest.php @@ -92,14 +92,14 @@ }); it('has many menu_options', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->menu_options(); expect($relation->getRelated())->toBeInstanceOf(MenuItemOption::class); }); it('has one special', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->special(); expect($relation->getRelated())->toBeInstanceOf(MenuSpecial::class) @@ -107,7 +107,7 @@ }); it('belongs to many categories', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->categories(); expect($relation->getRelated())->toBeInstanceOf(Category::class) @@ -115,7 +115,7 @@ }); it('belongs to many mealtimes', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->mealtimes(); expect($relation->getRelated())->toBeInstanceOf(Mealtime::class) @@ -123,7 +123,7 @@ }); it('morphs to many allergens', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->allergens(); expect($relation->getMorphType())->toBe('ingredientable_type') @@ -131,7 +131,7 @@ }); it('morphs to many ingredients', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->ingredients(); expect($relation->getMorphType())->toBe('ingredientable_type') @@ -139,7 +139,7 @@ }); it('morphs to many locations', function() { - $menu = new Menu(); + $menu = new Menu; $relation = $menu->locations(); expect($relation->getMorphType())->toBe('locationable_type') @@ -208,7 +208,7 @@ }); it('configures menu model correctly', function() { - $menu = new Menu(); + $menu = new Menu; expect(class_uses_recursive($menu)) ->toContain(HasMedia::class)