From f785bf0565ea6f99cde77b077f5f813b53180a8d Mon Sep 17 00:00:00 2001 From: Patrick Saint - laurent Date: Thu, 8 Oct 2015 18:32:53 -0400 Subject: [PATCH] Update phpunit-extensions to use sebastianbergmann/exporter --- PHPUnit/Extensions/Constraint/ArrayEqualsNoOrder.php | 5 +++++ PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php | 8 ++++++-- PHPUnit/Extensions/Constraint/EqualsClosure.php | 7 +++++-- PHPUnit/Extensions/Constraint/HasItems.php | 6 +++++- .../Extensions/Constraint/StringMatchIgnoreWhitespace.php | 6 +++++- PHPUnit/Extensions/MockObject/Stub/ReturnMapping.php | 8 ++++++-- composer.json | 1 + 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/PHPUnit/Extensions/Constraint/ArrayEqualsNoOrder.php b/PHPUnit/Extensions/Constraint/ArrayEqualsNoOrder.php index bf88c05..c2f6b32 100644 --- a/PHPUnit/Extensions/Constraint/ArrayEqualsNoOrder.php +++ b/PHPUnit/Extensions/Constraint/ArrayEqualsNoOrder.php @@ -1,5 +1,7 @@ exporter = new Exporter; $this->setConstraints( array( new PHPUnit_Extensions_Constraint_HasItems($expected), diff --git a/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php b/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php index 8c29c73..6924cd6 100644 --- a/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php +++ b/PHPUnit/Extensions/Constraint/ArrayHasKeyValuePair.php @@ -1,5 +1,7 @@ key = $key; $this->value = $value; + $this->exporter = new Exporter; } /** @@ -47,8 +51,8 @@ protected function matches($other) */ public function toString() { - return 'has the key ' . PHPUnit_Util_Type::export($this->key) . - ' with the value ' . PHPUnit_Util_Type::export($this->value); + return 'has the key ' . $this->exporter->export($this->key) . + ' with the value ' . $this->exporter->export($this->value); } /** diff --git a/PHPUnit/Extensions/Constraint/EqualsClosure.php b/PHPUnit/Extensions/Constraint/EqualsClosure.php index 42d74c6..4e495d8 100644 --- a/PHPUnit/Extensions/Constraint/EqualsClosure.php +++ b/PHPUnit/Extensions/Constraint/EqualsClosure.php @@ -1,14 +1,17 @@ expected = $expected; $this->closure = $closure; + $this->exporter = new Exporter; } protected function matches($actual) { @@ -20,7 +23,7 @@ protected function matches($actual) { public function toString() { return sprintf('is equal to %s', - PHPUnit_Util_Type::export($this->expected) + $this->exporter->export($this->expected) ); } -} \ No newline at end of file +} diff --git a/PHPUnit/Extensions/Constraint/HasItems.php b/PHPUnit/Extensions/Constraint/HasItems.php index e7a8f1e..12cd594 100644 --- a/PHPUnit/Extensions/Constraint/HasItems.php +++ b/PHPUnit/Extensions/Constraint/HasItems.php @@ -1,5 +1,7 @@ expected = $expected; + $this->exporter = new Exporter; } protected function matches($other) { @@ -28,7 +32,7 @@ protected function matches($other) { public function toString() { return sprintf('has items %s', - PHPUnit_Util_Type::export($this->expected)); + $this->exporter->export($this->expected)); } } diff --git a/PHPUnit/Extensions/Constraint/StringMatchIgnoreWhitespace.php b/PHPUnit/Extensions/Constraint/StringMatchIgnoreWhitespace.php index d5f08b0..cd060a2 100644 --- a/PHPUnit/Extensions/Constraint/StringMatchIgnoreWhitespace.php +++ b/PHPUnit/Extensions/Constraint/StringMatchIgnoreWhitespace.php @@ -1,5 +1,7 @@ expected = $expected; + $this->exporter = new Exporter; } protected function matches($actual) { @@ -23,7 +27,7 @@ private function normalize($string) { public function toString() { return sprintf( 'equals ignoring whitespace %s', - PHPUnit_Util_Type::export($this->normalize($this->expected))); + $this->exporter->export($this->normalize($this->expected))); } } diff --git a/PHPUnit/Extensions/MockObject/Stub/ReturnMapping.php b/PHPUnit/Extensions/MockObject/Stub/ReturnMapping.php index cebf2d6..7915405 100644 --- a/PHPUnit/Extensions/MockObject/Stub/ReturnMapping.php +++ b/PHPUnit/Extensions/MockObject/Stub/ReturnMapping.php @@ -1,11 +1,13 @@ return_map = $return_map; $this->default = $default; + $this->exporter = new Exporter; } /** @@ -26,6 +29,7 @@ public function __construct( * @return the invocation of the Entry with matching parameters. */ public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) { + foreach ($this->return_map as $entry) { if ($entry->matches($invocation)) { return $entry->invoke($invocation); @@ -39,7 +43,7 @@ public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) { PHPUnit_Framework_Assert::fail( sprintf( 'No return value defined for %s', - PHPUnit_Util_Type::export($invocation->parameters))); + $this->exporter->export($invocation->parameters))); } public function toString() { diff --git a/composer.json b/composer.json index dcb3143..c2db684 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "require": { "php": ">=5.3.6", "phpunit/PHPUnit": ">=3.6.10", + "sebastian/exporter": "1.0.*", "mockery/mockery": "0.8.0" }, "autoload": {