Skip to content

Commit

Permalink
add test-runner command
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed Jan 8, 2017
1 parent e3f7248 commit 7f4a978
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/Console.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Pds\Skeleton;

class Console
{
protected $commandsWhitelist = [
'validate' => 'Pds\Skeleton\ComplianceValidator',
'generate' => 'Pds\Skeleton\PackageGenerator',
'test' => 'Pds\Skeleton\TestRunner',
];

public function execute($args)
Expand All @@ -19,7 +19,7 @@ public function execute($args)
if (array_key_exists($commandName, $this->commandsWhitelist)) {
return $this->executeCommand($this->commandsWhitelist[$commandName], $args);
}

$this->outputHelp();
return false;
}
Expand All @@ -38,7 +38,7 @@ protected function outputHelp()
{
echo 'Available commands:' . PHP_EOL;
foreach ($this->commandsWhitelist as $key => $value) {
echo 'pdsskeleton ' . $key . PHP_EOL;
echo 'pds-skeleton ' . $key . PHP_EOL;
}
}
}
}
11 changes: 11 additions & 0 deletions src/TestRunner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
namespace Pds\Skeleton;

class TestRunner
{
public function execute()
{
ComplianceValidatorTest::run();
PackageGeneratorTest::run();
}
}
30 changes: 9 additions & 21 deletions tests/ComplianceValidatorTest.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
<?php

$autoloadFiles = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php'
];

foreach ($autoloadFiles as $autoloadFile) {
if (file_exists($autoloadFile)) {
require_once $autoloadFile;
break;
}
}

use Pds\Skeleton\ComplianceValidator;

$tester = new ComplianceValidatorTest();
// Test all 4 possible states.
$tester->testValidate_WithIncorrectBin_ReturnsIncorrectBin();
$tester->testValidate_WithoutVendor_ReturnsMissingVendor();

echo "Errors: {$tester->numErrors}" . PHP_EOL;
namespace Pds\Skeleton;

class ComplianceValidatorTest
{
public $numErrors = 0;

public static function run()
{
$tester = new ComplianceValidatorTest();
$tester->testValidate_WithIncorrectBin_ReturnsIncorrectBin();
$tester->testValidate_WithoutVendor_ReturnsMissingVendor();
echo __CLASS__ . " errors: {$tester->numErrors}" . PHP_EOL;
}

public function testValidate_WithIncorrectBin_ReturnsIncorrectBin()
{
$paths = [
Expand Down
28 changes: 8 additions & 20 deletions tests/PackageGeneratorTest.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
<?php

$autoloadFiles = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php'
];

foreach ($autoloadFiles as $autoloadFile) {
if (file_exists($autoloadFile)) {
require_once $autoloadFile;
break;
}
}

use Pds\Skeleton\ComplianceValidator;
use Pds\Skeleton\PackageGenerator;

$tester = new PackageGeneratorTest();
$tester->testGenerate_WithMissingBin_ReturnsBin();

echo "Errors: {$tester->numErrors}" . PHP_EOL;
namespace Pds\Skeleton;

class PackageGeneratorTest
{
public $numErrors = 0;

public static function run()
{
$tester = new PackageGeneratorTest();
$tester->testGenerate_WithMissingBin_ReturnsBin();
echo __CLASS__ . " errors: {$tester->numErrors}" . PHP_EOL;
}

public function testGenerate_WithMissingBin_ReturnsBin()
{
$validatorResults = [
Expand Down

0 comments on commit 7f4a978

Please sign in to comment.