No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InfoTest.php 2.0KB

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