4 * PEL: PHP Exif Library.
5 * A library with support for reading and
6 * writing all Exif headers in JPEG and TIFF images using PHP.
8 * Copyright (C) 2004, 2006 Martin Geisler.
9 * Copyright (C) 2017 Johannes Weberhofer
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program in the file COPYING; if not, write to the
23 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24 * Boston, MA 02110-1301 USA
26 use lsolesen\pel\PelEntryUndefined;
27 use lsolesen\pel\PelEntryUserComment;
28 use lsolesen\pel\PelEntryVersion;
29 use lsolesen\pel\PelConvert;
30 use PHPUnit\Framework\TestCase;
32 class PelEntryUndefinedTest extends TestCase
35 function testReturnValues()
37 new PelEntryUndefined(42);
39 $entry = new PelEntryUndefined(42, 'foo bar baz');
40 $this->assertEquals($entry->getComponents(), 11);
41 $this->assertEquals($entry->getValue(), 'foo bar baz');
44 function testUsercomment()
46 $entry = new PelEntryUserComment();
47 $this->assertEquals($entry->getComponents(), 8);
48 $this->assertEquals($entry->getValue(), '');
49 $this->assertEquals($entry->getEncoding(), 'ASCII');
51 $entry->setValue('Hello!');
52 $this->assertEquals($entry->getComponents(), 14);
53 $this->assertEquals($entry->getValue(), 'Hello!');
54 $this->assertEquals($entry->getEncoding(), 'ASCII');
57 function testVersion()
59 $entry = new PelEntryVersion(42);
61 $this->assertEquals($entry->getValue(), 0.0);
63 $entry->setValue(2.0);
64 $this->assertEquals($entry->getValue(), 2.0);
65 $this->assertEquals($entry->getText(false), 'Version 2.0');
66 $this->assertEquals($entry->getText(true), '2.0');
67 $this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0200');
69 $entry->setValue(2.1);
70 $this->assertEquals($entry->getValue(), 2.1);
71 $this->assertEquals($entry->getText(false), 'Version 2.1');
72 $this->assertEquals($entry->getText(true), '2.1');
73 $this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0210');
75 $entry->setValue(2.01);
76 $this->assertEquals($entry->getValue(), 2.01);
77 $this->assertEquals($entry->getText(false), 'Version 2.01');
78 $this->assertEquals($entry->getText(true), '2.01');
79 $this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0201');