Merge branch 'feature-fixes'
This commit is contained in:
commit
7dc0dbf8fe
22 changed files with 12 additions and 663 deletions
|
|
@ -35,7 +35,7 @@ test:
|
|||
|
||||
failure:
|
||||
email:
|
||||
committer: true
|
||||
committer: false
|
||||
|
||||
complete:
|
||||
email:
|
||||
|
|
@ -11,6 +11,8 @@ php-censor:
|
|||
language: en
|
||||
per_page: 10
|
||||
url: 'http://php-censor.local'
|
||||
email_settings:
|
||||
from_address: 'no-reply@php-censor.local'
|
||||
worker:
|
||||
host: localhost
|
||||
queue: php-censor-queue
|
||||
|
|
|
|||
19
phpcs.xml
19
phpcs.xml
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PHP Censor">
|
||||
|
||||
<description>Codestyle ruleset for PHP Censor</description>
|
||||
|
||||
<rule ref="PSR2"/>
|
||||
|
||||
<file>PHP Censor</file>
|
||||
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
<exclude-pattern>src/PHPCensor/Migrations/*</exclude-pattern>
|
||||
<exclude-pattern>src/PHPCensor/Model/Base/*</exclude-pattern>
|
||||
<exclude-pattern>src/PHPCensor/Languages/*</exclude-pattern>
|
||||
<exclude-pattern>tests/*</exclude-pattern>
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
|
||||
</ruleset>
|
||||
17
phpmd.xml
17
phpmd.xml
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="PHP Censor"
|
||||
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
|
||||
http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:noNamespaceSchemaLocation="
|
||||
http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||
<description>
|
||||
PHP Censor rule set
|
||||
</description>
|
||||
|
||||
<rule ref="rulesets/codesize.xml" />
|
||||
<rule ref="rulesets/unusedcode.xml" />
|
||||
<rule ref="rulesets/naming.xml" />
|
||||
|
||||
</ruleset>
|
||||
|
|
@ -440,7 +440,7 @@
|
|||
}
|
||||
|
||||
.skin-black .main-header li.user-header {
|
||||
background-color: #1a2226;
|
||||
background-color: #222d32;
|
||||
}
|
||||
|
||||
.skin-black .content-header {
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ class Application extends b8\Application
|
|||
|
||||
/**
|
||||
* Check whether we should skip auth (because it is disabled)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldSkipAuth()
|
||||
|
|
|
|||
|
|
@ -366,8 +366,6 @@ Kontrollér venligst nedenstående fejl før du fortsætter.',
|
|||
'plugin_success' => 'PLUGIN: SUCCES',
|
||||
'plugin_failed' => 'PLUGIN: FEJL',
|
||||
'plugin_missing' => 'Plugin findes ikke: %s',
|
||||
'tap_version' => 'TapParser understøtter kun TAP version 13.',
|
||||
'tap_error' => 'Ugyldig TAP-streng, antallet af tests passer ikke med det angivne antal tests.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Ingen tests udført.',
|
||||
|
|
|
|||
|
|
@ -389,8 +389,6 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
|
|||
'plugin_success' => 'PLUGIN: ERFOLGREICH',
|
||||
'plugin_failed' => 'PLUGIN: FEHLGECHLAGEN',
|
||||
'plugin_missing' => 'Plugin existiert nicht: %s',
|
||||
'tap_version' => 'TapParser unterstützt nur TAP version 13',
|
||||
'tap_error' => 'Ungültiger TAP String, Anzahl Tests entspricht nicht angegebener Testzahl.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Keine Tests wurden ausgeführt.',
|
||||
|
|
|
|||
|
|
@ -368,8 +368,6 @@ Services</a> του Bitbucket αποθετηρίου σας.',
|
|||
'plugin_success' => 'ΠΡΟΣΘΕΤΟ: ΕΠΙΤΥΧΙΑ',
|
||||
'plugin_failed' => 'ΠΡΟΣΘΕΤΟ: ΑΠΟΤΥΧΙΑ',
|
||||
'plugin_missing' => 'Το πρόσθετο δεν υπάρχει: %s',
|
||||
'tap_version' => 'Το TapParser υποστηρίζει μόνο το TAP έκδοση 13',
|
||||
'tap_error' => 'Μη έγκυρη συμβολοσειρά TAP, ο αριθμός των δοκιμών δεν ταιριάζει με την καθορισμένη καταμέτρηση της δοκιμής.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Δεν έγιναν δοκιμές.',
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ PHP Censor',
|
|||
'success' => 'Success',
|
||||
'failed' => 'Failed',
|
||||
'error' => 'Error',
|
||||
'skipped' => 'Skipped',
|
||||
'trace' => 'Stack trace',
|
||||
'manual_build' => 'Manual Build',
|
||||
|
||||
// Add/Edit Project:
|
||||
|
|
@ -419,8 +421,6 @@ PHP Censor',
|
|||
'plugin_success' => 'PLUGIN: SUCCESS',
|
||||
'plugin_failed' => 'PLUGIN: FAILED',
|
||||
'plugin_missing' => 'Plugin does not exist: %s',
|
||||
'tap_version' => 'TapParser only supports TAP version 13',
|
||||
'tap_error' => 'Invalid TAP string, number of tests does not match specified test count.',
|
||||
'failed_allowed' => 'Allowed',
|
||||
|
||||
// Build Plugins:
|
||||
|
|
|
|||
|
|
@ -357,8 +357,6 @@ PHP Censor',
|
|||
'plugin_success' => 'PLUGIN: EXITO',
|
||||
'plugin_failed' => 'PLUGIN: FALLÓ',
|
||||
'plugin_missing' => 'No existe el plugin: %s',
|
||||
'tap_version' => 'TapParser únicamente soporta la verisón 13 de TAP',
|
||||
'tap_error' => 'Cadena de caracteres TAP inválida, el número de tests no coincide con la cuenta de tests declarada.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'No se ejecutaron tests.',
|
||||
|
|
|
|||
|
|
@ -383,8 +383,6 @@ PHP Censor',
|
|||
'plugin_success' => 'PLUGIN: RÉUSSI',
|
||||
'plugin_failed' => 'PLUGIN: ÉCHOUÉ',
|
||||
'plugin_missing' => 'Le plugins n\'existe pas: %s',
|
||||
'tap_version' => 'TapParser supporte seulement les TAP version 13',
|
||||
'tap_error' => 'Chaîne de TAP invalide, le nombre de tests ne correspond pas à celui spécifié.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Aucun test n\'a été exécuté.',
|
||||
|
|
|
|||
|
|
@ -369,8 +369,6 @@ PHP Censor',
|
|||
'plugin_success' => 'PLUGIN: PASSATO',
|
||||
'plugin_failed' => 'PLUGIN: FALLITO',
|
||||
'plugin_missing' => 'Plugin non esistente: %s',
|
||||
'tap_version' => 'TapParser supporta solo la versione TAP 13',
|
||||
'tap_error' => 'Stringa TAP non valida, il numero dei test non corrisponde con il numero di test contati.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Nessun test è stato eseguito.',
|
||||
|
|
|
|||
|
|
@ -368,8 +368,6 @@ Gelieve de fouten na te kijken vooraleer verder te gaan.',
|
|||
'plugin_success' => 'PLUGIN: SUCCES',
|
||||
'plugin_failed' => 'PLUGIN: GEFAALD',
|
||||
'plugin_missing' => 'Plugin bestaat niet: %s',
|
||||
'tap_version' => 'TapParser ondersteunt enkel TAP versie 13',
|
||||
'tap_error' => 'Ongeldige TAP string, aantal tests niet in overeenstemming met opgegeven aantal.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Er werden geen tests uitgevoerd.',
|
||||
|
|
|
|||
|
|
@ -369,8 +369,6 @@ Przejrzyj powyższą listę błędów przed kontynuowaniem.',
|
|||
'plugin_success' => 'Plugin: Sukces',
|
||||
'plugin_failed' => 'Plugin: Niepowodzenie',
|
||||
'plugin_missing' => 'Plugin nie istnieje: %s',
|
||||
'tap_version' => 'TapParser obsługuje tylko TAP w wersji 13',
|
||||
'tap_error' => 'Nieprawidłowy łańcuch TAP, liczba testów nie zgadza się z policzoną ilością testów.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Nie przeprowadzono żadnych testów.',
|
||||
|
|
|
|||
|
|
@ -393,8 +393,6 @@ PHP Censor',
|
|||
'plugin_success' => 'PLUGIN: SUCCESS',
|
||||
'plugin_failed' => 'PLUGIN: FAILED',
|
||||
'plugin_missing' => 'Plugin does not exist: %s',
|
||||
'tap_version' => 'TapParser only supports TAP version 13',
|
||||
'tap_error' => 'Invalid TAP string, number of tests does not match specified test count.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'No tests have been performed.',
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ PHP Censor',
|
|||
|
||||
// Top Nav
|
||||
'toggle_navigation' => 'Скрыть/показать панель навигации',
|
||||
'n_builds_pending' => '%d сборок ожидает',
|
||||
'n_builds_running' => '%d сборок запущено',
|
||||
'n_builds_pending' => 'Сборок ожидает: %d',
|
||||
'n_builds_running' => 'Сборок запущено: %d',
|
||||
'edit_profile' => 'Редактировать профиль',
|
||||
'sign_out' => 'Выйти',
|
||||
'branch_x' => 'Ветка: %s',
|
||||
|
|
@ -87,6 +87,8 @@ PHP Censor',
|
|||
'success' => 'Успешно',
|
||||
'failed' => 'Провал',
|
||||
'error' => 'Ошибка',
|
||||
'skipped' => 'Пропущено',
|
||||
'trace' => 'Стек вызова',
|
||||
'manual_build' => 'Запущена вручную',
|
||||
|
||||
// Add/Edit Project:
|
||||
|
|
@ -404,8 +406,6 @@ PHP Censor',
|
|||
'plugin_success' => 'ПЛАГИН: УСПЕШНО',
|
||||
'plugin_failed' => 'ПЛАГИН: ПРОВАЛ',
|
||||
'plugin_missing' => 'Плагина не существует: %s',
|
||||
'tap_version' => 'TapParser поддерживает только TAP версии 13',
|
||||
'tap_error' => 'Некорректная TAP-строка, количество тестов не совпадает с заявленным.',
|
||||
'failed_allowed' => 'Разрешен',
|
||||
|
||||
// Build Plugins:
|
||||
|
|
|
|||
|
|
@ -368,8 +368,6 @@ PHP Censor',
|
|||
'plugin_success' => 'ПЛАГІН: УСПІШНО',
|
||||
'plugin_failed' => 'ПЛАГІН: НЕВДАЛО',
|
||||
'plugin_missing' => 'Плагін не існує: %s',
|
||||
'tap_version' => 'TapParser підтримує тільки TAP версії 13',
|
||||
'tap_error' => 'Некоректний TAP-рядок, кількість тестів не співпадає із вказаними.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'Жодних тестів не було запущено.',
|
||||
|
|
|
|||
|
|
@ -386,8 +386,6 @@ PHP Censor',
|
|||
'plugin_success' => 'PLUGIN: SUCCESS',
|
||||
'plugin_failed' => 'PLUGIN: FAILED',
|
||||
'plugin_missing' => 'Plugin does not exist: %s',
|
||||
'tap_version' => 'TapParser only supports TAP version 13',
|
||||
'tap_error' => 'Invalid TAP string, number of tests does not match specified test count.',
|
||||
|
||||
// Build Plugins:
|
||||
'no_tests_performed' => 'No tests have been performed.',
|
||||
|
|
|
|||
|
|
@ -1,286 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PHPCensor\Plugin\Util;
|
||||
|
||||
use Exception;
|
||||
use PHPCensor\Helper\Lang;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Processes TAP format strings into usable test result data.
|
||||
* @package PHPCensor\Plugin\Util
|
||||
*/
|
||||
class TapParser
|
||||
{
|
||||
const TEST_COUNTS_PATTERN = '/^\d+\.\.(\d+)/';
|
||||
const TEST_LINE_PATTERN = '/^(ok|not ok)(?:\s+\d+)?(?:\s+\-)?\s*(.*?)(?:\s*#\s*(skip|todo)\s*(.*))?\s*$/i';
|
||||
const TEST_YAML_START = '/^(\s*)---/';
|
||||
const TEST_DIAGNOSTIC = '/^#/';
|
||||
const TEST_COVERAGE = '/(Generating code coverage|The Xdebug extension is not loaded|No code coverage)/';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tapString;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $failures = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $lines;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $lineNumber;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $testCount;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $results;
|
||||
|
||||
/**
|
||||
* Create a new TAP parser for a given string.
|
||||
* @param string $tapString The TAP format string to be parsed.
|
||||
*/
|
||||
public function __construct($tapString)
|
||||
{
|
||||
$this->tapString = trim($tapString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a given TAP format string and return an array of tests and their status.
|
||||
*/
|
||||
public function parse()
|
||||
{
|
||||
// Split up the TAP string into an array of lines, then
|
||||
// trim all of the lines so there's no leading or trailing whitespace.
|
||||
$this->lines = array_map('rtrim', explode("\n", $this->tapString));
|
||||
$this->lineNumber = 0;
|
||||
|
||||
$this->testCount = false;
|
||||
$this->results = [];
|
||||
|
||||
$header = $this->findTapLog();
|
||||
|
||||
$line = $this->nextLine();
|
||||
if ($line === $header) {
|
||||
throw new Exception("Duplicated TAP log, please check the configuration.");
|
||||
}
|
||||
|
||||
while ($line !== false && ($this->testCount === false || count($this->results) < $this->testCount)) {
|
||||
$this->parseLine($line);
|
||||
$line = $this->nextLine();
|
||||
}
|
||||
|
||||
if (false !== $this->testCount && count($this->results) !== $this->testCount) {
|
||||
throw new Exception(Lang::get('tap_error'));
|
||||
}
|
||||
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/** Looks for the start of the TAP log in the string.
|
||||
*
|
||||
* @return string The TAP header line.
|
||||
*
|
||||
* @throws Exception if no TAP log is found or versions mismatch.
|
||||
*/
|
||||
protected function findTapLog()
|
||||
{
|
||||
// Look for the beginning of the TAP output
|
||||
do {
|
||||
$header = $this->nextLine();
|
||||
} while ($header !== false && substr($header, 0, 12) !== 'TAP version ');
|
||||
|
||||
//
|
||||
if ($header === false) {
|
||||
throw new Exception('No TAP log found, please check the configuration.');
|
||||
} elseif ($header !== 'TAP version 13') {
|
||||
throw new Exception(Lang::get('tap_version'));
|
||||
}
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
/** Fetch the next line.
|
||||
*
|
||||
* @return string|false The next line or false if the end has been reached.
|
||||
*/
|
||||
protected function nextLine()
|
||||
{
|
||||
if ($this->lineNumber < count($this->lines)) {
|
||||
return $this->lines[$this->lineNumber++];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function testLine($line)
|
||||
{
|
||||
if (preg_match(self::TEST_LINE_PATTERN, $line, $matches)) {
|
||||
$this->results[] = $this->processTestLine(
|
||||
$matches[1],
|
||||
isset($matches[2]) ? $matches[2] : '',
|
||||
isset($matches[3]) ? $matches[3] : null,
|
||||
isset($matches[4]) ? $matches[4] : null
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function yamlLine($line)
|
||||
{
|
||||
if (preg_match(self::TEST_YAML_START, $line, $matches)) {
|
||||
$diagnostic = $this->processYamlBlock($matches[1]);
|
||||
$test = array_pop($this->results);
|
||||
if (isset($test['message'], $diagnostic['message'])) {
|
||||
$test['message'] .= PHP_EOL . $diagnostic['message'];
|
||||
unset($diagnostic['message']);
|
||||
}
|
||||
$this->results[] = array_replace($test, $diagnostic);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Parse a single line.
|
||||
*
|
||||
* @param string $line
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function parseLine($line)
|
||||
{
|
||||
if (preg_match(self::TEST_DIAGNOSTIC, $line) || preg_match(self::TEST_COVERAGE, $line) || !$line) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (preg_match(self::TEST_COUNTS_PATTERN, $line, $matches)) {
|
||||
$this->testCount = intval($matches[1]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->testLine($line)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->yamlLine($line)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception(sprintf('Incorrect TAP data, line %d: %s', $this->lineNumber, $line));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an individual test line.
|
||||
*
|
||||
* @param string $result
|
||||
* @param string $message
|
||||
* @param string $directive
|
||||
* @param string $reason
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processTestLine($result, $message, $directive, $reason)
|
||||
{
|
||||
$test = [
|
||||
'pass' => true,
|
||||
'message' => $message,
|
||||
'severity' => 'success',
|
||||
];
|
||||
|
||||
if ($result !== 'ok') {
|
||||
$test['pass'] = false;
|
||||
$test['severity'] = substr($message, 0, 6) === 'Error:' ? 'error' : 'fail';
|
||||
$this->failures++;
|
||||
}
|
||||
|
||||
if ($directive) {
|
||||
$test = $this->processDirective($test, $directive, $reason);
|
||||
}
|
||||
|
||||
return $test;
|
||||
}
|
||||
|
||||
/** Process an indented Yaml block.
|
||||
*
|
||||
* @param string $indent The block indentation to ignore.
|
||||
*
|
||||
* @return array The processed Yaml content.
|
||||
*/
|
||||
protected function processYamlBlock($indent)
|
||||
{
|
||||
$startLine = $this->lineNumber + 1;
|
||||
$endLine = $indent . '...';
|
||||
$yamlLines = [];
|
||||
|
||||
do {
|
||||
$line = $this->nextLine();
|
||||
|
||||
if ($line === false) {
|
||||
throw new Exception(Lang::get('tap_error_endless_yaml', $startLine));
|
||||
} elseif ($line === $endLine) {
|
||||
break;
|
||||
}
|
||||
|
||||
$yamlLines[] = substr($line, strlen($indent));
|
||||
} while (true);
|
||||
|
||||
return Yaml::parse(join("\n", $yamlLines));
|
||||
}
|
||||
|
||||
/** Process a TAP directive
|
||||
*
|
||||
* @param array $test
|
||||
* @param string $directive
|
||||
* @param string $reason
|
||||
* @return array
|
||||
*/
|
||||
protected function processDirective($test, $directive, $reason)
|
||||
{
|
||||
$test['severity'] = strtolower($directive) === 'skip' ? 'skipped' : 'todo';
|
||||
|
||||
if (!empty($reason)) {
|
||||
if (!empty($test['message'])) {
|
||||
$test['message'] .= ', '.$test['severity'].': ';
|
||||
}
|
||||
$test['message'] .= $reason;
|
||||
}
|
||||
|
||||
return $test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of failures from the current TAP file.
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalFailures()
|
||||
{
|
||||
return $this->failures;
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- User image -->
|
||||
<li class="user-header bg-light-blue">
|
||||
<li class="user-header">
|
||||
<img src="https://www.gravatar.com/avatar/<?php print md5($this->User()->getEmail()); ?>?d=mm" class="img-circle" alt="<?php print $this->User()->getName(); ?>" />
|
||||
<p>
|
||||
<?php print $this->User()->getName(); ?>
|
||||
|
|
|
|||
|
|
@ -1,310 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPCI - Continuous Integration for PHP
|
||||
*
|
||||
* @copyright Copyright 2015, Block 8 Limited.
|
||||
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
||||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
namespace Tests\PHPCensor\Plugin\Util;
|
||||
|
||||
use PHPCensor\Plugin\Util\TapParser;
|
||||
|
||||
class TapParserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSimple()
|
||||
{
|
||||
$content = <<<TAP
|
||||
Leading garbage !
|
||||
TAP version 13
|
||||
ok 1 - SomeTest::testAnother
|
||||
not ok
|
||||
1..2
|
||||
Trailing garbage !
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'SomeTest::testAnother'],
|
||||
['pass' => false, 'severity' => 'fail', 'message' => ''],
|
||||
], $result);
|
||||
|
||||
$this->assertEquals(1, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
public function testSimple2()
|
||||
{
|
||||
$content = <<<TAP
|
||||
Leading garbage !
|
||||
TAP version 13
|
||||
|
||||
ok 1 - SomeTest::testAnother
|
||||
not ok
|
||||
1..2
|
||||
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'SomeTest::testAnother'],
|
||||
['pass' => false, 'severity' => 'fail', 'message' => ''],
|
||||
], $result);
|
||||
|
||||
$this->assertEquals(1, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp /No TAP/
|
||||
*/
|
||||
public function testNoTapData()
|
||||
{
|
||||
$content = <<<TAP
|
||||
Only garbage !
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$parser->parse();
|
||||
}
|
||||
|
||||
public function testTapCoverage()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
|
||||
Generating code coverage report in HTML format ... done
|
||||
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([], $result);
|
||||
}
|
||||
|
||||
public function testTapCoverageXdebug()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
|
||||
Warning: The Xdebug extension is not loaded
|
||||
No code coverage will be generated.
|
||||
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([], $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp /Duplicated TAP/
|
||||
*/
|
||||
public function testDuplicateOutput()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
TAP version 13
|
||||
ok 1 - SomeTest::testAnother
|
||||
ok 1 - SomeTest::testAnother
|
||||
not ok - Failure: SomeTest::testAnother
|
||||
not ok - Failure: SomeTest::testAnother
|
||||
not ok 3 - Error: SomeTest::testAnother
|
||||
not ok 3 - Error: SomeTest::testAnother
|
||||
1..3
|
||||
1..3
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$parser->parse();
|
||||
}
|
||||
|
||||
public function testSuiteAndTest()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
ok 1 - SomeTest::testAnother
|
||||
not ok - Failure: SomeTest::testAnother
|
||||
not ok 3 - Error: SomeTest::testAnother
|
||||
1..3
|
||||
Trailing garbage !
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'SomeTest::testAnother',],
|
||||
['pass' => false, 'severity' => 'fail', 'message' => 'Failure: SomeTest::testAnother'],
|
||||
['pass' => false, 'severity' => 'error', 'message' => 'Error: SomeTest::testAnother'],
|
||||
], $result);
|
||||
|
||||
$this->assertEquals(2, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
|
||||
public function testSkipped()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
ok 1 - # SKIP
|
||||
ok 2 - # SKIP foobar
|
||||
ok 3 - foo # SKIP bar
|
||||
1..3
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([
|
||||
['pass' => true, 'severity' => 'skipped', 'message' => ''],
|
||||
['pass' => true, 'severity' => 'skipped', 'message' => 'foobar'],
|
||||
['pass' => true, 'severity' => 'skipped', 'message' => 'foo, skipped: bar'],
|
||||
], $result);
|
||||
|
||||
$this->assertEquals(0, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
public function testTodo()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
ok 1 - SomeTest::testAnother # TODO really implement this test
|
||||
ok 2 - # TODO really implement this test
|
||||
ok 3 - this is a message # TODO really implement this test
|
||||
ok 4 - # TODO
|
||||
1..4
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([
|
||||
['pass' => true, 'severity' => 'todo', 'message' => 'SomeTest::testAnother, todo: really implement this test'],
|
||||
['pass' => true, 'severity' => 'todo', 'message' => 'really implement this test'],
|
||||
['pass' => true, 'severity' => 'todo', 'message' => 'this is a message, todo: really implement this test'],
|
||||
['pass' => true, 'severity' => 'todo', 'message' => ''],
|
||||
], $result);
|
||||
|
||||
$this->assertEquals(0, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
public function testYamlDiagnostic()
|
||||
{
|
||||
// From https://phpunit.de/manual/current/en/logging.html#logging.tap
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
not ok 1 - FOO
|
||||
---
|
||||
message: BAR
|
||||
...
|
||||
1..1
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([[
|
||||
'pass' => false,
|
||||
'severity' => 'fail',
|
||||
'message' => 'FOO' . PHP_EOL . 'BAR',
|
||||
]], $result);
|
||||
|
||||
$this->assertEquals(1, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
public function testFailureAndError()
|
||||
{
|
||||
// From https://phpunit.de/manual/current/en/logging.html#logging.tap
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
not ok 1 - Failure: testFailure::FailureErrorTest
|
||||
not ok 2 - Error: testError::FailureErrorTest
|
||||
1..2
|
||||
TAP;
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([[
|
||||
'pass' => false,
|
||||
'severity' => 'fail',
|
||||
'message' => 'Failure: testFailure::FailureErrorTest',
|
||||
], [
|
||||
'pass' => false,
|
||||
'severity' => 'error',
|
||||
'message' => 'Error: testError::FailureErrorTest',
|
||||
]], $result);
|
||||
|
||||
$this->assertEquals(2, $parser->getTotalFailures());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testGarbage()
|
||||
{
|
||||
$content = "Garbage !";
|
||||
|
||||
$parser = new TapParser($content);
|
||||
$parser->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testInvalidTestCount()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
ok 1 - SomeTest::testAnother
|
||||
not ok
|
||||
1..5
|
||||
TAP;
|
||||
|
||||
$parser = new TapParser($content);
|
||||
$parser->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testEndlessYaml()
|
||||
{
|
||||
$content = <<<TAP
|
||||
TAP version 13
|
||||
ok 1 - SomeTest::testAnother
|
||||
---
|
||||
1..1
|
||||
TAP;
|
||||
|
||||
$parser = new TapParser($content);
|
||||
$parser->parse();
|
||||
}
|
||||
|
||||
public function testCodeception()
|
||||
{
|
||||
$content = <<< TAP
|
||||
TAP version 13
|
||||
ok 1 - try to access the dashboard as a guest (Auth/GuestAccessDashboardAndRedirectCept)
|
||||
ok 2 - see the login page (Auth/SeeLoginCept)
|
||||
ok 3 - click forgot password and see the email form (Auth/SeeLoginForgotPasswordCept)
|
||||
ok 4 - see powered by runmybusiness branding (Auth/ShouldSeePoweredByBrandingCept)
|
||||
ok 5 - submit invalid credentials (Auth/SubmitLoginAndFailCept)
|
||||
ok 6 - submit valid credentials and see the dashboard (Auth/SubmitLoginAndSucceedCept)
|
||||
1..6
|
||||
TAP;
|
||||
|
||||
$parser = new TapParser($content);
|
||||
$result = $parser->parse();
|
||||
|
||||
$this->assertEquals([
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'try to access the dashboard as a guest (Auth/GuestAccessDashboardAndRedirectCept)'],
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'see the login page (Auth/SeeLoginCept)'],
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'click forgot password and see the email form (Auth/SeeLoginForgotPasswordCept)'],
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'see powered by runmybusiness branding (Auth/ShouldSeePoweredByBrandingCept)'],
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'submit invalid credentials (Auth/SubmitLoginAndFailCept)'],
|
||||
['pass' => true, 'severity' => 'success', 'message' => 'submit valid credentials and see the dashboard (Auth/SubmitLoginAndSucceedCept)'],
|
||||
], $result);
|
||||
|
||||
$this->assertEquals(0, $parser->getTotalFailures());
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue