using composer package format, decoupling bsr libraries and implementation
This commit is contained in:
54
vendor/pds/skeleton/tests/ComplianceValidatorTest.php
vendored
Normal file
54
vendor/pds/skeleton/tests/ComplianceValidatorTest.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace Pds\Skeleton;
|
||||
|
||||
class ComplianceValidatorTest
|
||||
{
|
||||
public $numErrors = 0;
|
||||
|
||||
public static function run()
|
||||
{
|
||||
$tester = new ComplianceValidatorTest();
|
||||
$tester->testValidate_WithIncorrectBin_ReturnsIncorrectBin();
|
||||
echo __CLASS__ . " errors: {$tester->numErrors}" . PHP_EOL;
|
||||
}
|
||||
|
||||
public function testValidate_WithIncorrectBin_ReturnsIncorrectBin()
|
||||
{
|
||||
$paths = [
|
||||
'cli/',
|
||||
'src/',
|
||||
];
|
||||
|
||||
$validator = new ComplianceValidator();
|
||||
$results = $validator->validate($paths);
|
||||
|
||||
foreach ($results as $expected => $result) {
|
||||
if ($expected == "bin/") {
|
||||
if ($result['state'] != ComplianceValidator::STATE_INCORRECT_PRESENT) {
|
||||
$this->numErrors++;
|
||||
echo __FUNCTION__ . ": Expected state of {$result['expected']} to be STATE_INCORRECT_PRESENT" . PHP_EOL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($expected == "src/") {
|
||||
if ($result['state'] != ComplianceValidator::STATE_CORRECT_PRESENT) {
|
||||
$this->numErrors++;
|
||||
echo __FUNCTION__ . ": Expected state of {$result['expected']} to be STATE_CORRECT_PRESENT" . PHP_EOL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($expected == "LICENSE") {
|
||||
if ($result['state'] != ComplianceValidator::STATE_RECOMMENDED_NOT_PRESENT) {
|
||||
$this->numErrors++;
|
||||
echo __FUNCTION__ . ": Expected state of {$result['expected']} to be STATE_RECOMMENDED_NOT_PRESENT" . PHP_EOL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($result['state'] != ComplianceValidator::STATE_OPTIONAL_NOT_PRESENT) {
|
||||
$this->numErrors++;
|
||||
echo __FUNCTION__ . ": Expected state of {$result['expected']} to be STATE_OPTIONAL_NOT_PRESENT" . PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
vendor/pds/skeleton/tests/PackageGeneratorTest.php
vendored
Normal file
41
vendor/pds/skeleton/tests/PackageGeneratorTest.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
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 = [
|
||||
'bin/' => [
|
||||
'state' => ComplianceValidator::STATE_OPTIONAL_NOT_PRESENT,
|
||||
'expected' => 'bin/',
|
||||
],
|
||||
'config/' => [
|
||||
'state' => ComplianceValidator::STATE_INCORRECT_PRESENT,
|
||||
'expected' => 'config/',
|
||||
],
|
||||
];
|
||||
|
||||
$generator = new PackageGenerator();
|
||||
$files = $generator->createFileList($validatorResults);
|
||||
|
||||
if (!array_key_exists('bin/', $files)) {
|
||||
$this->numErrors++;
|
||||
echo __FUNCTION__ . ": Expected bin/ to be present" . PHP_EOL;
|
||||
}
|
||||
|
||||
if (array_key_exists('config/', $files)) {
|
||||
$this->numErrors++;
|
||||
echo __FUNCTION__ . ": Expected config/ to be absent" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user