Skip to content

Commit 8e306e5

Browse files
author
Tom Van Herreweghe
committed
Fixed test for Native adapter
1 parent 59b413a commit 8e306e5

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

lib/PHPExif/Reader/Adapter/Native.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function getExifFromFile($file)
168168
$data = @exif_read_data(
169169
$file,
170170
$sections,
171-
$this->getSectionsAsArrays(),
171+
$this->getSectionsAsArray(),
172172
$this->getIncludeThumbnail()
173173
);
174174

tests/PHPExif/ExifTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class ExifTest extends \PHPUnit_Framework_TestCase
88

99
public function setUp()
1010
{
11-
$this->reader = new \PHPExif\Reader();
12-
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool.jpg';
11+
$this->reader = \PHPExif\Reader::factory(\PHPExif\Reader::TYPE_NATIVE);
12+
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool_500.jpg';
1313
$this->exif = $this->reader->getExifFromFile($file);
1414
}
1515

@@ -65,13 +65,13 @@ public function testGetFocusDistance()
6565

6666
public function testGetWidth()
6767
{
68-
$expected = 4288;
68+
$expected = 500;
6969
$this->assertEquals($expected, $this->exif->getWidth());
7070
}
7171

7272
public function testGetHeight()
7373
{
74-
$expected = 2848;
74+
$expected = 332;
7575
$this->assertEquals($expected, $this->exif->getHeight());
7676
}
7777

tests/PHPExif/ReaderTest.php renamed to tests/PHPExif/Reader/Adapter/NativeTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
11
<?php
2-
class ReaderTest extends \PHPUnit_Framework_TestCase
2+
class NativeTest extends \PHPUnit_Framework_TestCase
33
{
44
/**
5-
* @var \PHPExif\Reader
5+
* @var \PHPExif\Reader\Adapter\Native
66
*/
7-
protected $reader;
7+
protected $adapter;
88

99
public function setUp()
1010
{
11-
$this->reader = new \PHPExif\Reader();
11+
$this->adapter = new \PHPExif\Reader\Adapter\Native();
1212
}
1313

1414
public function testSetIncludeThumbnail()
1515
{
16-
$reflProperty = new \ReflectionProperty('\PHPExif\Reader', 'includeThumbnail');
16+
$reflProperty = new \ReflectionProperty('\PHPExif\Reader\Adapter\Native', 'includeThumbnail');
1717
$reflProperty->setAccessible(true);
1818

19-
$this->assertEquals(\PHPExif\Reader::NO_THUMBNAIL, $reflProperty->getValue($this->reader));
19+
$this->assertEquals(\PHPExif\Reader\Adapter\Native::NO_THUMBNAIL, $reflProperty->getValue($this->adapter));
2020

21-
$this->reader->setIncludeThumbnail(\PHPExif\Reader::INCLUDE_THUMBNAIL);
21+
$this->adapter->setIncludeThumbnail(\PHPExif\Reader\Adapter\Native::INCLUDE_THUMBNAIL);
2222

23-
$this->assertEquals(\PHPExif\Reader::INCLUDE_THUMBNAIL, $reflProperty->getValue($this->reader));
23+
$this->assertEquals(\PHPExif\Reader\Adapter\Native::INCLUDE_THUMBNAIL, $reflProperty->getValue($this->adapter));
2424
}
2525

2626
public function testGetRequiredSections()
2727
{
28-
$reflProperty = new \ReflectionProperty('\PHPExif\Reader', 'sections');
28+
$reflProperty = new \ReflectionProperty('\PHPExif\Reader\Adapter\Native', 'sections');
2929
$reflProperty->setAccessible(true);
3030

31-
$this->assertEquals($reflProperty->getValue($this->reader), $this->reader->getRequiredSections());
31+
$this->assertEquals($reflProperty->getValue($this->adapter), $this->adapter->getRequiredSections());
3232
}
3333

3434
public function testSetRequiredSections()
3535
{
36-
$reflProperty = new \ReflectionProperty('\PHPExif\Reader', 'sections');
36+
$reflProperty = new \ReflectionProperty('\PHPExif\Reader\Adapter\Native', 'sections');
3737
$reflProperty->setAccessible(true);
3838

3939
$testData = array('foo', 'bar', 'baz');
4040

41-
$returnValue = $this->reader->setRequiredSections($testData);
41+
$returnValue = $this->adapter->setRequiredSections($testData);
4242

43-
$this->assertEquals($testData, $reflProperty->getValue($this->reader));
44-
$this->assertEquals($this->reader, $returnValue);
43+
$this->assertEquals($testData, $reflProperty->getValue($this->adapter));
44+
$this->assertEquals($this->adapter, $returnValue);
4545
}
4646

4747
public function testAddRequiredSection()
4848
{
49-
$reflProperty = new \ReflectionProperty('\PHPExif\Reader', 'sections');
49+
$reflProperty = new \ReflectionProperty('\PHPExif\Reader\Adapter\Native', 'sections');
5050
$reflProperty->setAccessible(true);
5151

5252
$testData = array('foo', 'bar', 'baz');
53-
$this->reader->setRequiredSections($testData);
53+
$this->adapter->setRequiredSections($testData);
5454

55-
$returnValue = $this->reader->addRequiredSection('test');
55+
$returnValue = $this->adapter->addRequiredSection('test');
5656
array_push($testData, 'test');
5757

58-
$this->assertEquals($testData, $reflProperty->getValue($this->reader));
59-
$this->assertEquals($this->reader, $returnValue);
58+
$this->assertEquals($testData, $reflProperty->getValue($this->adapter));
59+
$this->assertEquals($this->adapter, $returnValue);
6060
}
6161

6262
public function testGetExifFromFileNoData()
6363
{
6464
$file = PHPEXIF_TEST_ROOT . '/files/empty.jpg';
6565
$this->setExpectedException('RuntimeException');
66-
$result = $this->reader->getExifFromFile($file);
66+
$result = $this->adapter->getExifFromFile($file);
6767
}
6868

6969
public function testGetExifFromFileHasData()
7070
{
71-
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool.jpg';
72-
$result = $this->reader->getExifFromFile($file);
71+
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool_500.jpg';
72+
$result = $this->adapter->getExifFromFile($file);
7373
$this->assertInstanceOf('\PHPExif\Exif', $result);
7474
}
7575

7676
public function testGetIptcData()
7777
{
78-
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool_smaller.jpg';
79-
$result = $this->reader->getIptcData($file);
78+
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool_500.jpg';
79+
$result = $this->adapter->getIptcData($file);
8080
$expected = array(
8181
'title' => 'Morning Glory Pool',
8282
'keywords' => array(

tests/bootstrap.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
2-
32
error_reporting(-1);
43
ini_set('display_errors', 1);
54
ini_set('display_startup_errors', 1);
65

76
date_default_timezone_set('Europe/Brussels');
87

9-
if (!is_file($autoloadFile = __DIR__ . '/../vendor/autoload.php')) {
8+
if (!is_file($autoloadFile = __DIR__ . '/../../../autoload.php')) {
109
echo 'Could not find "vendor/autoload.php". Did you forget to run "composer install --dev"?' . PHP_EOL;
1110
exit(1);
1211
}
-181 KB
Binary file not shown.

0 commit comments

Comments
 (0)