service = $this->createMock(OrderAdminService::class); $this->controller = new ShopOrderController($this->service); } public function testConstructorAcceptsService(): void { $controller = new ShopOrderController($this->service); $this->assertInstanceOf(ShopOrderController::class, $controller); } public function testHasExpectedActionMethods(): void { $this->assertTrue(method_exists($this->controller, 'list')); $this->assertTrue(method_exists($this->controller, 'view_list')); $this->assertTrue(method_exists($this->controller, 'details')); $this->assertTrue(method_exists($this->controller, 'order_details')); $this->assertTrue(method_exists($this->controller, 'edit')); $this->assertTrue(method_exists($this->controller, 'order_edit')); $this->assertTrue(method_exists($this->controller, 'save')); $this->assertTrue(method_exists($this->controller, 'order_save')); $this->assertTrue(method_exists($this->controller, 'notes_save')); $this->assertTrue(method_exists($this->controller, 'order_status_change')); $this->assertTrue(method_exists($this->controller, 'order_resend_confirmation_email')); $this->assertTrue(method_exists($this->controller, 'set_order_as_unpaid')); $this->assertTrue(method_exists($this->controller, 'set_order_as_paid')); $this->assertTrue(method_exists($this->controller, 'send_order_to_apilo')); $this->assertTrue(method_exists($this->controller, 'toggle_trustmate_send')); $this->assertTrue(method_exists($this->controller, 'delete')); $this->assertTrue(method_exists($this->controller, 'order_delete')); } public function testViewActionsReturnString(): void { $reflection = new \ReflectionClass($this->controller); $this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('view_list')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('details')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('order_details')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('edit')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('order_edit')->getReturnType()); } public function testMutationActionsReturnVoid(): void { $reflection = new \ReflectionClass($this->controller); $this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('order_save')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('notes_save')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('order_status_change')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('order_resend_confirmation_email')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('set_order_as_unpaid')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('set_order_as_paid')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('send_order_to_apilo')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('toggle_trustmate_send')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('delete')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('order_delete')->getReturnType()); } public function testConstructorRequiresOrderAdminService(): void { $reflection = new \ReflectionClass(ShopOrderController::class); $constructor = $reflection->getConstructor(); $params = $constructor->getParameters(); $this->assertCount(1, $params); $this->assertEquals('Domain\\Order\\OrderAdminService', $params[0]->getType()->getName()); } }