app = APP . DS . 'Application.php'; $this->originalAppContent = file_get_contents($this->app); $this->setAppNamespace(); } /** * tearDown method */ public function tearDown(): void { parent::tearDown(); file_put_contents($this->app, $this->originalAppContent); } /** * Test generating help succeeds */ public function testHelp(): void { $this->exec('plugin load --help'); $this->assertExitCode(CommandInterface::CODE_SUCCESS); $this->assertOutputContains('plugin load'); } /** * Test loading a plugin modifies the app */ public function testLoadModifiesApplication(): void { $this->exec('plugin load TestPlugin'); $this->assertExitCode(CommandInterface::CODE_SUCCESS); $contents = file_get_contents($this->app); $this->assertMatchesRegularExpression('/Check plugins added here\n {8}\$this->addPlugin\(\'TestPlugin\'\);\n {4}\}\n/u', $contents); } /** * Test loading an unknown plugin */ public function testLoadUnknownPlugin(): void { $this->exec('plugin load NopeNotThere'); $this->assertExitCode(CommandInterface::CODE_ERROR); $this->assertErrorContains('Plugin NopeNotThere could not be found'); $contents = file_get_contents($this->app); $this->assertStringNotContainsString("\$this->addPlugin('NopeNotThere');", $contents); } }