From 1e8183066c8a224899fcfb5b39aa5ee7c6f797cf Mon Sep 17 00:00:00 2001 From: Rougin Royce Gutib Date: Fri, 16 Sep 2016 19:22:30 +0800 Subject: [PATCH] Fix issues in unit testing --- src/Common/Config.php | 2 +- tests/Commands/CreateLayoutCommandTest.php | 10 ++++------ tests/Commands/CreateModelCommandTest.php | 2 +- tests/Commands/CreateViewCommandTest.php | 4 +--- tests/ValidatorTest.php | 16 ++++------------ 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/Common/Config.php b/src/Common/Config.php index f7353eb..9e9a0a0 100644 --- a/src/Common/Config.php +++ b/src/Common/Config.php @@ -60,7 +60,7 @@ public function get($item, $line, $dataType) break; case 'boolean': - $value = '(TRUE|FALSE)'; + $value = '(true|TRUE|false|FALSE)'; break; case 'string': diff --git a/tests/Commands/CreateLayoutCommandTest.php b/tests/Commands/CreateLayoutCommandTest.php index e8daf8f..59dab9a 100644 --- a/tests/Commands/CreateLayoutCommandTest.php +++ b/tests/Commands/CreateLayoutCommandTest.php @@ -44,7 +44,7 @@ public function testFilesExist() CodeIgniterHelper::setDefaults($this->appPath); $command = new CommandTester($this->command); - $command->execute([ '--bootstrap' => true]); + $command->execute([ '--bootstrap' => true ]); $header = $this->appPath . '/views/layout/header.php'; $footer = $this->appPath . '/views/layout/footer.php'; @@ -64,12 +64,10 @@ public function testFolderExists() { $command = new CommandTester($this->command); - $command->execute([ '--bootstrap' => true]); - $command->execute([ '--bootstrap' => true]); + $command->execute([ '--bootstrap' => true ]); + $command->execute([ '--bootstrap' => true ]); - $message = 'The layout directory already exists!' . PHP_EOL; - - $this->assertEquals($message, $command->getDisplay()); + $this->assertRegExp('/layout directory already exists/', $command->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); } diff --git a/tests/Commands/CreateModelCommandTest.php b/tests/Commands/CreateModelCommandTest.php index 8428da0..d8468fa 100644 --- a/tests/Commands/CreateModelCommandTest.php +++ b/tests/Commands/CreateModelCommandTest.php @@ -113,7 +113,7 @@ public function testNoLibraryInstalled() $expected = 'Please install Wildfire or Doctrine!' . PHP_EOL; - $this->assertEquals($expected, $createCommand->getDisplay()); + $this->assertRegExp('/Please install Wildfire or Doctrine/', $createCommand->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); } diff --git a/tests/Commands/CreateViewCommandTest.php b/tests/Commands/CreateViewCommandTest.php index cf46c18..cde86eb 100644 --- a/tests/Commands/CreateViewCommandTest.php +++ b/tests/Commands/CreateViewCommandTest.php @@ -92,9 +92,7 @@ public function testFolderAlreadyExists() $createCommand = new CommandTester($this->createCommand); $createCommand->execute($options); - $expected = 'The "' . plural($this->table) . '" views folder already exists!' . PHP_EOL; - - $this->assertEquals($expected, $createCommand->getDisplay()); + $this->assertRegExp('/views folder already exists/', $createCommand->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); } diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index b4ecf16..876daed 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -56,9 +56,7 @@ public function testNoLibraryInstalled() '--keep' => true ]); - $expected = 'Please install Wildfire or Doctrine!' . PHP_EOL; - - $this->assertEquals($expected, $createCommand->getDisplay()); + $this->assertRegExp('/Please install Wildfire or Doctrine/', $createCommand->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); } @@ -92,9 +90,7 @@ public function testNoLibrarySelected() '--keep' => false ]); - $expected = 'Both Wildfire and Doctrine exists! Choose only one.' . PHP_EOL; - - $this->assertEquals($expected, $createCommand->getDisplay()); + $this->assertRegExp('/Choose only one/', $createCommand->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); } @@ -128,9 +124,7 @@ public function testFileExists() '--keep' => true ]); - $expected = 'The "' . ucfirst($this->table) . '" controller already exists!' . PHP_EOL; - - $this->assertEquals($expected, $createCommand->getDisplay()); + $this->assertRegExp('/controller already exists/', $createCommand->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); } @@ -157,9 +151,7 @@ public function testWildfireCamelCasing() '--keep' => true ]); - $expected = 'Wildfire does not support camel casing!' . PHP_EOL; - - $this->assertEquals($expected, $createCommand->getDisplay()); + $this->assertRegExp('/not support camel casing/', $createCommand->getDisplay()); CodeIgniterHelper::setDefaults($this->appPath); }