Skip to content

Commit

Permalink
Generate integration tests using command parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliodeg authored and niden committed May 24, 2019
1 parent 5ce57b8 commit 86075c0
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions tests/_ci/generate-test-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
* file that was distributed with this source code.
*/
namespace Phalcon\Test\Unit\%n%;
namespace Phalcon\Test\%type%\%n%;
use UnitTester;
use %type%Tester;
class %m%Cest
{
/**
* Tests %ns% :: %sm%()
* %type% Tests %ns% :: %sm%()
*
* @author Phalcon Team <team@phalconphp.com>
* @since %d%
*/
public function %nn%%m%(UnitTester $I)
public function %nn%%m%(%type%Tester $I)
{
$I->wantToTest(\'%n% - %sm%()\');
Expand All @@ -52,13 +52,22 @@ public function %nn%%m%(UnitTester $I)
}
}

// Argument 1: could be "unit" or "integration" shortcut "u" or "i"
$type = ucfirst($argv[1] ?? 'unit');

// Normalize shortcut I = Integration or U = Unit
if (strlen($type) === 1) {
$type = $type === 'I' ? 'Integration' : 'Unit';
}

$placeholders = [
'%ns%' => '',
'%nn%' => '',
'%n%' => '',
'%m%' => '',
'%sm%' => '',
'%d%' => date('Y-m-d'),
'%type%' => $type,
'%ns%' => '',
'%nn%' => '',
'%n%' => '',
'%m%' => '',
'%sm%' => '',
'%d%' => date('Y-m-d'),
];

$outputDir = dirname(__DIR__) . '/nikos/';
Expand Down

0 comments on commit 86075c0

Please sign in to comment.