Skip to content

Commit

Permalink
Merge pull request #2 from Sweetchuck/acceptance-tests
Browse files Browse the repository at this point in the history
Add acceptance tests
  • Loading branch information
Sweetchuck authored Jan 21, 2021
2 parents ea79bbc + 354c0fe commit 37fcab6
Show file tree
Hide file tree
Showing 15 changed files with 426 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ commands:
- codecov/upload:
flags: 'unit'
file: './tests/_output/machine/coverage/unit/coverage.xml'
-
run:
name: 'Codeception - acceptance'
command: 'bin/robo --ansi test acceptance'
- codecov/upload:
flags: 'unit'
file: './tests/_output/machine/coverage/acceptance/coverage.xml'
- store_test_results:
name: 'Store unit test results'
path: './tests/_output/machine/junit'
Expand Down
7 changes: 0 additions & 7 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,6 @@ protected function getTaskPhpcsLint()
return $this->taskPhpcsLintFiles($options);
}

protected function isPhpDbgAvailable(): bool
{
$command = [$this->getPhpdbgExecutable(), '-qrr'];

return (new Process($command))->run() === 0;
}

protected function getLogDir(): string
{
$this->initCodeceptionInfo();
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"require-dev": {
"codeception/codeception": "^4.0",
"codeception/module-asserts": "^1.1",
"codeception/module-cli": "^1.1",
"codeception/module-filesystem": "^1.0",
"composer/composer": "^2.0",
"mikey179/vfsstream": "^1.6",
"nuvoleweb/robo-config": "2.x-dev",
Expand All @@ -54,6 +56,7 @@
"autoload-dev": {
"psr-4": {
"Sweetchuck\\ComposerSuite\\Test\\": "tests/_support/",
"Sweetchuck\\ComposerSuite\\Tests\\Acceptance\\": "tests/acceptance/",
"Sweetchuck\\ComposerSuite\\Tests\\Unit\\": "tests/unit/"
}
},
Expand Down
101 changes: 100 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/Composer/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
namespace Sweetchuck\ComposerSuite\Composer\Command;

use Composer\Factory as ComposerFactory;
use Composer\Package\Dumper\ArrayDumper;
use Sweetchuck\ComposerSuite\Composer\Plugin;
use Symfony\Component\Console\Input\InputOption;

class GenerateCommand extends CommandBase
{
Expand Down Expand Up @@ -47,7 +45,7 @@ protected function doIt()
if (in_array($action, ['create', 'update'])) {
$this->fs->dumpFile(
$suiteFileName,
$this->suiteHandler->encode($suiteData),
$this->suiteHandler->encode($suiteData) . "\n",
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ protected function onCommandEventValidate(): bool

switch ($whatToDo) {
case 'create':
$this->io->error("<error>{$pluginName} - {$newFileName} is is not exists</error>");
$this->io->error("<error>{$pluginName} - {$newFileName} is not exists</error>");
break;

case 'update':
$this->io->error("<error>{$pluginName} - {$newFileName} is is not up to date</error>");
$this->io->error("<error>{$pluginName} - {$newFileName} is not up to date</error>");
break;
}

Expand Down
13 changes: 11 additions & 2 deletions src/SuiteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ public function collectSuiteComposerFiles(string $composerFile): array
Path::getFilename($composerFile),
);

$projectRoot = Path::getDirectory($composerFile) ?: '.';

$files = (new Finder())
->in(Path::getDirectory($composerFile))
->in($projectRoot)
->files()
->name(sprintf('/^%s\.[^\.]+\.json$/', $base))
->depth(0);
Expand Down Expand Up @@ -320,7 +322,14 @@ protected function actionSortNormal(&$data, array $config)
);

if (!in_array($config['function'], $this->allowedSortNormalFunctions)) {
throw new \InvalidArgumentException('@todo', 1);
throw new \InvalidArgumentException(
sprintf(
'invalid sortNormal function: %s; allowed values: %s',
$config['function'],
implode(', ', $this->allowedSortNormalFunctions),
),
1,
);
}

$sub =& NestedArray::getValue($data, $config['parents']);
Expand Down
31 changes: 31 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types = 1);

namespace Sweetchuck\ComposerSuite\Test;

use Codeception\Actor;

/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
}
11 changes: 11 additions & 0 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types = 1);

namespace Sweetchuck\ComposerSuite\Test\Helper;

use Codeception\Module;

class Acceptance extends Module
{
}
2 changes: 2 additions & 0 deletions tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Sweetchuck\ComposerSuite\Test;

use Codeception\Actor;
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance.suite.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
actor: AcceptanceTester
modules:
enabled:
- Filesystem
- Cli
- \Sweetchuck\ComposerSuite\Test\Helper\Acceptance
Loading

0 comments on commit 37fcab6

Please sign in to comment.