[Pkg-owncloud-commits] [php-sabre-vobject] 16/25: Moved our PHPUnit helper into the public API.
David Prévot
taffit at moszumanska.debian.org
Thu Apr 7 01:41:29 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit c650b70ae06c10a86b025ae283f898205beb62c6
Author: Evert Pot <me at evertpot.com>
Date: Wed Apr 6 00:43:01 2016 -0400
Moved our PHPUnit helper into the public API.
---
.../TestCase.php => lib/PHPUnitAssertions.php | 13 ++++-
tests/VObject/TestCase.php | 64 +---------------------
2 files changed, 13 insertions(+), 64 deletions(-)
diff --git a/tests/VObject/TestCase.php b/lib/PHPUnitAssertions.php
similarity index 86%
copy from tests/VObject/TestCase.php
copy to lib/PHPUnitAssertions.php
index c1a63db..b36370d 100644
--- a/tests/VObject/TestCase.php
+++ b/lib/PHPUnitAssertions.php
@@ -2,7 +2,17 @@
namespace Sabre\VObject;
-class TestCase extends \PHPUnit_Framework_TestCase {
+/**
+ * PHPUnit Assertions
+ *
+ * This trait can be added to your unittest to make it easier to test iCalendar
+ * and/or vCards.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+trait PHPUnitAssertions {
/**
* This method tests wether two vcards or icalendar objects are
@@ -68,4 +78,5 @@ class TestCase extends \PHPUnit_Framework_TestCase {
}
+
}
diff --git a/tests/VObject/TestCase.php b/tests/VObject/TestCase.php
index c1a63db..af95387 100644
--- a/tests/VObject/TestCase.php
+++ b/tests/VObject/TestCase.php
@@ -4,68 +4,6 @@ namespace Sabre\VObject;
class TestCase extends \PHPUnit_Framework_TestCase {
- /**
- * This method tests wether two vcards or icalendar objects are
- * semantically identical.
- *
- * It supports objects being supplied as strings, streams or
- * Sabre\VObject\Component instances.
- *
- * PRODID is removed from both objects as this is often changes and would
- * just get in the way.
- *
- * CALSCALE will automatically get removed if it's set to GREGORIAN.
- *
- * Any property that has the value **ANY** will be treated as a wildcard.
- *
- * @param resource|string|Component $expected
- * @param resource|string|Component $actual
- * @param string $message
- */
- function assertVObjEquals($expected, $actual, $message = '') {
-
- $self = $this;
- $getObj = function($input) use ($self) {
-
- if (is_resource($input)) {
- $input = stream_get_contents($input);
- }
- if (is_string($input)) {
- $input = Reader::read($input);
- }
- if (!$input instanceof Component) {
- $this->fail('Input must be a string, stream or VObject component');
- }
- unset($input->PRODID);
- if ($input instanceof Component\VCalendar && (string)$input->CALSCALE === 'GREGORIAN') {
- unset($input->CALSCALE);
- }
- return $input;
-
- };
-
- $expected = $getObj($expected)->serialize();
- $actual = $getObj($actual)->serialize();
-
- // Finding wildcards in expected.
- preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\r$|m', $expected, $matches, PREG_SET_ORDER);
-
- foreach ($matches as $match) {
-
- $actual = preg_replace(
- '|^' . preg_quote($match[1], '|') . ':(.*)\r$|m',
- $match[1] . ':**ANY**' . "\r",
- $actual
- );
-
- }
-
- $this->assertEquals(
- $expected,
- $actual,
- $message
- );
-
- }
+ use PHPUnitAssertions;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list