mockRepository = $this->createMock(LanguagesRepository::class); $this->controller = new LanguagesController($this->mockRepository); } public function testConstructorAcceptsRepository(): void { $controller = new LanguagesController($this->mockRepository); $this->assertInstanceOf(LanguagesController::class, $controller); } public function testHasMainActionMethods(): void { $this->assertTrue(method_exists($this->controller, 'list')); $this->assertTrue(method_exists($this->controller, 'view_list')); $this->assertTrue(method_exists($this->controller, 'language_edit')); $this->assertTrue(method_exists($this->controller, 'language_save')); $this->assertTrue(method_exists($this->controller, 'language_delete')); $this->assertTrue(method_exists($this->controller, 'translation_list')); $this->assertTrue(method_exists($this->controller, 'translation_edit')); $this->assertTrue(method_exists($this->controller, 'translation_save')); $this->assertTrue(method_exists($this->controller, 'translation_delete')); } public function testActionMethodReturnTypes(): 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('language_edit')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('language_save')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('language_delete')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('translation_list')->getReturnType()); $this->assertEquals('string', (string)$reflection->getMethod('translation_edit')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('translation_save')->getReturnType()); $this->assertEquals('void', (string)$reflection->getMethod('translation_delete')->getReturnType()); } public function testConstructorRequiresLanguagesRepository(): void { $reflection = new \ReflectionClass(LanguagesController::class); $constructor = $reflection->getConstructor(); $params = $constructor->getParameters(); $this->assertCount(1, $params); $this->assertEquals('Domain\Languages\LanguagesRepository', $params[0]->getType()->getName()); } }