Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
03c603082f |
|
@ -1,4 +1,5 @@
|
||||||
build_settings:
|
build_settings:
|
||||||
|
clone_depth: 1
|
||||||
ignore:
|
ignore:
|
||||||
- vendor
|
- vendor
|
||||||
- tests
|
- tests
|
||||||
|
@ -13,6 +14,11 @@ test:
|
||||||
- phpunit.xml
|
- phpunit.xml
|
||||||
coverage: true
|
coverage: true
|
||||||
|
|
||||||
|
php_mess_detector:
|
||||||
|
allow_failures: true
|
||||||
|
rules:
|
||||||
|
- phpmd.xml
|
||||||
|
|
||||||
php_code_sniffer:
|
php_code_sniffer:
|
||||||
standard: PSR2
|
standard: PSR2
|
||||||
encoding: UTF-8
|
encoding: UTF-8
|
||||||
|
@ -27,6 +33,9 @@ test:
|
||||||
php_parallel_lint:
|
php_parallel_lint:
|
||||||
allow_failures: true
|
allow_failures: true
|
||||||
|
|
||||||
|
php_docblock_checker:
|
||||||
|
allow_failures: true
|
||||||
|
|
||||||
security_checker:
|
security_checker:
|
||||||
allow_failures: false
|
allow_failures: false
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
"codeception/codeception": "~2.3.0",
|
"codeception/codeception": "~2.3.0",
|
||||||
"phpmd/phpmd": "~2.6.0",
|
"phpmd/phpmd": "~2.6.0",
|
||||||
"sebastian/phpcpd": "~2.0.0",
|
"sebastian/phpcpd": "~2.0.0",
|
||||||
"squizlabs/php_codesniffer": "~3.2.0",
|
"squizlabs/php_codesniffer": "~2.8.0",
|
||||||
"block8/php-docblock-checker": "~1.3.0",
|
"block8/php-docblock-checker": "~1.3.0",
|
||||||
"phploc/phploc": "~4.0.0",
|
"phploc/phploc": "~4.0.0",
|
||||||
"jakub-onderka/php-parallel-lint": "~0.9.0",
|
"jakub-onderka/php-parallel-lint": "~0.9.0",
|
||||||
|
|
51
composer.lock
generated
51
composer.lock
generated
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"_readme": [
|
"_readme": [
|
||||||
"This file locks the dependencies of your project to a known state",
|
"This file locks the dependencies of your project to a known state",
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "8ed0d649c464752b717de050e04cd313",
|
"content-hash": "6c8facd9ea26fd63006a35d445fac984",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "behat/gherkin",
|
"name": "behat/gherkin",
|
||||||
|
@ -2959,37 +2959,64 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "squizlabs/php_codesniffer",
|
"name": "squizlabs/php_codesniffer",
|
||||||
"version": "3.2.3",
|
"version": "2.8.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||||
"reference": "4842476c434e375f9d3182ff7b89059583aa8b27"
|
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27",
|
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
|
||||||
"reference": "4842476c434e375f9d3182ff7b89059583aa8b27",
|
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-simplexml": "*",
|
"ext-simplexml": "*",
|
||||||
"ext-tokenizer": "*",
|
"ext-tokenizer": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"php": ">=5.4.0"
|
"php": ">=5.1.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
"phpunit/phpunit": "~4.0"
|
||||||
},
|
},
|
||||||
"bin": [
|
"bin": [
|
||||||
"bin/phpcs",
|
"scripts/phpcs",
|
||||||
"bin/phpcbf"
|
"scripts/phpcbf"
|
||||||
],
|
],
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.x-dev"
|
"dev-master": "2.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"CodeSniffer.php",
|
||||||
|
"CodeSniffer/CLI.php",
|
||||||
|
"CodeSniffer/Exception.php",
|
||||||
|
"CodeSniffer/File.php",
|
||||||
|
"CodeSniffer/Fixer.php",
|
||||||
|
"CodeSniffer/Report.php",
|
||||||
|
"CodeSniffer/Reporting.php",
|
||||||
|
"CodeSniffer/Sniff.php",
|
||||||
|
"CodeSniffer/Tokens.php",
|
||||||
|
"CodeSniffer/Reports/",
|
||||||
|
"CodeSniffer/Tokenizers/",
|
||||||
|
"CodeSniffer/DocGenerators/",
|
||||||
|
"CodeSniffer/Standards/AbstractPatternSniff.php",
|
||||||
|
"CodeSniffer/Standards/AbstractScopeSniff.php",
|
||||||
|
"CodeSniffer/Standards/AbstractVariableSniff.php",
|
||||||
|
"CodeSniffer/Standards/IncorrectPatternException.php",
|
||||||
|
"CodeSniffer/Standards/Generic/Sniffs/",
|
||||||
|
"CodeSniffer/Standards/MySource/Sniffs/",
|
||||||
|
"CodeSniffer/Standards/PEAR/Sniffs/",
|
||||||
|
"CodeSniffer/Standards/PSR1/Sniffs/",
|
||||||
|
"CodeSniffer/Standards/PSR2/Sniffs/",
|
||||||
|
"CodeSniffer/Standards/Squiz/Sniffs/",
|
||||||
|
"CodeSniffer/Standards/Zend/Sniffs/"
|
||||||
|
]
|
||||||
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
"BSD-3-Clause"
|
"BSD-3-Clause"
|
||||||
|
@ -3006,7 +3033,7 @@
|
||||||
"phpcs",
|
"phpcs",
|
||||||
"standards"
|
"standards"
|
||||||
],
|
],
|
||||||
"time": "2018-02-20T21:35:23+00:00"
|
"time": "2017-03-01T22:17:45+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "swiftmailer/swiftmailer",
|
"name": "swiftmailer/swiftmailer",
|
||||||
|
|
|
@ -78,7 +78,7 @@ Plugins
|
||||||
|
|
||||||
* [Campfire](plugins/campfire.md) - `campfire`
|
* [Campfire](plugins/campfire.md) - `campfire`
|
||||||
* [Email](plugins/email.md) - `email`
|
* [Email](plugins/email.md) - `email`
|
||||||
* [FlowDock](plugins/flowdock_notify.md) - `flowdock_notify`
|
* FlowDock - `flowdock_notify`
|
||||||
* [HipChat](plugins/hipchat_notify.md) - `hipchat_notify`
|
* [HipChat](plugins/hipchat_notify.md) - `hipchat_notify`
|
||||||
* [IRC](plugins/irc.md) - `irc`
|
* [IRC](plugins/irc.md) - `irc`
|
||||||
* [Slack](plugins/slack_notify.md) - `slack_notify`
|
* [Slack](plugins/slack_notify.md) - `slack_notify`
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
Plugin FlowdockNotify
|
|
||||||
=====================
|
|
||||||
|
|
||||||
This plugin joins a [Flowdock](https://www.flowdock.com/) room and sends a user-defined message, for example a
|
|
||||||
"Build Succeeded" message.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
The plugin depends on `mremi/flowdock` library. To use FlowdockNotify plugin you should install dependency:
|
|
||||||
|
|
||||||
```
|
|
||||||
composer require "mremi/flowdock"
|
|
||||||
```
|
|
|
@ -1,18 +1,9 @@
|
||||||
Plugin HipchatNotify
|
Plugin Hipchat Notify
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
This plugin joins a [HipChat](https://www.hipchat.com/) room and sends a user-defined message, for example a
|
This plugin joins a [HipChat](https://www.hipchat.com/) room and sends a user-defined message, for example a
|
||||||
"Build Succeeded" message.
|
"Build Succeeded" message.
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
The plugin depends on `hipchat/hipchat-php` library. To use HipchatNotify plugin you should install dependency:
|
|
||||||
|
|
||||||
```
|
|
||||||
composer require "hipchat/hipchat-php"
|
|
||||||
```
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,9 @@
|
||||||
Plugin SlackNotify
|
Plugin Slack Notify
|
||||||
===================
|
===================
|
||||||
|
|
||||||
This plugin joins a [Slack](https://www.slack.com/) room and sends a user-defined message, for example a "Build
|
This plugin joins a [Slack](https://www.slack.com/) room and sends a user-defined message, for example a "Build
|
||||||
Succeeded" message.
|
Succeeded" message.
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
The plugin depends on `maknz/slack` library. To use SlackNotify plugin you should install dependency:
|
|
||||||
|
|
||||||
```
|
|
||||||
composer require "maknz/slack"
|
|
||||||
```
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -592,11 +592,11 @@ class WebhookController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Called by Gogs Webhooks:
|
||||||
|
*
|
||||||
* @param string $projectId
|
* @param string $projectId
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function gogs($projectId)
|
public function gogs($projectId)
|
||||||
{
|
{
|
||||||
|
@ -605,17 +605,15 @@ class WebhookController extends Controller
|
||||||
Project::TYPE_GIT,
|
Project::TYPE_GIT,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$contentType = !empty($_SERVER['CONTENT_TYPE'])
|
switch ($_SERVER['CONTENT_TYPE']) {
|
||||||
? $_SERVER['CONTENT_TYPE']
|
case 'application/json':
|
||||||
: null;
|
$payload = json_decode(file_get_contents('php://input'), true);
|
||||||
|
break;
|
||||||
switch ($contentType) {
|
|
||||||
case 'application/x-www-form-urlencoded':
|
case 'application/x-www-form-urlencoded':
|
||||||
$payload = json_decode($this->getParam('payload'), true);
|
$payload = json_decode($this->getParam('payload'), true);
|
||||||
break;
|
break;
|
||||||
case 'application/json':
|
|
||||||
default:
|
default:
|
||||||
$payload = json_decode(file_get_contents('php://input'), true);
|
return ['status' => 'failed', 'error' => 'Content type not supported.', 'responseCode' => 401];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Push web hooks:
|
// Handle Push web hooks:
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace PHPCensor\Helper;
|
|
||||||
|
|
||||||
class XmlUtf8CleanFilter extends \php_user_filter
|
|
||||||
{
|
|
||||||
const PATTERN = '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param resource $in
|
|
||||||
* @param resource $out
|
|
||||||
* @param int $consumed
|
|
||||||
* @param bool $closing
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
function filter($in, $out, &$consumed, $closing)
|
|
||||||
{
|
|
||||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
|
||||||
$bucket->data = preg_replace(self::PATTERN, '', $bucket->data);
|
|
||||||
$consumed += $bucket->datalen;
|
|
||||||
|
|
||||||
stream_bucket_append($out, $bucket);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PSFS_PASS_ON;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Xml
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param $filePath
|
|
||||||
*
|
|
||||||
* @return null|\SimpleXMLElement
|
|
||||||
*/
|
|
||||||
public static function loadFromFile($filePath)
|
|
||||||
{
|
|
||||||
stream_filter_register('xml_utf8_clean', 'PHPCensor\Helper\XmlUtf8CleanFilter');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$xml = simplexml_load_file('php://filter/read=xml_utf8_clean/resource=' . $filePath);
|
|
||||||
} catch (\Exception $ex) {
|
|
||||||
$xml = null;
|
|
||||||
} catch (\Throwable $ex) { // since php7
|
|
||||||
$xml = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$xml) {
|
|
||||||
// from https://stackoverflow.com/questions/7766455/how-to-handle-invalid-unicode-with-simplexml/8092672#8092672
|
|
||||||
$oldUse = libxml_use_internal_errors(true);
|
|
||||||
|
|
||||||
libxml_clear_errors();
|
|
||||||
|
|
||||||
$dom = new \DOMDocument("1.0", "UTF-8");
|
|
||||||
|
|
||||||
$dom->strictErrorChecking = false;
|
|
||||||
$dom->validateOnParse = false;
|
|
||||||
$dom->recover = true;
|
|
||||||
|
|
||||||
$dom->loadXML(strtr(
|
|
||||||
file_get_contents($filePath),
|
|
||||||
['"' => "'"] // " in attribute names may mislead the parser
|
|
||||||
));
|
|
||||||
|
|
||||||
/** @var \LibXMLError $xmlError */
|
|
||||||
$xmlError = libxml_get_last_error();
|
|
||||||
if ($xmlError) {
|
|
||||||
$warning = sprintf('L%s C%s: %s', $xmlError->line, $xmlError->column, $xmlError->message);
|
|
||||||
print 'WARNING: ignored errors while reading phpunit result, '.$warning."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$dom->hasChildNodes()) {
|
|
||||||
new \SimpleXMLElement('<empty/>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$xml = simplexml_import_dom($dom);
|
|
||||||
|
|
||||||
libxml_clear_errors();
|
|
||||||
libxml_use_internal_errors($oldUse);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $xml;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -302,7 +302,7 @@ class Build extends BaseBuild
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$className = '\PHPCensor\Plugin\\'.$item->getBasename('.php');
|
$className = '\PHPCensor\Plugin\\' . $item->getBasename('.php');
|
||||||
|
|
||||||
$reflectedPlugin = new \ReflectionClass($className);
|
$reflectedPlugin = new \ReflectionClass($className);
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,8 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$parser = new Parser($this->builder, ($outputPath . 'report.xml'));
|
$xml = file_get_contents($outputPath . 'report.xml', false);
|
||||||
|
$parser = new Parser($this->builder, $xml);
|
||||||
$output = $parser->parse();
|
$output = $parser->parse();
|
||||||
|
|
||||||
$meta = [
|
$meta = [
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace PHPCensor\Plugin\Util;
|
namespace PHPCensor\Plugin\Util;
|
||||||
|
|
||||||
use PHPCensor\Helper\Xml;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PhpUnitResultJunit parses the results for the PhpUnitV2 plugin
|
* Class PhpUnitResultJunit parses the results for the PhpUnitV2 plugin
|
||||||
*
|
*
|
||||||
|
@ -26,11 +24,11 @@ class PhpUnitResultJunit extends PhpUnitResult
|
||||||
|
|
||||||
$suites = $this->loadResultFile();
|
$suites = $this->loadResultFile();
|
||||||
|
|
||||||
if ($suites) {
|
foreach ($suites->xpath('//testcase') as $testCase) {
|
||||||
foreach ($suites->xpath('//testcase') as $testCase) {
|
$this->parseTestcase($testCase);
|
||||||
$this->parseTestcase($testCase);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$suites['failures'];
|
||||||
|
$suites['errors'];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +139,44 @@ class PhpUnitResultJunit extends PhpUnitResult
|
||||||
return new \SimpleXMLElement('<empty/>'); // new empty element
|
return new \SimpleXMLElement('<empty/>'); // new empty element
|
||||||
}
|
}
|
||||||
|
|
||||||
return Xml::loadFromFile($this->outputFile);
|
try {
|
||||||
|
$suites = simplexml_load_file($this->outputFile);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
$suites = null;
|
||||||
|
} catch (\Throwable $ex) { // since php7
|
||||||
|
$suites = null;
|
||||||
|
}
|
||||||
|
if (!$suites) {
|
||||||
|
// from https://stackoverflow.com/questions/7766455/how-to-handle-invalid-unicode-with-simplexml/8092672#8092672
|
||||||
|
$oldUse = libxml_use_internal_errors(true);
|
||||||
|
libxml_clear_errors();
|
||||||
|
$dom = new \DOMDocument("1.0", "UTF-8");
|
||||||
|
$dom->strictErrorChecking = false;
|
||||||
|
$dom->validateOnParse = false;
|
||||||
|
$dom->recover = true;
|
||||||
|
$dom->loadXML(strtr(
|
||||||
|
file_get_contents($this->outputFile),
|
||||||
|
array('"' => "'") // " in attribute names may mislead the parser
|
||||||
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \LibXMLError
|
||||||
|
*/
|
||||||
|
$xmlError = libxml_get_last_error();
|
||||||
|
if ($xmlError) {
|
||||||
|
$warning = sprintf('L%s C%s: %s', $xmlError->line, $xmlError->column, $xmlError->message);
|
||||||
|
print 'WARNING: ignored errors while reading phpunit result, '.$warning."\n";
|
||||||
|
}
|
||||||
|
if (!$dom->hasChildNodes()) {
|
||||||
|
$this->internalProblem('xml file with no content');
|
||||||
|
}
|
||||||
|
$suites = simplexml_import_dom($dom);
|
||||||
|
|
||||||
|
libxml_clear_errors();
|
||||||
|
libxml_use_internal_errors($oldUse);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $suites;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,5 +185,7 @@ class PhpUnitResultJunit extends PhpUnitResult
|
||||||
private function internalProblem($description)
|
private function internalProblem($description)
|
||||||
{
|
{
|
||||||
throw new \RuntimeException($description);
|
throw new \RuntimeException($description);
|
||||||
|
|
||||||
|
// alternative to error throwing: append to $this->errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace PHPCensor\Plugin\Util\TestResultParsers;
|
namespace PHPCensor\Plugin\Util\TestResultParsers;
|
||||||
|
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Helper\Xml;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Codeception
|
* Class Codeception
|
||||||
|
@ -12,49 +11,23 @@ use PHPCensor\Helper\Xml;
|
||||||
*/
|
*/
|
||||||
class Codeception implements ParserInterface
|
class Codeception implements ParserInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var Builder
|
|
||||||
*/
|
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
protected $resultsXml;
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $xmlPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $results;
|
protected $results;
|
||||||
|
protected $totalTests;
|
||||||
/**
|
protected $totalTimeTaken;
|
||||||
* @var int
|
protected $totalFailures;
|
||||||
*/
|
protected $totalErrors;
|
||||||
protected $totalTests = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $totalTimeTaken = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $totalFailures = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $totalErrors = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $builder
|
* @param Builder $builder
|
||||||
* @param string $xmlPath
|
* @param $resultsXml
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $builder, $xmlPath)
|
public function __construct(Builder $builder, $resultsXml)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
$this->xmlPath = $xmlPath;
|
$this->resultsXml = $resultsXml;
|
||||||
|
$this->totalTests = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,43 +36,42 @@ class Codeception implements ParserInterface
|
||||||
public function parse()
|
public function parse()
|
||||||
{
|
{
|
||||||
$rtn = [];
|
$rtn = [];
|
||||||
$this->results = Xml::loadFromFile($this->xmlPath);
|
$this->results = new \SimpleXMLElement($this->resultsXml);
|
||||||
|
|
||||||
if ($this->results) {
|
// calculate total results
|
||||||
foreach ($this->results->testsuite as $testSuite) {
|
foreach ($this->results->testsuite as $testSuite) {
|
||||||
$this->totalTests += (int)$testSuite['tests'];
|
$this->totalTests += (int)$testSuite['tests'];
|
||||||
$this->totalTimeTaken += (float)$testSuite['time'];
|
$this->totalTimeTaken += (float)$testSuite['time'];
|
||||||
$this->totalFailures += (int)$testSuite['failures'];
|
$this->totalFailures += (int)$testSuite['failures'];
|
||||||
$this->totalErrors += (int)$testSuite['errors'];
|
$this->totalErrors += (int)$testSuite['errors'];
|
||||||
|
|
||||||
foreach ($testSuite->testcase as $testCase) {
|
foreach ($testSuite->testcase as $testCase) {
|
||||||
$testResult = [
|
$testResult = [
|
||||||
'suite' => (string)$testSuite['name'],
|
'suite' => (string)$testSuite['name'],
|
||||||
'file' => str_replace($this->builder->buildPath, '/', (string) $testCase['file']),
|
'file' => str_replace($this->builder->buildPath, '/', (string) $testCase['file']),
|
||||||
'name' => (string)$testCase['name'],
|
'name' => (string)$testCase['name'],
|
||||||
'feature' => (string)$testCase['feature'],
|
'feature' => (string)$testCase['feature'],
|
||||||
'assertions' => (int)$testCase['assertions'],
|
'assertions' => (int)$testCase['assertions'],
|
||||||
'time' => (float)$testCase['time']
|
'time' => (float)$testCase['time']
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($testCase['class'])) {
|
if (isset($testCase['class'])) {
|
||||||
$testResult['class'] = (string) $testCase['class'];
|
$testResult['class'] = (string) $testCase['class'];
|
||||||
}
|
|
||||||
|
|
||||||
// PHPUnit testcases does not have feature field. Use class::method instead
|
|
||||||
if (!$testResult['feature']) {
|
|
||||||
$testResult['feature'] = sprintf('%s::%s', $testResult['class'], $testResult['name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($testCase->failure) || isset($testCase->error)) {
|
|
||||||
$testResult['pass'] = false;
|
|
||||||
$testResult['message'] = isset($testCase->failure) ? (string)$testCase->failure : (string)$testCase->error;
|
|
||||||
} else {
|
|
||||||
$testResult['pass'] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rtn[] = $testResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PHPUnit testcases does not have feature field. Use class::method instead
|
||||||
|
if (!$testResult['feature']) {
|
||||||
|
$testResult['feature'] = sprintf('%s::%s', $testResult['class'], $testResult['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($testCase->failure) || isset($testCase->error)) {
|
||||||
|
$testResult['pass'] = false;
|
||||||
|
$testResult['message'] = isset($testCase->failure) ? (string)$testCase->failure : (string)$testCase->error;
|
||||||
|
} else {
|
||||||
|
$testResult['pass'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rtn[] = $testResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,18 @@ class ProjectTest extends TestCase
|
||||||
self::assertEquals(false, $result);
|
self::assertEquals(false, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOverwriteBuildConfig()
|
||||||
|
{
|
||||||
|
$project = new Project();
|
||||||
|
|
||||||
|
$result = $project->setOverwriteBuildConfig(false);
|
||||||
|
self::assertEquals(true, $result);
|
||||||
|
self::assertEquals(false, $project->getOverwriteBuildConfig());
|
||||||
|
|
||||||
|
$result = $project->setOverwriteBuildConfig(false);
|
||||||
|
self::assertEquals(false, $result);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAllowPublicStatus()
|
public function testAllowPublicStatus()
|
||||||
{
|
{
|
||||||
$project = new Project();
|
$project = new Project();
|
||||||
|
|
|
@ -75,6 +75,13 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
|
||||||
'reference' => 'php-censor/php-censor',
|
'reference' => 'php-censor/php-censor',
|
||||||
'origin' => 'git@sss.github.com:php-censor/php-censor.git',
|
'origin' => 'git@sss.github.com:php-censor/php-censor.git',
|
||||||
],
|
],
|
||||||
|
], [
|
||||||
|
'git@172.168.23.4:php-censor/php-censor.git', [
|
||||||
|
'user' => 'git',
|
||||||
|
'domain' => '172.168.23.4',
|
||||||
|
'reference' => 'php-censor/php-censor',
|
||||||
|
'origin' => 'git@172.168.23.4:php-censor/php-censor.git',
|
||||||
|
],
|
||||||
], [
|
], [
|
||||||
'ssh://git@github.com/php-censor/php-censor.git', [
|
'ssh://git@github.com/php-censor/php-censor.git', [
|
||||||
'user' => 'git',
|
'user' => 'git',
|
||||||
|
@ -82,12 +89,25 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
|
||||||
'reference' => 'php-censor/php-censor',
|
'reference' => 'php-censor/php-censor',
|
||||||
'origin' => 'ssh://git@github.com/php-censor/php-censor.git',
|
'origin' => 'ssh://git@github.com/php-censor/php-censor.git',
|
||||||
],
|
],
|
||||||
|
], [
|
||||||
|
'ssh://git@172.168.23.4/php-censor/php-censor.git', [
|
||||||
|
'user' => 'git',
|
||||||
|
'domain' => '172.168.23.4',
|
||||||
|
'reference' => 'php-censor/php-censor',
|
||||||
|
'origin' => 'ssh://git@172.168.23.4/php-censor/php-censor.git',
|
||||||
|
],
|
||||||
], [
|
], [
|
||||||
'https://github.com/php-censor/php-censor.git', [
|
'https://github.com/php-censor/php-censor.git', [
|
||||||
'domain' => 'github.com',
|
'domain' => 'github.com',
|
||||||
'reference' => 'php-censor/php-censor',
|
'reference' => 'php-censor/php-censor',
|
||||||
'origin' => 'https://github.com/php-censor/php-censor.git',
|
'origin' => 'https://github.com/php-censor/php-censor.git',
|
||||||
],
|
],
|
||||||
|
], [
|
||||||
|
'https://172.168.23.4/php-censor/php-censor.git', [
|
||||||
|
'domain' => '172.168.23.4',
|
||||||
|
'reference' => 'php-censor/php-censor',
|
||||||
|
'origin' => 'https://172.168.23.4/php-censor/php-censor.git',
|
||||||
|
],
|
||||||
], [
|
], [
|
||||||
'http://github.com/php-censor/php-censor.git', [
|
'http://github.com/php-censor/php-censor.git', [
|
||||||
'domain' => 'github.com',
|
'domain' => 'github.com',
|
||||||
|
@ -102,6 +122,14 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
|
||||||
'reference' => 'php-censor/php-censor',
|
'reference' => 'php-censor/php-censor',
|
||||||
'origin' => 'git@github.com:443/php-censor/php-censor.git',
|
'origin' => 'git@github.com:443/php-censor/php-censor.git',
|
||||||
],
|
],
|
||||||
|
], [
|
||||||
|
'git@172.168.23.4:443/php-censor/php-censor.git', [
|
||||||
|
'user' => 'git',
|
||||||
|
'domain' => '172.168.23.4',
|
||||||
|
'port' => '443',
|
||||||
|
'reference' => 'php-censor/php-censor',
|
||||||
|
'origin' => 'git@172.168.23.4:443/php-censor/php-censor.git',
|
||||||
|
],
|
||||||
], [
|
], [
|
||||||
'ssh://git@github.com:443/php-censor/php-censor.git', [
|
'ssh://git@github.com:443/php-censor/php-censor.git', [
|
||||||
'user' => 'git',
|
'user' => 'git',
|
||||||
|
@ -110,6 +138,14 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
|
||||||
'reference' => 'php-censor/php-censor',
|
'reference' => 'php-censor/php-censor',
|
||||||
'origin' => 'ssh://git@github.com:443/php-censor/php-censor.git',
|
'origin' => 'ssh://git@github.com:443/php-censor/php-censor.git',
|
||||||
],
|
],
|
||||||
|
], [
|
||||||
|
'ssh://git@172.168.23.4:443/php-censor/php-censor.git', [
|
||||||
|
'user' => 'git',
|
||||||
|
'domain' => '172.168.23.4',
|
||||||
|
'port' => '443',
|
||||||
|
'reference' => 'php-censor/php-censor',
|
||||||
|
'origin' => 'ssh://git@172.168.23.4:443/php-censor/php-censor.git',
|
||||||
|
],
|
||||||
], [
|
], [
|
||||||
'https://github.com:443/php-censor/php-censor.git', [
|
'https://github.com:443/php-censor/php-censor.git', [
|
||||||
'domain' => 'github.com',
|
'domain' => 'github.com',
|
||||||
|
@ -117,6 +153,13 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
|
||||||
'reference' => 'php-censor/php-censor',
|
'reference' => 'php-censor/php-censor',
|
||||||
'origin' => 'https://github.com:443/php-censor/php-censor.git',
|
'origin' => 'https://github.com:443/php-censor/php-censor.git',
|
||||||
],
|
],
|
||||||
|
], [
|
||||||
|
'https://172.168.23.4:443/php-censor/php-censor.git', [
|
||||||
|
'domain' => '172.168.23.4',
|
||||||
|
'port' => '443',
|
||||||
|
'reference' => 'php-censor/php-censor',
|
||||||
|
'origin' => 'https://172.168.23.4:443/php-censor/php-censor.git',
|
||||||
|
],
|
||||||
], [
|
], [
|
||||||
'http://github.com:443/php-censor/php-censor.git', [
|
'http://github.com:443/php-censor/php-censor.git', [
|
||||||
'domain' => 'github.com',
|
'domain' => 'github.com',
|
||||||
|
@ -180,7 +223,7 @@ class ProjectServiceTest extends \PHPUnit\Framework\TestCase
|
||||||
'reference' => 'php-censor',
|
'reference' => 'php-censor',
|
||||||
'origin' => 'http://github:443/php-censor.git',
|
'origin' => 'http://github:443/php-censor.git',
|
||||||
],
|
],
|
||||||
],
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue