aboutsummaryrefslogtreecommitdiff
path: root/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests
diff options
context:
space:
mode:
authorDalyn Cessac <dalyn.cessac@1214036.no-reply.drupal.org>2011-03-16 11:06:40 -0500
committerDalyn Cessac <dalyn.cessac@1214036.no-reply.drupal.org>2011-03-16 11:06:40 -0500
commita435de089da4dd37c3c183f633a49107c720dd95 (patch)
tree5f92decbf2d4bb27f85c49bfc5b4fcaf938b58b4 /libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests
parenta31b9883849b0a04420ee1d476fbe08c87bc5d53 (diff)
downloadvideo-a435de089da4dd37c3c183f633a49107c720dd95.tar.gz
video-a435de089da4dd37c3c183f633a49107c720dd95.tar.bz2
Added phpvideotoolkit transcoder and updates to the preset ui
Diffstat (limited to 'libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests')
-rw-r--r--libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/Makefile44
-rw-r--r--libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestAll.php59
-rw-r--r--libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3Frame.php1218
-rw-r--r--libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v1.php194
-rw-r--r--libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v2.php139
-rw-r--r--libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestTransform.php221
6 files changed, 1875 insertions, 0 deletions
diff --git a/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/Makefile b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/Makefile
new file mode 100644
index 0000000..9f88faa
--- /dev/null
+++ b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/Makefile
@@ -0,0 +1,44 @@
+#
+# PHP Reader Library
+#
+# Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# - Neither the name of the project workgroup nor the names of its
+# contributors may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# $Id: Makefile 64 2008-04-01 10:38:12Z svollbehr $
+#
+
+CLEANFILES = *~
+ax_prog_tput = `which tput 2>/dev/null`
+
+all:
+ @if test -n "${ax_prog_tput}"; then \
+ ${ax_prog_tput} bold 2>/dev/null; \
+ fi;
+ @echo -e "\nMaking tests ...\n";
+ @if test -n "${ax_prog_tput}"; then \
+ ${ax_prog_tput} sgr0 2>/dev/null; \
+ fi;
+ @php -f TestAll.php
diff --git a/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestAll.php b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestAll.php
new file mode 100644
index 0000000..0d609ee
--- /dev/null
+++ b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestAll.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * PHP Reader Library
+ *
+ * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the project workgroup nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Id: TestAll.php 107 2008-08-03 19:09:16Z svollbehr $
+ */
+
+/**#@+ @ignore */
+require_once("PHPUnit/Framework.php");
+require_once("PHPUnit/TextUI/TestRunner.php");
+
+ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . "../src/");
+ini_set("memory_limit", "16M");
+
+$suite = new PHPUnit_Framework_TestSuite("PHP Reader");
+
+$dir = opendir(dirname(__FILE__));
+while (($file = readdir($dir)) !== false) {
+ if ($file == basename(__FILE__))
+ continue;
+ if (preg_match("/^Test.+\.php$/", $file)) {
+ require_once($file);
+ $suite->addTestSuite(substr($file, 0, -4));
+ }
+}
+closedir($dir);
+
+PHPUnit_TextUI_TestRunner::run($suite);
+/**#@-*/
diff --git a/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3Frame.php b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3Frame.php
new file mode 100644
index 0000000..fd84a32
--- /dev/null
+++ b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3Frame.php
@@ -0,0 +1,1218 @@
+<?php
+/**
+ * PHP Reader Library
+ *
+ * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the project workgroup nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Id: TestID3Frame.php 111 2008-09-05 17:20:56Z svollbehr $
+ */
+
+/**#@+ @ignore */
+require_once("PHPUnit/Framework.php");
+require_once("Reader.php");
+/**#@-*/
+
+/**
+ * Unit test case for all ID3 frames.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @author Ryan Butterfield <buttza@gmail.com>
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Rev: 111 $
+ */
+final class TestID3Frame extends PHPUnit_Framework_TestCase
+{
+ private $testText = "abcdefghijklmnopqrstuvwxyz1234567890!@#\$%^&*()-";
+ private $testLink = "http://www.abcdefghijklmnopqrstuvwxyz.com.xyz/qwerty.php?asdf=1234&zxcv=%20";
+ private $testDate = "20070707";
+ private $testCurrency = "AUD";
+ private $testIdentifier = "TEST";
+ private $testPrice = "169.12";
+ private $testInt8 = -0x7a;
+ private $testInt16 = -0x7aff;
+ private $testInt24 = 0x7affca;
+ private $testInt32 = -0x7affcafe;
+ private $testUInt8 = 0xfa;
+ private $testUInt16 = 0xfaff;
+ private $testUInt32 = 0xfaffcafe;
+
+ /**
+ * Data provider for the ID3 frame test case. Finds all frames and builds
+ * input combinations necessary to test all variations of each frame.
+ */
+ public static function provider()
+ {
+ /* Ignore WIP frames */
+ $ignore = array("ASPI.php", "MLLT.php");
+
+ /* Load all frames */
+ $dir = opendir("../src/ID3/Frame");
+ while (($file = readdir($dir)) !== false)
+ if (preg_match("/^.+\.php$/", $file) && !in_array($file, $ignore))
+ require_once("ID3/Frame/" . $file);
+ foreach (get_declared_classes() as $class)
+ if (strpos($class, "ID3_Frame_") === 0)
+ $identifiers[] = substr($class, 10);
+ closedir($dir);
+
+ /* Build up all valid combinations */
+ $tests = array();
+ foreach ($identifiers as $identifier)
+ {
+ if (!method_exists("TestID3Frame", "frame" . $identifier . "0"))
+ continue; // skip if no handlers registered
+
+ $class = "ID3_Frame_" . $identifier;
+ $encodings = $languages = $timings = array(null);
+ if (in_array("ID3_Encoding", class_implements($class)))
+ array_push($encodings, ID3_Encoding::ISO88591, ID3_Encoding::UTF16,
+ ID3_Encoding::UTF16BE, ID3_Encoding::UTF8);
+ if (in_array("ID3_Language", class_implements($class)))
+ array_push($languages, "eng", "und");
+ if (in_array("ID3_Timing", class_implements($class)))
+ array_push($timings, ID3_Timing::MPEG_FRAMES, ID3_Timing::MILLISECONDS);
+
+ foreach ($encodings as $encoding)
+ foreach ($languages as $language)
+ foreach ($timings as $timing)
+ $tests[] = array($identifier, $encoding, $language, $timing);
+ }
+
+ return $tests;
+ }
+
+ /**
+ * Test a given frame by identifier, its text encoding (if provided),
+ * its language (if provided) and its timing (also if provided).
+ *
+ * The test involves finding frame functions that will test the given frame
+ * identifier, constructing and setting up the frame, testing the constructed
+ * frame, saving the frame to a string then re-creating the frame using the
+ * string and testing for a final time.
+ *
+ * @param string $identifier The frame identifier.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ *
+ * @dataProvider provider
+ */
+ public function testFrame($identifier, $encoding, $language, $timing)
+ {
+ /* Iterate through all test case functions for this frame identifier */
+ $class = "ID3_Frame_" . $identifier;
+ $test = 0;
+ while (method_exists($this, $method = "frame" . $identifier . $test++)) {
+
+ /* Setup and verify the frame */
+ $frame = new $class();
+ call_user_func(array($this, $method),
+ $frame, true, $encoding, $language, $timing);
+ call_user_func(array($this, $method),
+ $frame, false, $encoding, $language, $timing);
+
+ if (isset($encoding)) {
+ $this->assertTrue(method_exists($frame, "setEncoding"));
+ $frame->setEncoding($encoding);
+ $this->assertTrue(method_exists($frame, "getEncoding"));
+ $this->assertEquals($encoding, $frame->getEncoding());
+ }
+ if (isset($language)) {
+ $this->assertTrue(method_exists($frame, "setLanguage"));
+ $frame->setLanguage($language);
+ $this->assertTrue(method_exists($frame, "getLanguage"));
+ $this->assertEquals($language, $frame->getLanguage());
+ }
+ if (isset($timing)) {
+ $this->assertTrue(method_exists($frame, "setFormat"));
+ $frame->setFormat($timing);
+ $this->assertTrue(method_exists($frame, "getFormat"));
+ $this->assertEquals($timing, $frame->getFormat());
+ }
+
+ for ($i = 0; $i < 2; $i++) {
+ /* Convert to string representation and store in an in-memory buffer */
+ if ($i > 0)
+ $existing = $data;
+ $length = strlen($data = "" . $frame);
+ if ($i > 0)
+ $this->assertEquals($existing, $data);
+ $this->assertTrue(($fd = fopen("php://temp", "r+b")) !== false);
+ $this->assertEquals($length, fwrite($fd, $data, $length));
+ $this->assertTrue(rewind($fd));
+
+ /* Construct a frame using the reader and verify */
+ $frame = new $class($reader = new Reader($fd));
+ call_user_func(array($this, $method),
+ $frame, false, $encoding, $language, $timing);
+ if (isset($encoding))
+ $this->assertEquals($encoding, $frame->getEncoding());
+ if (isset($language))
+ $this->assertEquals($language, $frame->getLanguage());
+ if (isset($timing))
+ $this->assertEquals($timing, $frame->getFormat());
+ }
+ }
+ }
+
+ /**
+ * The first AbstractLink frame test.
+ *
+ * @param ID3_Frame_AbstractLink $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ /*private function frameAbstractLink0(&$frame, $construct, $encoding, $language, $timing) {
+ $link = $this->testLink;
+
+ if ($construct)
+ $frame->setLink($link);
+ else
+ $this->assertEquals($link, $frame->getLink());
+ }*/
+
+ /**
+ * The first AbstractText frame test.
+ *
+ * @param ID3_Frame_AbstractText $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ /*private function frameAbstractText0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $text = $this->convert($this->testText, $encoding);
+
+ if ($construct)
+ $frame->setText($text);
+ else
+ $this->assertEquals($text, $frame->getText());
+ }*/
+
+ /**
+ * The first AENC frame test.
+ *
+ * @param ID3_Frame_AENC $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameAENC0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $owner = $this->testText;
+ $previewStart = $this->testUInt16;
+ $previewLength = $this->testUInt16 - 1;
+ $encryptionInfo = $this->testText;
+
+ if ($construct) {
+ $frame->setOwner($owner);
+ $frame->setPreviewStart($previewStart);
+ $frame->setPreviewLength($previewLength);
+ $frame->setEncryptionInfo($encryptionInfo);
+ } else {
+ $this->assertEquals($owner, $frame->getOwner());
+ $this->assertEquals($previewStart, $frame->getPreviewStart());
+ $this->assertEquals($previewLength, $frame->getPreviewLength());
+ $this->assertEquals($encryptionInfo, $frame->getEncryptionInfo());
+ }
+ }
+
+ /**
+ * The first APIC frame test.
+ *
+ * @param ID3_Frame_APIC $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameAPIC0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $mimeType = $this->testText;
+ $imageType = $this->testUInt8;
+ $description = $this->convert($this->testText, $encoding);
+ $imageData = $this->testText;
+ $imageSize = strlen($imageData);
+
+ if ($construct) {
+ $frame->setMimeType($mimeType);
+ $frame->setImageType($imageType);
+ $frame->setDescription($description);
+ $frame->setImageData($imageData);
+ } else {
+ $this->assertEquals($mimeType, $frame->getMimeType());
+ $this->assertEquals($imageType, $frame->getImageType());
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($imageData, $frame->getImageData());
+ $this->assertEquals($imageSize, $frame->getImageSize());
+ }
+ }
+
+ /**
+ * The first COMM frame test.
+ *
+ * @param ID3_Frame_COMM $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameCOMM0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $description = $this->convert($this->testText, $encoding);
+ $text = $this->convert($this->testText, $encoding);
+
+ if ($construct) {
+ $frame->setDescription($description);
+ $frame->setText($text);
+ } else {
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($text, $frame->getText());
+ }
+ }
+
+ /**
+ * The first COMR frame test.
+ *
+ * @param ID3_Frame_COMR $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameCOMR0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $currency = $this->testCurrency;
+ $price = $this->testText;
+ $date = $this->testDate;
+ $contact = $this->testLink;
+ $delivery = $this->testUInt8;
+ $seller = $this->convert($this->testText, $encoding);
+ $description = $this->convert($this->testText, $encoding);
+ $mimeType = $this->testText;
+ $imageData = $this->testText;
+ $imageSize = strlen($imageData);
+
+ if ($construct) {
+ $frame->setCurrency($currency);
+ $frame->setPrice($price);
+ $frame->setDate($date);
+ $frame->setContact($contact);
+ $frame->setDelivery($delivery);
+ $frame->setSeller($seller);
+ $frame->setDescription($description);
+ $frame->setMimeType($mimeType);
+ $frame->setImageData($imageData);
+ } else {
+ $this->assertEquals($currency, $frame->getCurrency());
+ $this->assertEquals($price, $frame->getPrice());
+ $this->assertEquals($date, $frame->getDate());
+ $this->assertEquals($contact, $frame->getContact());
+ $this->assertEquals($delivery, $frame->getDelivery());
+ $this->assertEquals($seller, $frame->getSeller());
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($mimeType, $frame->getMimeType());
+ $this->assertEquals($imageData, $frame->getImageData());
+ $this->assertEquals($imageSize, $frame->getImageSize());
+ }
+ }
+
+ /**
+ * The first ENCR frame test.
+ *
+ * @param ID3_Frame_ENCR $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameENCR0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $owner = $this->testLink;
+ $method = $this->testInt8;
+ $encryptionData = $this->testText;
+
+ if ($construct) {
+ $frame->setOwner($owner);
+ $frame->setMethod($method);
+ $frame->setEncryptionData($encryptionData);
+ } else {
+ $this->assertEquals($owner, $frame->getOwner());
+ $this->assertEquals($method, $frame->getMethod());
+ $this->assertEquals($encryptionData, $frame->getEncryptionData());
+ }
+ }
+
+ /**
+ * The first EQU2 frame test.
+ *
+ * @param ID3_Frame_EQU2 $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameEQU20
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $interpolation = $this->testInt8;
+ $device = $this->testText;
+ $adjustments[0] = -32767.0 / 512.0;
+ $adjustments[2047] = -1.0;
+ $adjustments[8191] = 0.0;
+ $adjustments[16383] = 1.0;
+ $adjustments[32767] = 32767.0 / 512.0;
+
+ if ($construct) {
+ foreach ($adjustments as $frequency => $adjustment)
+ $frame->addAdjustment($frequency, $adjustment);
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+
+ $frame->setInterpolation($interpolation);
+ $frame->setDevice($device);
+ $frame->setAdjustments($adjustments);
+ } else {
+ $this->assertEquals($interpolation, $frame->getInterpolation());
+ $this->assertEquals($device, $frame->getDevice());
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+ }
+
+ /**
+ * The first EQUA frame test.
+ *
+ * @param ID3_Frame_EQUA $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameEQUA0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $adjustments[0] = -65535;
+ $adjustments[2047] = -4096;
+ $adjustments[8191] = 0;
+ $adjustments[16383] = 4096;
+ $adjustments[32767] = 65535;
+
+ if ($construct) {
+ foreach ($adjustments as $frequency => $adjustment)
+ $frame->addAdjustment($frequency, $adjustment);
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+
+ $frame->setAdjustments($adjustments);
+ } else {
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+ }
+
+ /**
+ * The first ETCO frame test.
+ *
+ * @param ID3_Frame_ETCO $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameETCO0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $events[0] = array_search("Intro end", ID3_Frame_ETCO::$types);
+ $events[0xFFFF] = array_search("Verse start", ID3_Frame_ETCO::$types);
+ $events[0xFFFFF] = array_search("Verse end", ID3_Frame_ETCO::$types);
+ $events[0xFFFFFF] = array_search
+ ("Audio end (start of silence)", ID3_Frame_ETCO::$types);
+ $events[0xFFFFFFFF] = array_search
+ ("Audio file ends", ID3_Frame_ETCO::$types);
+
+ if ($construct)
+ $frame->setEvents($events);
+ else
+ $this->assertEquals($events, $frame->getEvents());
+ }
+
+ /**
+ * The first GEOB frame test.
+ *
+ * @param ID3_Frame_GEOB $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameGEOB0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $mimeType = $this->testText;
+ $filename = $this->convert($this->testText, $encoding);
+ $description = $this->convert($this->testText, $encoding);
+ $objectData = $this->testText;
+
+ if ($construct) {
+ $frame->setMimeType($mimeType);
+ $frame->setFilename($filename);
+ $frame->setDescription($description);
+ $frame->setObjectData($objectData);
+ } else {
+ $this->assertEquals($mimeType, $frame->getMimeType());
+ $this->assertEquals($filename, $frame->getFilename());
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($objectData, $frame->getObjectData());
+ }
+ }
+
+ /**
+ * The first GRID frame test.
+ *
+ * @param ID3_Frame_GRID $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameGRID0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $owner = $this->testLink;
+ $group = $this->testUInt8;
+ $groupData = $this->testText;
+
+ if ($construct) {
+ $frame->setOwner($owner);
+ $frame->setGroup($group);
+ $frame->setGroupData($groupData);
+ } else {
+ $this->assertEquals($owner, $frame->getOwner());
+ $this->assertEquals($group, $frame->getGroup());
+ $this->assertEquals($groupData, $frame->getGroupData());
+ }
+ }
+
+ /**
+ * The first IPLS frame test.
+ *
+ * @param ID3_Frame_IPLS $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameIPLS0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $testText = $this->convert($this->testText, $encoding);
+ for ($i = 0; $i < 3; $i++)
+ $people[] = array($testText => $testText);
+
+ if ($construct) {
+ foreach ($people as $entry)
+ foreach ($entry as $involvement => $person)
+ $frame->addPerson($involvement, $person);
+ $this->assertEquals($people, $frame->getPeople());
+
+ $frame->setPeople($people);
+ } else {
+ $this->assertEquals($people, $frame->getPeople());
+ }
+ }
+
+ /**
+ * The first LINK frame test.
+ *
+ * @param ID3_Frame_LINK $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameLINK0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $target = $this->testIdentifier;
+ $url = $this->testLink;
+ $qualifier = $this->testText;
+
+ if ($construct) {
+ $frame->setTarget($target);
+ $frame->setUrl($url);
+ $frame->setQualifier($qualifier);
+ } else {
+ $this->assertEquals($target, $frame->getTarget());
+ $this->assertEquals($url, $frame->getUrl());
+ $this->assertEquals($qualifier, $frame->getQualifier());
+ }
+ }
+
+ /**
+ * The first MCDI frame test.
+ *
+ * @param ID3_Frame_MCDI $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameMCDI0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $data = $this->testText;
+
+ if ($construct)
+ $frame->setData($data);
+ else
+ $this->assertEquals($data, $frame->getData());
+ }
+
+ /**
+ * The first OWNE frame test.
+ *
+ * @param ID3_Frame_OWNE $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameOWNE0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $currency = $this->testCurrency;
+ $price = $this->testPrice;
+ $date = $this->testDate;
+ $seller = $this->convert($this->testText, $encoding);
+
+ if ($construct) {
+ $frame->setCurrency($currency);
+ $frame->setPrice(0.0 + $price);
+ $frame->setDate($date);
+ $frame->setSeller($seller);
+ } else {
+ $this->assertEquals($currency, $frame->getCurrency());
+ $this->assertEquals($price, $frame->getPrice());
+ $this->assertEquals($date, $frame->getDate());
+ $this->assertEquals($seller, $frame->getSeller());
+ }
+ }
+
+ /**
+ * The first PCNT frame test.
+ *
+ * @param ID3_Frame_PCNT $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function framePCNT0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $counter = $this->testUInt32;
+
+ if ($construct) {
+ for ($i = 0; $i < 123; $i++)
+ $frame->addCounter();
+ $this->assertEquals(123, $frame->getCounter());
+
+ $frame->setCounter($counter);
+ } else {
+ $this->assertEquals($counter, $frame->getCounter());
+ }
+ }
+
+ /**
+ * The first POPM frame test.
+ *
+ * @param ID3_Frame_POPM $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function framePOPM0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $owner = $this->testLink;
+ $rating = $this->testUInt8;
+ $counter = $this->testUInt32;
+
+ if ($construct) {
+ $frame->setOwner($owner);
+ $frame->setRating($rating);
+ $frame->setCounter($counter);
+ } else {
+ $this->assertEquals($owner, $frame->getOwner());
+ $this->assertEquals($rating, $frame->getRating());
+ $this->assertEquals($counter, $frame->getCounter());
+ }
+ }
+
+ /**
+ * The first POSS frame test.
+ *
+ * @param ID3_Frame_POSS $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function framePOSS0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $position = $this->testUInt32;
+
+ if ($construct)
+ $frame->setPosition($position);
+ else
+ $this->assertEquals($position, $frame->getPosition());
+ }
+
+ /**
+ * The first PRIV frame test.
+ *
+ * @param ID3_Frame_PRIV $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function framePRIV0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $owner = $this->testText;
+ $privateData = $this->testText;
+
+ if ($construct) {
+ $frame->setOwner($owner);
+ $frame->setPrivateData($privateData);
+ } else {
+ $this->assertEquals($owner, $frame->getOwner());
+ $this->assertEquals($privateData, $frame->getPrivateData());
+ }
+ }
+
+ /**
+ * The first RBUF frame test.
+ *
+ * @param ID3_Frame_RBUF $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRBUF0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $bufferSize = $this->testInt24;
+ $flags = $this->testInt8;
+ $offset = $this->testInt32;
+
+ if ($construct) {
+ $frame->setBufferSize($bufferSize);
+ $frame->setInfoFlags($flags);
+ $frame->setOffset($offset);
+ } else {
+ $this->assertEquals($bufferSize, $frame->getBufferSize());
+ $this->assertEquals($flags, $frame->getInfoFlags());
+ $this->assertEquals($offset, $frame->getOffset());
+ }
+ }
+
+ /**
+ * The first RVA2 frame test.
+ *
+ * @param ID3_Frame_RVA2 $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRVA20
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $device = $this->testText;
+ $adjustments[0] = array(ID3_Frame_RVA2::channelType => 0,
+ ID3_Frame_RVA2::volumeAdjustment => -32767.0 / 512.0,
+ ID3_Frame_RVA2::peakVolume => 0x0);
+ $adjustments[1] = array(ID3_Frame_RVA2::channelType => 1,
+ ID3_Frame_RVA2::volumeAdjustment => -8191.0 / 512.0,
+ ID3_Frame_RVA2::peakVolume => 0x7f);
+ $adjustments[2] = array(ID3_Frame_RVA2::channelType => 2,
+ ID3_Frame_RVA2::volumeAdjustment => -2047.0 / 512.0,
+ ID3_Frame_RVA2::peakVolume => 0xff);
+ $adjustments[3] = array(ID3_Frame_RVA2::channelType => 3,
+ ID3_Frame_RVA2::volumeAdjustment => -1.0,
+ ID3_Frame_RVA2::peakVolume => 0x7fff);
+ $adjustments[4] = array(ID3_Frame_RVA2::channelType => 4,
+ ID3_Frame_RVA2::volumeAdjustment => 0.0,
+ ID3_Frame_RVA2::peakVolume => 0xffff);
+ $adjustments[5] = array(ID3_Frame_RVA2::channelType => 5,
+ ID3_Frame_RVA2::volumeAdjustment => 1.0,
+ ID3_Frame_RVA2::peakVolume => 0x7fffff);
+ $adjustments[6] = array(ID3_Frame_RVA2::channelType => 6,
+ ID3_Frame_RVA2::volumeAdjustment => 2047.0 / 512.0,
+ ID3_Frame_RVA2::peakVolume => 0xffffff);
+ $adjustments[7] = array(ID3_Frame_RVA2::channelType => 7,
+ ID3_Frame_RVA2::volumeAdjustment => 8191.0 / 512.0,
+ ID3_Frame_RVA2::peakVolume => 0x7fffffff);
+ $adjustments[8] = array(ID3_Frame_RVA2::channelType => 8,
+ ID3_Frame_RVA2::volumeAdjustment => 32767.0 / 512.0,
+ ID3_Frame_RVA2::peakVolume => 0xffffffff);
+
+ if ($construct) {
+ $frame->setDevice($device);
+ $frame->setAdjustments($adjustments);
+ } else {
+ $this->assertEquals($device, $frame->getDevice());
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+ }
+
+ /**
+ * The first RVAD frame test.
+ *
+ * @param ID3_Frame_RVAD $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRVAD0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $adjustments[ID3_Frame_RVAD::right] = -0xffff;
+ $adjustments[ID3_Frame_RVAD::left] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
+
+ if ($construct)
+ $frame->setAdjustments($adjustments);
+ else
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+
+ /**
+ * The second RVAD frame test.
+ *
+ * @param ID3_Frame_RVAD $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRVAD1
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $adjustments[ID3_Frame_RVAD::right] = -0xffff;
+ $adjustments[ID3_Frame_RVAD::left] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
+ $adjustments[ID3_Frame_RVAD::rightBack] = -0xff;
+ $adjustments[ID3_Frame_RVAD::leftBack] = 0xff;
+ $adjustments[ID3_Frame_RVAD::peakRightBack] = 0xff;
+ $adjustments[ID3_Frame_RVAD::peakLeftBack] = 0xf;
+
+ if ($construct)
+ $frame->setAdjustments($adjustments);
+ else
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+
+ /**
+ * The third RVAD frame test.
+ *
+ * @param ID3_Frame_RVAD $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRVAD2
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $adjustments[ID3_Frame_RVAD::right] = -0xffff;
+ $adjustments[ID3_Frame_RVAD::left] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
+ $adjustments[ID3_Frame_RVAD::rightBack] = -0xff;
+ $adjustments[ID3_Frame_RVAD::leftBack] = 0xff;
+ $adjustments[ID3_Frame_RVAD::peakRightBack] = 0xff;
+ $adjustments[ID3_Frame_RVAD::peakLeftBack] = 0xf;
+ $adjustments[ID3_Frame_RVAD::center] = 0xf;
+ $adjustments[ID3_Frame_RVAD::peakCenter] = 0x7;
+
+ if ($construct)
+ $frame->setAdjustments($adjustments);
+ else
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+
+ /**
+ * The fourth RVAD frame test.
+ *
+ * @param ID3_Frame_RVAD $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRVAD3
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $adjustments[ID3_Frame_RVAD::right] = -0xffff;
+ $adjustments[ID3_Frame_RVAD::left] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
+ $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
+ $adjustments[ID3_Frame_RVAD::rightBack] = -0xff;
+ $adjustments[ID3_Frame_RVAD::leftBack] = 0xff;
+ $adjustments[ID3_Frame_RVAD::peakRightBack] = 0xff;
+ $adjustments[ID3_Frame_RVAD::peakLeftBack] = 0xf;
+ $adjustments[ID3_Frame_RVAD::center] = 0xf;
+ $adjustments[ID3_Frame_RVAD::peakCenter] = 0x7;
+ $adjustments[ID3_Frame_RVAD::bass] = 0x0;
+ $adjustments[ID3_Frame_RVAD::peakBass] = 0x0;
+
+ if ($construct)
+ $frame->setAdjustments($adjustments);
+ else
+ $this->assertEquals($adjustments, $frame->getAdjustments());
+ }
+
+ /**
+ * The first RVRB frame test.
+ *
+ * @param ID3_Frame_RVRB $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameRVRB0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $reverbLeft = $this->testUInt16;
+ $reverbRight = $this->testUInt16 - 1;
+ $reverbBouncesLeft = $this->testUInt8;
+ $reverbBouncesRight = $this->testUInt8 - 1;
+ $reverbFeedbackLtoL = $this->testUInt8 - 2;
+ $reverbFeedbackLtoR = $this->testUInt8 - 3;
+ $reverbFeedbackRtoR = $this->testUInt8 - 4;
+ $reverbFeedbackRtoL = $this->testUInt8 - 5;
+ $premixLtoR = $this->testUInt8 - 6;
+ $premixRtoL = $this->testUInt8 - 7;
+
+ if ($construct) {
+ $frame->setReverbLeft($reverbLeft);
+ $frame->setReverbRight($reverbRight);
+ $frame->setReverbBouncesLeft($reverbBouncesLeft);
+ $frame->setReverbBouncesRight($reverbBouncesRight);
+ $frame->setReverbFeedbackLtoL($reverbFeedbackLtoL);
+ $frame->setReverbFeedbackLtoR($reverbFeedbackLtoR);
+ $frame->setReverbFeedbackRtoR($reverbFeedbackRtoR);
+ $frame->setReverbFeedbackRtoL($reverbFeedbackRtoL);
+ $frame->setPremixLtoR($premixLtoR);
+ $frame->setPremixRtoL($premixRtoL);
+ } else {
+ $this->assertEquals($reverbLeft, $frame->getReverbLeft());
+ $this->assertEquals($reverbRight, $frame->getReverbRight());
+ $this->assertEquals($reverbBouncesLeft, $frame->getReverbBouncesLeft());
+ $this->assertEquals($reverbBouncesRight, $frame->getReverbBouncesRight());
+ $this->assertEquals($reverbFeedbackLtoL, $frame->getReverbFeedbackLtoL());
+ $this->assertEquals($reverbFeedbackLtoR, $frame->getReverbFeedbackLtoR());
+ $this->assertEquals($reverbFeedbackRtoR, $frame->getReverbFeedbackRtoR());
+ $this->assertEquals($reverbFeedbackRtoL, $frame->getReverbFeedbackRtoL());
+ $this->assertEquals($premixLtoR, $frame->getPremixLtoR());
+ $this->assertEquals($premixRtoL, $frame->getPremixRtoL());
+ }
+ }
+
+ /**
+ * The first SEEK frame test.
+ *
+ * @param ID3_Frame_SEEK $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameSEEK0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $minOffset = $this->testInt32;
+
+ if ($construct)
+ $frame->setMinimumOffset($minOffset);
+ else
+ $this->assertEquals($minOffset, $frame->getMinimumOffset());
+ }
+
+ /**
+ * The first SIGN frame test.
+ *
+ * @param ID3_Frame_SIGN $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameSIGN0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $group = $this->testUInt8;
+ $signature = $this->testText;
+
+ if ($construct) {
+ $frame->setGroup($group);
+ $frame->setSignature($signature);
+ } else {
+ $this->assertEquals($group, $frame->getGroup());
+ $this->assertEquals($signature, $frame->getSignature());
+ }
+ }
+
+ /**
+ * The first SYLT frame test.
+ *
+ * @param ID3_Frame_SYLT $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameSYLT0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $type = $this->testUInt8;
+ $description = $this->convert($this->testText, $encoding);
+ $events[0] = $description;
+ $events[0xFFFF] = $description;
+ $events[0xFFFFF] = $description;
+ $events[0xFFFFFF] = $description;
+ $events[0xFFFFFFFF] = $description;
+
+ if ($construct) {
+ $frame->setType($type);
+ $frame->setDescription($description);
+ $frame->setEvents($events);
+ } else {
+ $this->assertEquals($type, $frame->getType());
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($events, $frame->getEvents());
+ }
+ }
+
+ /**
+ * The first SYTC frame test.
+ *
+ * @param ID3_Frame_SYTC $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameSYTC0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $events[0] = ID3_Frame_SYTC::BEAT_FREE;
+ $events[0xFFFF] = ID3_Frame_SYTC::SINGLE_BEAT;
+ $events[0xFFFFF] = 0xFF;
+ $events[0xFFFFFF] = 0xFF + 1;
+ $events[0xFFFFFFFF] = 0xFF + 0xFF;
+
+ if ($construct)
+ $frame->setEvents($events);
+ else
+ $this->assertEquals($events, $frame->getEvents());
+ }
+
+ /**
+ * The first TXXX frame test.
+ *
+ * @param ID3_Frame_TXXX $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameTXXX0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $description = $this->convert($this->testText, $encoding);
+ $text = $this->convert($this->testText, $encoding);
+
+ if ($construct) {
+ $frame->setDescription($description);
+ $frame->setText($text);
+ } else {
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($text, $frame->getText());
+ }
+ }
+
+ /**
+ * The first USER frame test.
+ *
+ * @param ID3_Frame_USER $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameUSER0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $text = $this->convert($this->testText, $encoding);
+
+ if ($construct)
+ $frame->setText($text);
+ else
+ $this->assertEquals($text, $frame->getText());
+ }
+
+ /**
+ * The first USLT frame test.
+ *
+ * @param ID3_Frame_USLT $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameUSLT0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $description = $this->convert($this->testText, $encoding);
+ $text = $this->convert($this->testText, $encoding);
+
+ if ($construct) {
+ $frame->setDescription($description);
+ $frame->setText($text);
+ } else {
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($text, $frame->getText());
+ }
+ }
+
+ /**
+ * The first WXXX frame test.
+ *
+ * @param ID3_Frame_WXXX $frame The frame to test.
+ * @param boolean $construct Whether construction or testing should occur.
+ * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
+ * in this frame.
+ * @param string $language The language code.
+ * @param integer $timing The timing format.
+ */
+ private function frameWXXX0
+ (&$frame, $construct, $encoding, $language, $timing)
+ {
+ $description = $this->convert($this->testText, $encoding);
+ $link = $this->testLink;
+
+ if ($construct) {
+ $frame->setDescription($description);
+ $frame->setLink($link);
+ } else {
+ $this->assertEquals($description, $frame->getDescription());
+ $this->assertEquals($link, $frame->getLink());
+ }
+ }
+
+ /**
+ * Helper function to convert a string into a string of the given encoding.
+ *
+ * @param string $text The string to convert.
+ * @param integer $encoding The text encoding to convert to.
+ * @return string
+ */
+ private static function convert($text, $encoding)
+ {
+ switch ($encoding) {
+ case ID3_Encoding::ISO88591:
+ return iconv("ascii", "ISO-8859-1", $text);
+ case ID3_Encoding::UTF16:
+ return iconv("ascii", "UTF-16", $text);
+ case ID3_Encoding::UTF16LE:
+ return substr(iconv("ascii", "UTF-16LE", $text), 2);
+ case ID3_Encoding::UTF16BE:
+ return iconv("ascii", "UTF-16BE", $text);
+ default: // ID3_Encoding::UTF8
+ return iconv("ascii", "UTF-8", $text);
+ }
+ }
+} \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v1.php b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v1.php
new file mode 100644
index 0000000..2f416dc
--- /dev/null
+++ b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v1.php
@@ -0,0 +1,194 @@
+<?php
+/**
+ * PHP Reader Library
+ *
+ * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the project workgroup nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Id: TestID3v1.php 64 2008-04-01 10:38:12Z svollbehr $
+ */
+
+/**#@+ @ignore */
+require_once("PHPUnit/Framework.php");
+require_once("ID3v1.php");
+/**#@-*/
+
+/**
+ * Unit test case for ID3v1 class.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @author Sven Vollbehr <svollbehr@gmail.com>
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Rev: 64 $
+ */
+final class TestID3v1 extends PHPUnit_Framework_TestCase
+{
+ function testTagCreate()
+ {
+ $id3 = new ID3v1();
+
+ $id3->title = "Title 1";
+ $this->assertEquals("Title 1", $id3->title);
+
+ $id3->artist = "Artist 1";
+ $this->assertEquals("Artist 1", $id3->artist);
+
+ $id3->album = "Album 1";
+ $this->assertEquals("Album 1", $id3->album);
+
+ $id3->year = "2008";
+ $this->assertEquals("2008", $id3->year);
+
+ $id3->comment = "Comment 1";
+ $this->assertEquals("Comment 1", $id3->comment);
+
+ $id3->track = 30;
+ $this->assertEquals(30, $id3->track);
+
+ $id3->genre = array_search("Classical", ID3v1::$genres);
+ $this->assertEquals("Classical", $id3->genre);
+
+ $id3->write("id3v1.tag");
+ }
+
+ function testTagReadAfterCreate()
+ {
+ $id3 = new ID3v1("id3v1.tag");
+ $this->assertEquals("Title 1", $id3->title);
+ $this->assertEquals("Artist 1", $id3->artist);
+ $this->assertEquals("Album 1", $id3->album);
+ $this->assertEquals("2008", $id3->year);
+ $this->assertEquals("Comment 1", $id3->comment);
+ $this->assertEquals(30, $id3->track);
+ $this->assertEquals("Classical", $id3->genre);
+ }
+
+ function testTagChange()
+ {
+ $id3 = new ID3v1("id3v1.tag");
+
+ $id3->title = "Title 2";
+ $this->assertEquals("Title 2", $id3->title);
+
+ $id3->artist = "Artist 2";
+ $this->assertEquals("Artist 2", $id3->artist);
+
+ $id3->album = "Album 2";
+ $this->assertEquals("Album 2", $id3->album);
+
+ $id3->year = "2045";
+ $this->assertEquals("2045", $id3->year);
+
+ $id3->comment = "Comment 2";
+ $this->assertEquals("Comment 2", $id3->comment);
+
+ $id3->track = 10;
+ $this->assertEquals(10, $id3->track);
+
+ $id3->genre = array_search("Trance", ID3v1::$genres);
+ $this->assertEquals("Trance", $id3->genre);
+
+ $id3->write();
+ }
+
+ function testTagReadAfterChange()
+ {
+ $id3 = new ID3v1("id3v1.tag");
+ $this->assertEquals("Title 2", $id3->title);
+ $this->assertEquals("Artist 2", $id3->artist);
+ $this->assertEquals("Album 2", $id3->album);
+ $this->assertEquals("2045", $id3->year);
+ $this->assertEquals("Comment 2", $id3->comment);
+ $this->assertEquals(10, $id3->track);
+ $this->assertEquals("Trance", $id3->genre);
+ }
+
+ function testTagReplace()
+ {
+ $id3 = new ID3v1();
+
+ $id3->title = "Title 3";
+ $this->assertEquals("Title 3", $id3->title);
+ $this->assertEquals("Unknown", $id3->genre);
+
+ $id3->write("id3v1.tag");
+ }
+
+ function testTagReadAfterReplace()
+ {
+ $id3 = new ID3v1("id3v1.tag");
+ $this->assertEquals("Title 3", $id3->title);
+ $this->assertEquals("", $id3->artist);
+ $this->assertEquals("", $id3->album);
+ $this->assertEquals("", $id3->year);
+ $this->assertEquals("", $id3->comment);
+ $this->assertEquals("", $id3->track);
+ $this->assertEquals("Unknown", $id3->genre);
+ }
+
+ function testTagCreateVersion10()
+ {
+ $id3 = new ID3v1();
+
+ $id3->title = "Title 4";
+ $this->assertEquals("Title 4", $id3->title);
+
+ $id3->artist = "Artist 4";
+ $this->assertEquals("Artist 4", $id3->artist);
+
+ $id3->album = "Album 4";
+ $this->assertEquals("Album 4", $id3->album);
+
+ $id3->year = "2020";
+ $this->assertEquals("2020", $id3->year);
+
+ $id3->comment = "A comment field with 30 chars.";
+ $this->assertEquals("A comment field with 30 chars.", $id3->comment);
+
+ $id3->genre = array_search("Classical", ID3v1::$genres);
+ $this->assertEquals("Classical", $id3->genre);
+
+ $id3->write("id3v1.tag");
+ }
+
+ function testTagReadAfterCreateVersion10()
+ {
+ $id3 = new ID3v1("id3v1.tag");
+ $this->assertEquals("Title 4", $id3->title);
+ $this->assertEquals("Artist 4", $id3->artist);
+ $this->assertEquals("Album 4", $id3->album);
+ $this->assertEquals("2020", $id3->year);
+ $this->assertEquals("A comment field with 30 chars.", $id3->comment);
+ $this->assertEquals("", $id3->track);
+ $this->assertEquals("Classical", $id3->genre);
+ }
+}
diff --git a/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v2.php b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v2.php
new file mode 100644
index 0000000..facb87d
--- /dev/null
+++ b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3v2.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * PHP Reader Library
+ *
+ * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the project workgroup nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Id: TestID3v2.php 107 2008-08-03 19:09:16Z svollbehr $
+ */
+
+/**#@+ @ignore */
+require_once("PHPUnit/Framework.php");
+require_once("ID3v2.php");
+/**#@-*/
+
+/**
+ * Unit test case for ID3v2 class.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @author Sven Vollbehr <svollbehr@gmail.com>
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Rev: 107 $
+ */
+final class TestID3v2 extends PHPUnit_Framework_TestCase
+{
+ function testTagCreate()
+ {
+ $id3 = new ID3v2();
+
+ $id3->tit2->text = "Title 1";
+ $this->assertEquals("Title 1", $id3->tit2->text);
+ $id3->tope->text = "Artist 1";
+ $this->assertEquals("Artist 1", $id3->tope->text);
+ $id3->talb->text = "Album 1";
+ $this->assertEquals("Album 1", $id3->talb->text);
+ $id3->tdrc->text = "2008";
+ $this->assertEquals("2008", $id3->tdrc->text);
+ $id3->comm->text = "Comment 1";
+ $this->assertEquals("Comment 1", $id3->comm->text);
+ $id3->trck->text = "11/13";
+ $this->assertEquals("11/13", $id3->trck->text);
+ $id3->tcon->text = "Classical";
+ $this->assertEquals("Classical", $id3->tcon->text);
+
+ $id3->write("id3v2.tag");
+ }
+
+ function testTagReadAfterCreate()
+ {
+ $id3 = new ID3v2("id3v2.tag");
+
+ $this->assertEquals("Title 1", $id3->tit2->text);
+ $this->assertEquals("Artist 1", $id3->tope->text);
+ $this->assertEquals("Album 1", $id3->talb->text);
+ $this->assertEquals("2008", $id3->tdrc->text);
+ $this->assertEquals("Comment 1", $id3->comm->text);
+ $this->assertEquals("11/13", $id3->trck->text);
+ $this->assertEquals("Classical", $id3->tcon->text);
+ }
+
+ function testTagChange()
+ {
+ $id3 = new ID3v2("id3v2.tag");
+
+ $id3->tit2->text = "Title 2";
+ $this->assertEquals("Title 2", $id3->tit2->text);
+ $id3->tope->text = "Artist 2";
+ $this->assertEquals("Artist 2", $id3->tope->text);
+ $id3->talb->text = "Album 2";
+ $this->assertEquals("Album 2", $id3->talb->text);
+ $id3->tdrc->text = "2020";
+ $this->assertEquals("2020", $id3->tdrc->text);
+ $id3->comm->text = "Comment 2";
+ $this->assertEquals("Comment 2", $id3->comm->text);
+ $id3->trck->text = "13/13";
+ $this->assertEquals("13/13", $id3->trck->text);
+ $id3->tcon->text = "Trance";
+ $this->assertEquals("Trance", $id3->tcon->text);
+
+ $id3->write();
+ }
+
+ function testTagReadAfterChange()
+ {
+ $id3 = new ID3v2("id3v2.tag");
+
+ $this->assertEquals("Title 2", $id3->tit2->text);
+ $this->assertEquals("Artist 2", $id3->tope->text);
+ $this->assertEquals("Album 2", $id3->talb->text);
+ $this->assertEquals("2020", $id3->tdrc->text);
+ $this->assertEquals("Comment 2", $id3->comm->text);
+ $this->assertEquals("13/13", $id3->trck->text);
+ $this->assertEquals("Trance", $id3->tcon->text);
+ }
+
+ function testUnsynchronisation()
+ {
+ $id3 = new ID3v2("id3v2.tag");
+ $id3->tit2->text = "\xff\xf0";
+ $id3->tcon->text = "\xff\xe0\xf0";
+ $id3->write();
+
+ $this->assertEquals
+ ("TIT2\0\0\0\x08\0\x03\0\0\0\x03\x03\xff\x00\xf0", "" . $id3->tit2);
+
+ $id3 = new ID3v2("id3v2.tag");
+ $this->assertEquals("\xff\xf0", $id3->tit2->text);
+ $this->assertEquals("\xff\xe0\xf0", $id3->tcon->text);
+ }
+}
diff --git a/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestTransform.php b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestTransform.php
new file mode 100644
index 0000000..8fd955c
--- /dev/null
+++ b/libraries/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestTransform.php
@@ -0,0 +1,221 @@
+<?php
+/**
+ * PHP Reader Library
+ *
+ * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the project workgroup nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Id: TestTransform.php 107 2008-08-03 19:09:16Z svollbehr $
+ */
+
+/**#@+ @ignore */
+require_once("PHPUnit/Framework.php");
+require_once("Transform.php");
+/**#@-*/
+
+/**
+ * Unit test case for Transform class.
+ *
+ * @package php-reader
+ * @subpackage Tests
+ * @author Sven Vollbehr <svollbehr@gmail.com>
+ * @author Ryan Butterfield <buttza@gmail.com>
+ * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
+ * @license http://code.google.com/p/php-reader/wiki/License New BSD License
+ * @version $Rev: 107 $
+ */
+final class TestTransform extends PHPUnit_Framework_TestCase
+{
+ function testInt64LE()
+ {
+ $this->assertEquals
+ (0x7fffffffffffffff, Transform::fromInt64BE
+ (Transform::toInt64BE(0x7fffffffffffffff)));
+ }
+
+ function testInt64BE()
+ {
+ $this->assertEquals
+ (0x7fffffffffffffff, Transform::fromInt64BE
+ (Transform::toInt64BE(0x7fffffffffffffff)));
+ }
+
+ function testInt32()
+ {
+ $this->assertEquals
+ (0x7fffffff, Transform::fromInt32(Transform::toInt32(0x7fffffff)));
+ $this->assertEquals
+ (-0x7fffffff, Transform::fromInt32(Transform::toInt32(-0x7fffffff)));
+ $this->assertEquals(-1, Transform::fromInt32(Transform::toInt32(-1)));
+ }
+
+ function testInt32LE()
+ {
+ $this->assertEquals(1, Transform::fromInt32LE("\x01\x00\x00\x00"));
+ $this->assertEquals
+ (0x7fffffff, Transform::fromInt32LE(Transform::toInt32LE(0x7fffffff)));
+ $this->assertEquals
+ (-0x7fffffff, Transform::fromInt32LE(Transform::toInt32LE(-0x7fffffff)));
+ $this->assertEquals(-1, Transform::fromInt32LE(Transform::toInt32LE(-1)));
+ }
+
+ function testInt32BE()
+ {
+ $this->assertEquals(1, Transform::fromInt32BE("\x00\x00\x00\x01"));
+ $this->assertEquals
+ (0x7fffffff, Transform::fromInt32BE(Transform::toInt32BE(0x7fffffff)));
+ $this->assertEquals
+ (-0x7fffffff, Transform::fromInt32BE(Transform::toInt32BE(-0x7fffffff)));
+ }
+
+ function testUInt32LE()
+ {
+ $this->assertEquals
+ ("78563412", Transform::fromHHex(Transform::toUInt32LE(0x12345678)));
+ $this->assertEquals
+ (0xffffffff, Transform::fromUInt32LE(Transform::toUInt32LE(0xffffffff)));
+ }
+
+ function testUInt32BE()
+ {
+ $this->assertEquals
+ ("12345678", Transform::fromHHex(Transform::toUInt32BE(0x12345678)));
+ $this->assertEquals
+ (0xffffffff, Transform::fromUInt32BE(Transform::toUInt32BE(0xffffffff)));
+ }
+
+ function testInt16()
+ {
+ $this->assertEquals
+ (0x7fff, Transform::fromInt16(Transform::toInt16(0x7fff)));
+ $this->assertEquals(-1, Transform::fromInt16(Transform::toInt16(-1)));
+ }
+
+ function testInt16LE()
+ {
+ $this->assertEquals(1, Transform::fromInt16LE("\x01\x00"));
+ $this->assertEquals
+ (0x7fff, Transform::fromInt16LE(Transform::toInt16LE(0x7fff)));
+ $this->assertEquals(-1, Transform::fromInt16LE(Transform::toInt16LE(-1)));
+ }
+
+ function testInt16BE()
+ {
+ $this->assertEquals(1, Transform::fromInt16BE("\x00\x01"));
+ $this->assertEquals
+ (0x7fff, Transform::fromInt16BE(Transform::toInt16BE(0x7fff)));
+ $this->assertEquals(-1, Transform::fromInt16BE(Transform::toInt16BE(-1)));
+ }
+
+ function testUInt16LE()
+ {
+ $this->assertEquals
+ ("fffe", Transform::fromHHex(Transform::toUInt16LE(0xfeff)));
+ $this->assertEquals
+ (0xffff, Transform::fromUInt16LE(Transform::toUInt16LE(0xffff)));
+ }
+
+ function testUInt16BE()
+ {
+ $this->assertEquals
+ ("feff", Transform::fromHHex(Transform::toUInt16BE(0xfeff)));
+ $this->assertEquals
+ (0xffff, Transform::fromUInt16BE(Transform::toUInt16BE(0xffff)));
+ }
+
+ function testInt8()
+ {
+ $this->assertEquals(0x7f, Transform::fromInt8(Transform::toInt8(0x7f)));
+ }
+
+ function testString16()
+ {
+ $this->assertEquals("00e4", Transform::fromHHex
+ (Transform::fromString16(Transform::toString16("\x00\xe4"))));
+ $this->assertEquals
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::fromString16(Transform::toString16LE
+ ("\xff\xfe\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.")));
+ $this->assertEquals
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::fromString16(Transform::toString16BE
+ ("\xff\xfe\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.")));
+ $this->assertEquals
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::fromString16(Transform::toString16
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::LITTLE_ENDIAN_ORDER)));
+ $this->assertEquals
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::fromString16(Transform::toString16
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::BIG_ENDIAN_ORDER)));
+ }
+
+ function testString16LE()
+ {
+ $this->assertEquals
+ ("fffe", Transform::fromHHex(Transform::toString16LE("\xff\xfe")));
+ $this->assertEquals
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::fromString16LE(Transform::toString16LE
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.")));
+ }
+
+ function testString16BE()
+ {
+ $this->assertEquals
+ ("feff", Transform::fromHHex(Transform::toString16BE("\xff\xfe")));
+ $this->assertEquals
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.",
+ Transform::fromString16BE(Transform::toString16BE
+ ("\0T\0h\0i\0s\0 \0i\0s\0 \0a\0 \0t\0e\0s\0t\0.")));
+ }
+
+ function testHHex()
+ {
+ $this->assertEquals("6c34", bin2hex(Transform::toHHex("6c34")));
+ $this->assertEquals("6c34", Transform::fromHHex(Transform::toHHex("6c34")));
+ }
+
+ function testLHex()
+ {
+ $this->assertEquals("c643", bin2hex(Transform::toLHex("6c34")));
+ $this->assertEquals("6c34", Transform::fromLHex(Transform::toLHex("6c34")));
+ }
+
+ function testGUID()
+ {
+ $this->assertEquals
+ ("75b22630-668e-11cf-a6d9-00aa0062ce6c",
+ Transform::fromGUID(Transform::toGUID
+ ("75b22630-668e-11cf-a6d9-00aa0062ce6c")));
+ }
+}