-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixing stuff and replacing files lost in rebase * Fixing namespace test
- Loading branch information
1 parent
e0eea00
commit f4d2ede
Showing
8 changed files
with
192 additions
and
452 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Commands\Generators; | ||
|
||
use CodeIgniter\CLI\BaseCommand; | ||
use CodeIgniter\CLI\GeneratorTrait; | ||
|
||
/** | ||
* Generates a skeleton command file. | ||
*/ | ||
class TestGenerator extends BaseCommand | ||
{ | ||
use GeneratorTrait; | ||
|
||
/** | ||
* The Command's Group | ||
* | ||
* @var string | ||
*/ | ||
protected $group = 'Generators'; | ||
|
||
/** | ||
* The Command's Name | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'make:test'; | ||
|
||
/** | ||
* The Command's Description | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Generates a new test file.'; | ||
|
||
/** | ||
* The Command's Usage | ||
* | ||
* @var string | ||
*/ | ||
protected $usage = 'make:test <name> [options]'; | ||
|
||
/** | ||
* The Command's Arguments | ||
* | ||
* @var array<string, string> | ||
*/ | ||
protected $arguments = [ | ||
'name' => 'The command class name.', | ||
]; | ||
|
||
/** | ||
* The Command's Options | ||
* | ||
* @var array<string, string> | ||
*/ | ||
protected $options = [ | ||
'--namespace' => 'Set root namespace. Default: "APP_NAMESPACE".', | ||
'--force' => 'Force overwrite existing file.', | ||
]; | ||
|
||
/** | ||
* Actually execute a command. | ||
*/ | ||
public function run(array $params) | ||
{ | ||
$this->component = 'Test'; | ||
$this->template = 'test.tpl.php'; | ||
$this->namespace = 'Tests'; | ||
|
||
$this->classNameLang = 'CLI.generator.className.test'; | ||
$this->generateClass($params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<@php | ||
|
||
namespace {namespace}; | ||
|
||
use CodeIgniter\Test\CIUnitTestCase; | ||
|
||
class {class} extends CIUnitTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
public function testExample(): void | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Commands; | ||
|
||
use CodeIgniter\Test\CIUnitTestCase; | ||
use CodeIgniter\Test\StreamFilterTrait; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @group Others | ||
*/ | ||
final class TestGeneratorTest extends CIUnitTestCase | ||
{ | ||
use StreamFilterTrait; | ||
|
||
protected function tearDown(): void | ||
{ | ||
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', $this->getStreamFilterBuffer()); | ||
$file = str_replace('ROOTPATH' . DIRECTORY_SEPARATOR, ROOTPATH, trim(substr($result, 14))); | ||
$dir = dirname($file); | ||
if (is_file($file)) { | ||
unlink($file); | ||
} | ||
if (is_dir($dir)) { | ||
rmdir($dir); | ||
} | ||
} | ||
|
||
public function testGenerateTest(): void | ||
{ | ||
command('make:test Foo/Bar'); | ||
$this->assertFileExists(ROOTPATH . 'tests/Foo/Bar.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters