From 907904183d106310f14512a3554e8023d1cb9ee5 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Sun, 15 Sep 2013 16:19:22 -0400 Subject: [PATCH] Provide access to test result via test instead of earl report. - Reduces memory consumption because global state is serialized for every test and the test result is large (do not link it to the earl report listener as it is global). --- test.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test.php b/test.php index 6678c8a..bbf90ea 100644 --- a/test.php +++ b/test.php @@ -18,6 +18,7 @@ class JsonLdTestCase extends PHPUnit_Framework_TestCase { public function run(PHPUnit_Framework_TestResult $result = NULL) { global $EARL; $EARL->attach($result); + $this->result = $result; parent::run($result); } @@ -439,7 +440,7 @@ class EarlReport extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener { public function __construct() { $this->filename = null; - $this->result = null; + $this->attached = false; $this->report = (object)array( '@context' => (object)array( 'doap' => 'http://usefulinc.com/ns/doap#', @@ -487,8 +488,8 @@ class EarlReport extends PHPUnit_Util_Printer * @param PHPUnit_Framework_Test $result the result to attach to. */ public function attach(PHPUnit_Framework_TestResult $result) { - if(!$this->result && $this->filename) { - $this->result = $result; + if(!$this->attached && $this->filename) { + $this->attached = true; $result->addListener($this); } } @@ -539,13 +540,12 @@ class EarlReport extends PHPUnit_Util_Printer PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { $this->addAssertion($test->test, false); - if($this->result->shouldStop()) { + if($test->result->shouldStop()) { printf("\n\nFAILED\n"); printf("Test: %s\n", $test->test->name); printf("Purpose: %s\n", $test->test->data->purpose); printf("EXPECTED: %s\n", Util::jsonldEncode($test->test->expected)); printf("ACTUAL: %s\n", Util::jsonldEncode($test->test->actual)); - exit(0); } }