Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / lsolesen / pel / test / IfdTest.php
1 <?php
2
3 /**
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.
7  *
8  * Copyright (C) 2006 Martin Geisler.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program in the file COPYING; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301 USA
24  */
25
26 use lsolesen\pel\PelIfd;
27 use lsolesen\pel\PelEntryAscii;
28 use lsolesen\pel\PelTag;
29 use lsolesen\pel\PelEntryTime;
30
31 class IfdTest extends \PHPUnit_Framework_TestCase
32 {
33     function testIteratorAggretate()
34     {
35         $ifd = new PelIfd(PelIfd::IFD0);
36
37         $this->assertEquals(sizeof($ifd->getIterator()), 0);
38
39         $desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, 'Hello?');
40         $date = new PelEntryTime(PelTag::DATE_TIME, 12345678);
41
42         $ifd->addEntry($desc);
43         $ifd->addEntry($date);
44
45         $this->assertEquals(sizeof($ifd->getIterator()), 2);
46
47         $entries = array();
48         foreach ($ifd as $tag => $entry) {
49             $entries[$tag] = $entry;
50         }
51
52         $this->assertSame($entries[PelTag::IMAGE_DESCRIPTION], $desc);
53         $this->assertSame($entries[PelTag::DATE_TIME], $date);
54     }
55
56     function testArrayAccess()
57     {
58         $ifd = new PelIfd(PelIfd::IFD0);
59
60         $this->assertEquals(sizeof($ifd->getIterator()), 0);
61
62         $desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, 'Hello?');
63         $date = new PelEntryTime(PelTag::DATE_TIME, 12345678);
64
65         $ifd[] = $desc;
66         $ifd[] = $date;
67
68         $this->assertSame($ifd[PelTag::IMAGE_DESCRIPTION], $desc);
69         $this->assertSame($ifd[PelTag::DATE_TIME], $date);
70
71         unset($ifd[PelTag::DATE_TIME]);
72
73         $this->assertFalse(isset($ifd[PelTag::DATE_TIME]));
74     }
75 }