Skip to content

Commit 7f4a978

Browse files
author
Paul M. Jones
committed
add test-runner command
1 parent e3f7248 commit 7f4a978

File tree

4 files changed

+32
-45
lines changed

4 files changed

+32
-45
lines changed

src/Console.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
2-
32
namespace Pds\Skeleton;
43

54
class Console
65
{
76
protected $commandsWhitelist = [
87
'validate' => 'Pds\Skeleton\ComplianceValidator',
98
'generate' => 'Pds\Skeleton\PackageGenerator',
9+
'test' => 'Pds\Skeleton\TestRunner',
1010
];
1111

1212
public function execute($args)
@@ -19,7 +19,7 @@ public function execute($args)
1919
if (array_key_exists($commandName, $this->commandsWhitelist)) {
2020
return $this->executeCommand($this->commandsWhitelist[$commandName], $args);
2121
}
22-
22+
2323
$this->outputHelp();
2424
return false;
2525
}
@@ -38,7 +38,7 @@ protected function outputHelp()
3838
{
3939
echo 'Available commands:' . PHP_EOL;
4040
foreach ($this->commandsWhitelist as $key => $value) {
41-
echo 'pdsskeleton ' . $key . PHP_EOL;
41+
echo 'pds-skeleton ' . $key . PHP_EOL;
4242
}
4343
}
44-
}
44+
}

src/TestRunner.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
namespace Pds\Skeleton;
3+
4+
class TestRunner
5+
{
6+
public function execute()
7+
{
8+
ComplianceValidatorTest::run();
9+
PackageGeneratorTest::run();
10+
}
11+
}

tests/ComplianceValidatorTest.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
<?php
2-
3-
$autoloadFiles = [
4-
__DIR__ . '/../vendor/autoload.php',
5-
__DIR__ . '/../../../autoload.php'
6-
];
7-
8-
foreach ($autoloadFiles as $autoloadFile) {
9-
if (file_exists($autoloadFile)) {
10-
require_once $autoloadFile;
11-
break;
12-
}
13-
}
14-
15-
use Pds\Skeleton\ComplianceValidator;
16-
17-
$tester = new ComplianceValidatorTest();
18-
// Test all 4 possible states.
19-
$tester->testValidate_WithIncorrectBin_ReturnsIncorrectBin();
20-
$tester->testValidate_WithoutVendor_ReturnsMissingVendor();
21-
22-
echo "Errors: {$tester->numErrors}" . PHP_EOL;
2+
namespace Pds\Skeleton;
233

244
class ComplianceValidatorTest
255
{
266
public $numErrors = 0;
277

8+
public static function run()
9+
{
10+
$tester = new ComplianceValidatorTest();
11+
$tester->testValidate_WithIncorrectBin_ReturnsIncorrectBin();
12+
$tester->testValidate_WithoutVendor_ReturnsMissingVendor();
13+
echo __CLASS__ . " errors: {$tester->numErrors}" . PHP_EOL;
14+
}
15+
2816
public function testValidate_WithIncorrectBin_ReturnsIncorrectBin()
2917
{
3018
$paths = [

tests/PackageGeneratorTest.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
<?php
2-
3-
$autoloadFiles = [
4-
__DIR__ . '/../vendor/autoload.php',
5-
__DIR__ . '/../../../autoload.php'
6-
];
7-
8-
foreach ($autoloadFiles as $autoloadFile) {
9-
if (file_exists($autoloadFile)) {
10-
require_once $autoloadFile;
11-
break;
12-
}
13-
}
14-
15-
use Pds\Skeleton\ComplianceValidator;
16-
use Pds\Skeleton\PackageGenerator;
17-
18-
$tester = new PackageGeneratorTest();
19-
$tester->testGenerate_WithMissingBin_ReturnsBin();
20-
21-
echo "Errors: {$tester->numErrors}" . PHP_EOL;
2+
namespace Pds\Skeleton;
223

234
class PackageGeneratorTest
245
{
256
public $numErrors = 0;
267

8+
public static function run()
9+
{
10+
$tester = new PackageGeneratorTest();
11+
$tester->testGenerate_WithMissingBin_ReturnsBin();
12+
echo __CLASS__ . " errors: {$tester->numErrors}" . PHP_EOL;
13+
}
14+
2715
public function testGenerate_WithMissingBin_ReturnsBin()
2816
{
2917
$validatorResults = [

0 commit comments

Comments
 (0)