4b0157095502ceb4ea4db3283f8ad0f6e8644cac
[yaffs-website] / test / PelJpegMarkerTest.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) 2004, 2006 Martin Geisler.
9  * Copyright (C) 2017 Johannes Weberhofer
10  *
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.
15  *
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.
20  *
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
25  */
26 use PHPUnit\Framework\TestCase;
27 use lsolesen\pel\PelJpegMarker;
28 use lsolesen\pel\Pel;
29 use lsolesen\pel\PelJpegInvalidMarkerException;
30
31 class PelJpegMarkerTest extends TestCase
32 {
33
34     function testNames()
35     {
36         $jpegMarker = new PelJpegMarker();
37         $this->assertEquals($jpegMarker::getName(PelJpegMarker::SOF0), 'SOF0');
38         $this->assertEquals($jpegMarker::getName(PelJpegMarker::RST3), 'RST3');
39         $this->assertEquals($jpegMarker::getName(PelJpegMarker::APP3), 'APP3');
40         $this->assertEquals($jpegMarker::getName(PelJpegMarker::JPG11), 'JPG11');
41         $this->assertEquals($jpegMarker::getName(100), Pel::fmt('Unknown marker: 0x%02X', 100));
42     }
43
44     function testDescriptions()
45     {
46         $jpegMarker = new PelJpegMarker();
47         $this->assertEquals($jpegMarker::getDescription(PelJpegMarker::SOF0), 'Encoding (baseline)');
48         $this->assertEquals($jpegMarker::getDescription(PelJpegMarker::RST3), Pel::fmt('Restart %d', 3));
49         $this->assertEquals($jpegMarker::getDescription(PelJpegMarker::APP3), Pel::fmt('Application segment %d', 3));
50         $this->assertEquals($jpegMarker::getDescription(PelJpegMarker::JPG11), Pel::fmt('Extension %d', 11));
51         $this->assertEquals($jpegMarker::getDescription(100), Pel::fmt('Unknown marker: 0x%02X', 100));
52     }
53
54     /**
55      * @expectedException lsolesen\pel\PelJpegInvalidMarkerException
56      * @throws PelJpegInvalidMarkerException
57      */
58     function testInvalidMarkerException()
59     {
60         throw new PelJpegInvalidMarkerException(1, 2);
61     }
62 }