Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Re-write the acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andor Dávid committed Sep 5, 2016
1 parent a55df19 commit 9791f45
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 37 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"cheppers/git-hooks": "^0.0.8",
"cheppers/robo-phpcs": "^0.0.4",
"codeception/codeception": "^2.2",
"squizlabs/php_codesniffer": "2.6.2",
"symfony/process": "^2.8|^3.1"
},
"autoload": {
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

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

73 changes: 70 additions & 3 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use \PHPUnit_Framework_Assert as Assert;

/**
* Inherited Methods
Expand All @@ -20,7 +21,73 @@ class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
/**
* @return $this
*/
public function clearTheReportsDir()
{
$reportsDir = 'tests/_data/reports';
if (is_dir($reportsDir)) {
$finder = new \Symfony\Component\Finder\Finder();
$finder->in($reportsDir);
foreach ($finder->files() as $file) {
unlink($file->getPathname());
}
}

return $this;
}

/**
* @param string $taskName
*
* @return $this
*/
public function runRoboTask($taskName)
{
$cmd = sprintf(
'cd tests/_data && ../../bin/robo %s',
escapeshellarg($taskName)
);

$this->runShellCommand($cmd);

return $this;
}

/**
* @param string $expected
*
* @return $this
*/
public function seeThisTextInTheStdOutput($expected)
{
Assert::assertContains($expected, $this->getStdOutput());

return $this;
}

/**
* @param string $expected
*
* @return $this
*/
public function seeThisTextInTheStdError($expected)
{
Assert::assertContains($expected, $this->getStdError());

return $this;
}

/**
* @param int $expected
*
* @return $this
*/
public function theExitCodeShouldBe($expected)
{
Assert::assertEquals($expected, $this->getExitCode());

return $this;
}
}
22 changes: 7 additions & 15 deletions tests/acceptance/LintVerboseCept.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?php

/**
* @var \Codeception\Scenario $scenario
*/

use \PHPUnit_Framework_Assert as Assert;

$dataDir = rtrim(codecept_data_dir(), '/');

$i = new AcceptanceTester($scenario);
$i = new \AcceptanceTester($scenario);
$i->wantTo('tslint --format verbose');
$cmd = sprintf('bin/robo --load-from %s lint:verbose', escapeshellarg($dataDir));
$i->runShellCommand($cmd);
Assert::assertContains(
'(whitespace) samples/invalid-01.d.ts[5, 16]: missing whitespace',
$i->getStdOutput()
);
Assert::assertContains(
'(whitespace) samples/invalid-02.d.ts[5, 16]: missing whitespace',
$i->getStdOutput()
);

$i->runRoboTask('lint:verbose');
$i->theExitCodeShouldBe(2);
$i->seeThisTextInTheStdOutput('(whitespace) samples/invalid-01.d.ts[5, 16]: missing whitespace');
$i->seeThisTextInTheStdOutput('(whitespace) samples/invalid-02.d.ts[5, 16]: missing whitespace');
15 changes: 4 additions & 11 deletions tests/acceptance/LintWithJarCept.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<?php

/**
* @var \Codeception\Scenario $scenario
*/

use \PHPUnit_Framework_Assert as Assert;

$dataDir = rtrim(codecept_data_dir(), '/');
$cmd = sprintf('bin/robo --load-from %s lint:with-jar', escapeshellarg($dataDir));

$i = new AcceptanceTester($scenario);
$i->wantTo('tslint --format yaml | tslint-formatters yaml2jsonGroupByFiles');
$i->runShellCommand($cmd);
Assert::assertEquals(1, $i->getExitCode());
Assert::assertContains(
'One or more errors were reported (and any number of warnings)',
$i->getStdError()
);
$i->runRoboTask('lint:with-jar');
$i->theExitCodeShouldBe(1);
$i->seeThisTextInTheStdError('One or more errors were reported (and any number of warnings)');

0 comments on commit 9791f45

Please sign in to comment.