InfoTest.php
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
namespace tests;
use think\Image;
class InfoTest extends TestCase
{
public function testOpen()
{
$this->setExpectedException("\\think\\image\\Exception");
Image::open('');
}
public function testIllegal()
{
$this->setExpectedException("\\think\\image\\Exception", 'Illegal image file');
Image::open(TEST_PATH . 'images/test.bmp');
}
public function testJpeg()
{
$image = Image::open($this->getJpeg());
$this->assertEquals(800, $image->width());
$this->assertEquals(600, $image->height());
$this->assertEquals('jpeg', $image->type());
$this->assertEquals('image/jpeg', $image->mime());
$this->assertEquals([800, 600], $image->size());
}
public function testPng()
{
$image = Image::open($this->getPng());
$this->assertEquals(800, $image->width());
$this->assertEquals(600, $image->height());
$this->assertEquals('png', $image->type());
$this->assertEquals('image/png', $image->mime());
$this->assertEquals([800, 600], $image->size());
}
public function testGif()
{
$image = Image::open($this->getGif());
$this->assertEquals(380, $image->width());
$this->assertEquals(216, $image->height());
$this->assertEquals('gif', $image->type());
$this->assertEquals('image/gif', $image->mime());
$this->assertEquals([380, 216], $image->size());
}
}