WaterTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 WaterTest extends TestCase
  14. {
  15. public function testJpeg()
  16. {
  17. $pathname = TEST_PATH . 'tmp/water.jpg';
  18. $image = Image::open($this->getJpeg());
  19. $image->water(TEST_PATH . 'images/test.gif')->save($pathname);
  20. $file = new \SplFileInfo($pathname);
  21. $this->assertTrue($file->isFile());
  22. @unlink($pathname);
  23. }
  24. public function testPng()
  25. {
  26. $pathname = TEST_PATH . 'tmp/water.png';
  27. $image = Image::open($this->getPng());
  28. $image->water(TEST_PATH . 'images/test.gif')->save($pathname);
  29. $file = new \SplFileInfo($pathname);
  30. $this->assertTrue($file->isFile());
  31. @unlink($pathname);
  32. }
  33. public function testGif()
  34. {
  35. $pathname = TEST_PATH . 'tmp/water.gif';
  36. $image = Image::open($this->getGif());
  37. $image->water(TEST_PATH . 'images/test.jpg')->save($pathname);
  38. $file = new \SplFileInfo($pathname);
  39. $this->assertTrue($file->isFile());
  40. @unlink($pathname);
  41. }
  42. }