From 061681f27b6a43d92542e36b76a786952de5a155 Mon Sep 17 00:00:00 2001 From: tdreis Date: Tue, 2 Aug 2016 12:49:11 -0300 Subject: [PATCH 01/13] Change name, to insert package on https://packagist.org. However, the credits are of Brianium. (https://github.com/brianium/paratest) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 551e9d7d..6e914f79 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "brianium/paratest", + "name": "tayguara/paratest", "require": { "php": ">=5.5.11", "phpunit/phpunit": ">=3.7.8", From 3b70176631517454f796244aeb0e39fc8a98beaf Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 09:26:08 -0300 Subject: [PATCH 02/13] Implemented the SystemOut on xml result, if the test has fail. --- src/ParaTest/Logging/JUnit/TestCase.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 004cc1c6..2798b840 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -122,14 +122,20 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['assertions'], (string) $node['time'] ); - $failures = $node->xpath('failure'); - $errors = $node->xpath('error'); + + $sys = "system-out"; + $node->failure = (string)$node->failure . (string)$node->{$sys}; + $failures = $node->xpath('failure'); + $errors = $node->xpath('error'); + while (list( , $fail) = each($failures)) { $case->addFailure((string)$fail['type'], (string)$fail); } + while (list( , $err) = each($errors)) { $case->addError((string)$err['type'], (string)$err); } + return $case; } } From 41943d108a128b9e14ef921bdb9daedac915bec1 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 09:30:00 -0300 Subject: [PATCH 03/13] Return to the "brianium/paratest" on composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6e914f79..551e9d7d 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "tayguara/paratest", + "name": "brianium/paratest", "require": { "php": ">=5.5.11", "phpunit/phpunit": ">=3.7.8", From 574f561042f4d0891b64383b75acf0b9ac57ffb0 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 11:01:13 -0300 Subject: [PATCH 04/13] Adjust on "system-out" log. --- src/ParaTest/Logging/JUnit/TestCase.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 2798b840..7a6e4197 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -123,8 +123,12 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['time'] ); - $sys = "system-out"; - $node->failure = (string)$node->failure . (string)$node->{$sys}; + if(!empty($node->failure)) + { + $sys = "system-out"; + $node->failure = (string)$node->failure . (string)$node->{$sys}; + } + $failures = $node->xpath('failure'); $errors = $node->xpath('error'); From 8a4930370f48153b21830471dd7c76c87ce249c6 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 11:36:37 -0300 Subject: [PATCH 05/13] Adjust on "system-out" log if result has error. --- src/ParaTest/Logging/JUnit/TestCase.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 7a6e4197..db7d65d6 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -129,8 +129,14 @@ public static function caseFromNode(\SimpleXMLElement $node) $node->failure = (string)$node->failure . (string)$node->{$sys}; } - $failures = $node->xpath('failure'); - $errors = $node->xpath('error'); + if(!empty($node->error)) + { + $sys = "system-out"; + $node->error = (string)$node->error . (string)$node->{$sys}; + } + + $failures = $node->xpath('failure'); + $errors = $node->xpath('error'); while (list( , $fail) = each($failures)) { $case->addFailure((string)$fail['type'], (string)$fail); From 4c92e5aa4e7c1bab7544978f478866b0bbe78a32 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 12:38:04 -0300 Subject: [PATCH 06/13] Adjust code style. --- src/ParaTest/Logging/JUnit/TestCase.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index db7d65d6..044ffedc 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -123,15 +123,13 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['time'] ); - if(!empty($node->failure)) - { - $sys = "system-out"; + $sys = "system-out"; + + if(!empty($node->failure)) { $node->failure = (string)$node->failure . (string)$node->{$sys}; } - if(!empty($node->error)) - { - $sys = "system-out"; + if(!empty($node->error)) { $node->error = (string)$node->error . (string)$node->{$sys}; } From 7700a35e2abd9cd57a00327a26b4548b611c5d78 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 12:42:56 -0300 Subject: [PATCH 07/13] Adjust on "system-out" log if result has error. --- src/ParaTest/Logging/JUnit/TestCase.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index db7d65d6..8119b3b4 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -123,16 +123,14 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['time'] ); - if(!empty($node->failure)) - { - $sys = "system-out"; - $node->failure = (string)$node->failure . (string)$node->{$sys}; + $sys = "system-out"; + + if(!empty($node->failure)) { + $node->failure = (string)$node->failure . (string)$node->{$sys}; } - if(!empty($node->error)) - { - $sys = "system-out"; - $node->error = (string)$node->error . (string)$node->{$sys}; + if(!empty($node->error)) { + $node->error = (string)$node->error . (string)$node->{$sys}; } $failures = $node->xpath('failure'); From f62803c0b7e45204ee1728fbd8c47d33e1f838e0 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 12:50:00 -0300 Subject: [PATCH 08/13] Adjust on code style. --- src/ParaTest/Logging/JUnit/TestCase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 044ffedc..25f1856a 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -123,14 +123,14 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['time'] ); - $sys = "system-out"; + $sys = 'system-out'; if(!empty($node->failure)) { - $node->failure = (string)$node->failure . (string)$node->{$sys}; + $node->failure = (string)$node->failure . (string)$node->{$sys}; } if(!empty($node->error)) { - $node->error = (string)$node->error . (string)$node->{$sys}; + $node->error = (string)$node->error . (string)$node->{$sys}; } $failures = $node->xpath('failure'); From 5290628d80eaf96d11c2a6eb58b0a634e7c69764 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 12:50:52 -0300 Subject: [PATCH 09/13] Adjust on code style. --- src/ParaTest/Logging/JUnit/TestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 8119b3b4..25f1856a 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -123,7 +123,7 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['time'] ); - $sys = "system-out"; + $sys = 'system-out'; if(!empty($node->failure)) { $node->failure = (string)$node->failure . (string)$node->{$sys}; From 3c8b9b2b0b1ad6f02c528467a23971b14e084802 Mon Sep 17 00:00:00 2001 From: tdreis Date: Wed, 3 Aug 2016 15:49:36 -0300 Subject: [PATCH 10/13] Update version --- src/ParaTest/Console/ParaTestApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParaTest/Console/ParaTestApplication.php b/src/ParaTest/Console/ParaTestApplication.php index 046c9dca..a7f8c898 100644 --- a/src/ParaTest/Console/ParaTestApplication.php +++ b/src/ParaTest/Console/ParaTestApplication.php @@ -11,7 +11,7 @@ class ParaTestApplication extends Application { const NAME = 'ParaTest'; - const VERSION = '0.13.3'; + const VERSION = '0.13.8'; public function __construct() { From 0d7faaee995db99eeb3472fc51505a0650437ba6 Mon Sep 17 00:00:00 2001 From: tdreis Date: Fri, 5 Aug 2016 17:36:59 -0300 Subject: [PATCH 11/13] Implementation of unit tests to validate results with and without custom "System Out". --- src/ParaTest/Logging/JUnit/TestCase.php | 32 +++++++++---- .../results/mixed-results-with-system-out.xml | 47 +++++++++++++++++++ .../ParaTest/Logging/JUnit/ReaderTest.php | 26 ++++++++++ 3 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/results/mixed-results-with-system-out.xml diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 25f1856a..9e7cec7a 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -105,6 +105,27 @@ protected function addDefect($collName, $type, $text) ); } + /** + * Add systemOut result on test (if has fail or have error) + * + * @param mixed $node + * @return mixed + */ + public static function addSystemOut($node) + { + $sys = 'system-out'; + + if(!empty($node->failure)) { + $node->failure = (string)$node->failure . (string)$node->{$sys}; + } + + if(!empty($node->error)) { + $node->error = (string)$node->error . (string)$node->{$sys}; + } + + return $node; + } + /** * Factory method that creates a TestCase object * from a SimpleXMLElement @@ -123,16 +144,7 @@ public static function caseFromNode(\SimpleXMLElement $node) (string) $node['time'] ); - $sys = 'system-out'; - - if(!empty($node->failure)) { - $node->failure = (string)$node->failure . (string)$node->{$sys}; - } - - if(!empty($node->error)) { - $node->error = (string)$node->error . (string)$node->{$sys}; - } - + $node = self::addSystemOut($node); $failures = $node->xpath('failure'); $errors = $node->xpath('error'); diff --git a/test/fixtures/results/mixed-results-with-system-out.xml b/test/fixtures/results/mixed-results-with-system-out.xml new file mode 100644 index 00000000..606ada59 --- /dev/null +++ b/test/fixtures/results/mixed-results-with-system-out.xml @@ -0,0 +1,47 @@ + + + + + + + UnitTestWithClassAnnotationTest::testFalsehood +Failed asserting that true is false. + +/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithClassAnnotationTest.php:20 + + + + + + + UnitTestWithErrorTest::testTruth +Exception: Error!!! + +/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithErrorTest.php:12 + + + + + + UnitTestWithErrorTest::testTruth +Exception: Error!!! + +/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithErrorTest.php:12 + + Custom error log on result test with error! + + + + + + UnitTestWithMethodAnnotationsTest::testFalsehood +Failed asserting that true is false. + +/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithMethodAnnotationsTest.php:18 + + Custom error log on result test with failure! + + + + + diff --git a/test/unit/ParaTest/Logging/JUnit/ReaderTest.php b/test/unit/ParaTest/Logging/JUnit/ReaderTest.php index 5e54617c..554f56a3 100644 --- a/test/unit/ParaTest/Logging/JUnit/ReaderTest.php +++ b/test/unit/ParaTest/Logging/JUnit/ReaderTest.php @@ -202,4 +202,30 @@ public function testRemoveLog() $reader->removeLog(); $this->assertFalse(file_exists($tmp)); } + + public function testResultWithoutSystemOut() + { + $result = FIXTURES . DS . 'results' . DS . 'mixed-results-with-system-out.xml'; + $failLog = "UnitTestWithClassAnnotationTest::testFalsehood\nFailed asserting that true is false.\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithClassAnnotationTest.php:20"; + $errorLog = "UnitTestWithErrorTest::testTruth\nException: Error!!!\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithErrorTest.php:12"; + $node = new Reader($result); + $resultFail = $node->getSuites()[0]->suites[0]->cases[1]->failures[0]['text']; + $resultError = $node->getSuites()[0]->suites[1]->cases[0]->errors[0]['text']; + + \PHPUnit_Framework_TestCase::assertEquals($failLog, $resultFail); + \PHPUnit_Framework_TestCase::assertEquals($errorLog, $resultError); + } + + public function testResultWithSystemOut() + { + $result = FIXTURES . DS . 'results' . DS . 'mixed-results-with-system-out.xml'; + $failLog = "UnitTestWithMethodAnnotationsTest::testFalsehood\nFailed asserting that true is false.\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithMethodAnnotationsTest.php:18\nCustom error log on result test with failure!"; + $errorLog = "UnitTestWithErrorTest::testTruth\nException: Error!!!\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithErrorTest.php:12\nCustom error log on result test with error!"; + $node = new Reader($result); + $resultFail = $node->getSuites()[0]->suites[2]->cases[1]->failures[0]['text']; + $resultError = $node->getSuites()[0]->suites[1]->cases[1]->errors[0]['text']; + + \PHPUnit_Framework_TestCase::assertEquals($failLog, $resultFail); + \PHPUnit_Framework_TestCase::assertEquals($errorLog, $resultError); + } } From e34d44dcf1c5fddac0f7a98922808eceb0dee08f Mon Sep 17 00:00:00 2001 From: tdreis Date: Fri, 5 Aug 2016 17:41:03 -0300 Subject: [PATCH 12/13] Implementation of unit tests to validate results with and without custom "System Out". --- src/ParaTest/Console/ParaTestApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParaTest/Console/ParaTestApplication.php b/src/ParaTest/Console/ParaTestApplication.php index a7f8c898..046c9dca 100644 --- a/src/ParaTest/Console/ParaTestApplication.php +++ b/src/ParaTest/Console/ParaTestApplication.php @@ -11,7 +11,7 @@ class ParaTestApplication extends Application { const NAME = 'ParaTest'; - const VERSION = '0.13.8'; + const VERSION = '0.13.3'; public function __construct() { From f7763afaa8b1973d5eee5cc769127e1c609679bf Mon Sep 17 00:00:00 2001 From: tdreis Date: Mon, 8 Aug 2016 08:54:13 -0300 Subject: [PATCH 13/13] Adjusts in code, after code review by Julian Seeger. --- src/ParaTest/Logging/JUnit/TestCase.php | 2 +- .../results/mixed-results-with-system-out.xml | 4 +-- .../ParaTest/Logging/JUnit/ReaderTest.php | 26 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/ParaTest/Logging/JUnit/TestCase.php b/src/ParaTest/Logging/JUnit/TestCase.php index 9e7cec7a..2582d19f 100644 --- a/src/ParaTest/Logging/JUnit/TestCase.php +++ b/src/ParaTest/Logging/JUnit/TestCase.php @@ -106,7 +106,7 @@ protected function addDefect($collName, $type, $text) } /** - * Add systemOut result on test (if has fail or have error) + * Add systemOut result on test (if has failed or have error) * * @param mixed $node * @return mixed diff --git a/test/fixtures/results/mixed-results-with-system-out.xml b/test/fixtures/results/mixed-results-with-system-out.xml index 606ada59..e01d0216 100644 --- a/test/fixtures/results/mixed-results-with-system-out.xml +++ b/test/fixtures/results/mixed-results-with-system-out.xml @@ -4,10 +4,10 @@ - UnitTestWithClassAnnotationTest::testFalsehood + UnitTestWithMethodAnnotationsTest::testFalsehood Failed asserting that true is false. -/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithClassAnnotationTest.php:20 +/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithMethodAnnotationsTest.php:18 diff --git a/test/unit/ParaTest/Logging/JUnit/ReaderTest.php b/test/unit/ParaTest/Logging/JUnit/ReaderTest.php index 554f56a3..d478a3a5 100644 --- a/test/unit/ParaTest/Logging/JUnit/ReaderTest.php +++ b/test/unit/ParaTest/Logging/JUnit/ReaderTest.php @@ -203,29 +203,33 @@ public function testRemoveLog() $this->assertFalse(file_exists($tmp)); } - public function testResultWithoutSystemOut() + /** + * Extraction of log from xml file to use in test of validation "SystemOut" result + * + * @return \stdClass $log + */ + public static function extractLog() { + $log = new \stdClass(); $result = FIXTURES . DS . 'results' . DS . 'mixed-results-with-system-out.xml'; - $failLog = "UnitTestWithClassAnnotationTest::testFalsehood\nFailed asserting that true is false.\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithClassAnnotationTest.php:20"; - $errorLog = "UnitTestWithErrorTest::testTruth\nException: Error!!!\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithErrorTest.php:12"; $node = new Reader($result); - $resultFail = $node->getSuites()[0]->suites[0]->cases[1]->failures[0]['text']; - $resultError = $node->getSuites()[0]->suites[1]->cases[0]->errors[0]['text']; + $log->failure = $node->getSuites()[0]->suites[0]->cases[1]->failures[0]['text']; + $log->error = $node->getSuites()[0]->suites[1]->cases[0]->errors[0]['text']; - \PHPUnit_Framework_TestCase::assertEquals($failLog, $resultFail); - \PHPUnit_Framework_TestCase::assertEquals($errorLog, $resultError); + return $log; } public function testResultWithSystemOut() { + $customLog = "\nCustom error log on result test with "; $result = FIXTURES . DS . 'results' . DS . 'mixed-results-with-system-out.xml'; - $failLog = "UnitTestWithMethodAnnotationsTest::testFalsehood\nFailed asserting that true is false.\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithMethodAnnotationsTest.php:18\nCustom error log on result test with failure!"; - $errorLog = "UnitTestWithErrorTest::testTruth\nException: Error!!!\n\n/home/brian/Projects/parallel-phpunit/test/fixtures/tests/UnitTestWithErrorTest.php:12\nCustom error log on result test with error!"; + $failLog = self::extractLog()->failure . $customLog . "failure!"; + $errorLog = self::extractLog()->error . $customLog . "error!"; $node = new Reader($result); $resultFail = $node->getSuites()[0]->suites[2]->cases[1]->failures[0]['text']; $resultError = $node->getSuites()[0]->suites[1]->cases[1]->errors[0]['text']; - \PHPUnit_Framework_TestCase::assertEquals($failLog, $resultFail); - \PHPUnit_Framework_TestCase::assertEquals($errorLog, $resultError); + $this->assertEquals($failLog, $resultFail); + $this->assertEquals($errorLog, $resultError); } }