Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Switch to PHPUnit #48

Merged
merged 1 commit into from
Apr 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build:
environment:
php:
version: 5.6.9 # Common versions: 5.4, 5.5, 5.6, 7.0 or hhvm
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@ language: php
sudo: false

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- nightly

matrix:
fast_finish: true
allow_failures:
- php: hhvm
- php: nightly

install:
- composer install
- travis_retry composer self-update
- travis_retry composer install --no-interaction

before_script:
- mkdir -p build/logs

script:
- ./vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=psr2 src
- php test/run-tests.php
- phpunit --coverage-clover build/logs/clover.xml ./test

after_script:
- travis_retry php vendor/bin/coveralls -v
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Credits
*******

PEL is written by Martin Geisler <mgeisler@users.sourceforge.net> and
is now maintained by Lars Olesen <lars@legestue.net>
is now maintained by Lars Olesen <lars@intraface.dk>
and <jweberhofer@weberhofer.at>

The source started out as a port of the nice, clean C code found in
Expand Down
105 changes: 0 additions & 105 deletions README

This file was deleted.

18 changes: 9 additions & 9 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Licensed under the GNU GPL, see COPYING for details.


Description
***********
--

The PHP Exif Library (PEL) makes it easy to develop programs that will
read and write the Exif metadata headers found in JPEG and TIFF
Expand All @@ -31,7 +31,7 @@ share your ideas about how the API should look like.


Documentation Overview
**********************
--

* README: gives you a short introduction to PEL (this file).
* INSTALL: explain how to install and get going with PEL.
Expand All @@ -41,7 +41,7 @@ Documentation Overview
* run run-phpdoc.sh to generate API-documention or see it online at http://lsolesen.github.com/pel

Features of PEL
***************
--

* Reads and writes Exif metadata from both JPEG and TIFF images.
* Supports reading and writing all Exif tags.
Expand All @@ -52,21 +52,21 @@ Features of PEL


Helping out
***********
--

Help will be very much appreciated. You can report issues, run the test
suite, add patches. The best way to help out is applying patches and
helping out with the tests. See instructions in the test/ directory.


Languages
*********
--

To work with the translations, you need the gettext package installed.


Getting Support
***************
--

The first place you should consult for support is the documentation
supplied with PEL, found in the doc/ directory. There you will find a
Expand All @@ -93,7 +93,7 @@ generally very stable.


Contributing Test Images
************************
--

To make PEL as stable as possible, it is tested with images from a
number of different camera models.
Expand All @@ -104,7 +104,7 @@ instructions.


Credits
*******
--

Please see the AUTHORS file for a list of people who have contributed
to PEL.
to PEL. See the full list of [code contributors](https://github.com/lsolesen/pel/graphs/contributors).
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"php": ">=5.0.0"
},
"require-dev" : {
"lastcraft/simpletest": ">=1.1",
"squizlabs/php_codesniffer": "2.*"
"php": ">=5.5.0",
"phpunit/phpunit": "4.4.*",
"squizlabs/php_codesniffer": "2.*",
"satooshi/php-coveralls": "dev-master"
},
"autoload": {
"psr-4": {"lsolesen\\pel\\": "src/"}
Expand Down
21 changes: 21 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Pel Testing Suite">
<directory suffix=".php">./test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ function quote($str)

function entryToTest($name, PelEntry $entry)
{
println('$this->assertIsA(%s, \'%s\');', $name, get_class($entry));
println('$this->assertInstanceOf(\'%s\', %s);', $name, get_class($entry));

println('$this->assertEqual(%s->getValue(), %s);', $name, var_export($entry->getValue(), true));
println('$this->assertEquals(%s->getValue(), %s);', $name, var_export($entry->getValue(), true));

println('$this->assertEqual(%s->getText(), \'%s\');', $name, quote($entry->getText()));
println('$this->assertEquals(%s->getText(), \'%s\');', $name, quote($entry->getText()));
}

function ifdToTest($name, $number, PelIfd $ifd)
Expand All @@ -76,7 +76,7 @@ function ifdToTest($name, $number, PelIfd $ifd)
println('/* Start of IDF %s%d. */', $name, $number);

$entries = $ifd->getEntries();
println('$this->assertEqual(count(%s%d->getEntries()), %d);', $name, $number, count($entries));
println('$this->assertEquals(count(%s%d->getEntries()), %d);', $name, $number, count($entries));

foreach ($entries as $tag => $entry) {
println();
Expand All @@ -88,13 +88,13 @@ function ifdToTest($name, $number, PelIfd $ifd)
println('/* Sub IFDs of %s%d. */', $name, $number);

$sub_ifds = $ifd->getSubIfds();
println('$this->assertEqual(count(%s%d->getSubIfds()), %d);', $name, $number, count($sub_ifds));
println('$this->assertEquals(count(%s%d->getSubIfds()), %d);', $name, $number, count($sub_ifds));

$n = 0;
$sub_name = $name . $number . '_';
foreach ($sub_ifds as $type => $sub_ifd) {
println('%s%d = %s%d->getSubIfd(%d); // IFD %s', $sub_name, $n, $name, $number, $type, $sub_ifd->getName());
println('$this->assertIsA(%s%d, \'PelIfd\');', $sub_name, $n);
println('$this->assertInstanceOf(\'PelIfd\', %s%d);', $sub_name, $n);
ifdToTest($sub_name, $n, $sub_ifd);
$n ++;
}
Expand All @@ -104,9 +104,9 @@ function ifdToTest($name, $number, PelIfd $ifd)
if (strlen($ifd->getThumbnailData()) > 0) {
println('$thumb_data = file_get_contents(dirname(__FILE__) .');
println(' \'/%s\');', $GLOBALS['thumb_filename']);
println('$this->assertEqual(%s%d->getThumbnailData(), $thumb_data);', $name, $number);
println('$this->assertEquals(%s%d->getThumbnailData(), $thumb_data);', $name, $number);
} else {
println('$this->assertEqual(%s%d->getThumbnailData(), \'\');', $name, $number);
println('$this->assertEquals(%s%d->getThumbnailData(), \'\');', $name, $number);
}

println();
Expand All @@ -116,7 +116,7 @@ function ifdToTest($name, $number, PelIfd $ifd)
println('%s%d = %s%d->getNextIfd();', $name, $number + 1, $name, $number);

if ($next instanceof PelIfd) {
println('$this->assertIsA(%s%d, \'PelIfd\');', $name, $number + 1);
println('$this->assertInstanceOf(\'PelIfd\', %s%d);', $name, $number + 1);
println('/* End of IFD %s%d. */', $name, $number);

ifdToTest($name, $number + 1, $next);
Expand All @@ -133,7 +133,7 @@ function tiffToTest($name, PelTiff $tiff)
println('$ifd0 = %s->getIfd();', $name);
$ifd = $tiff->getIfd();
if ($ifd instanceof PelIfd) {
println('$this->assertIsA($ifd0, \'PelIfd\');');
println('$this->assertInstanceOf(\'PelIfd\', $ifd0);');
ifdToTest('$ifd', 0, $ifd);
} else {
println('$this->assertNull($ifd0);');
Expand All @@ -143,12 +143,12 @@ function tiffToTest($name, PelTiff $tiff)
function jpegContentToTest($name, PelJpegContent $content)
{
if ($content instanceof PelExif) {
println('$this->assertIsA(%s, \'PelExif\');', $name);
println('$this->assertInstanceOf(\'PelExif\', %s);', $name);
$tiff = $content->getTiff();
println();
println('$tiff = %s->getTiff();', $name);
if ($tiff instanceof PelTiff) {
println('$this->assertIsA($tiff, \'PelTiff\');');
println('$this->assertInstanceOf(\'PelTiff\', $tiff);');
tiffToTest('$tiff', $tiff);
}
}
Expand Down Expand Up @@ -207,25 +207,19 @@ function binstrencode($field)

/* Autogenerated by the make-image-test.php script */

if (realpath($_SERVER[\'PHP_SELF\']) == __FILE__) {
require_once \'../autoload.php\';
require_once \'../vendor/lastcraft/simpletest/autorun.php\';
}
use lsolesen\pel\PelJpeg;

class %s extends UnitTestCase {

function __construct() {
parent::__construct(\'PEL %s Tests\');
}
class %s extends \PHPUnit_Framework_TestCase
{

function testRead() {
function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . \'/%s\');
', $test_name, $image_filename, $image_filename);

require_once (dirname(__FILE__) . '/../../src/PelJpeg.php');
require_once(dirname(__FILE__) . '/../../src/PelJpeg.php');
$jpeg = new PelJpeg($image_filename);

$indent = 2;
Expand All @@ -240,9 +234,9 @@ function testRead() {
} else {
println('$exceptions = Pel::getExceptions();');
for ($i = 0; $i < count($exceptions); $i ++) {
println('$this->assertIsA($exceptions[%d], \'%s\');', $i, get_class($exceptions[$i]));
println('$this->assertInstanceOf(\'%s\', $exceptions[%d]);', $i, get_class($exceptions[$i]));

println('$this->assertEqual($exceptions[%d]->getMessage(),', $i);
println('$this->assertEquals($exceptions[%d]->getMessage(),', $i);
println(' \'%s\');', quote($exceptions[$i]->getMessage()));
}
}
Expand Down
1 change: 0 additions & 1 deletion src/PelIfd.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ public function newEntryFromData($tag, $format, $components, PelDataWindow $data
* class.
*/
switch ($this->type) {

case self::IFD0:
case self::IFD1:
case self::EXIF:
Expand Down
Loading