FileTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * This file is part of PHPPresentation - A pure PHP library for reading and writing
  4. * presentations documents.
  5. *
  6. * PHPPresentation is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
  12. *
  13. * @copyright 2009-2015 PHPPresentation contributors
  14. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  15. * @link https://github.com/PHPOffice/PHPPresentation
  16. */
  17. namespace PhpOffice\PhpPresentation\Tests\Shape\Drawing;
  18. use PhpOffice\PhpPresentation\Shape\Drawing\File;
  19. /**
  20. * Test class for Drawing element
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\Drawing
  23. */
  24. class FileTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testConstruct()
  27. {
  28. $object = new File();
  29. $this->assertEmpty($object->getPath());
  30. }
  31. /**
  32. * @expectedException \Exception
  33. * @expectedExceptionMessage File not found!
  34. */
  35. public function testPathBasic()
  36. {
  37. $object = new File();
  38. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object->setPath());
  39. }
  40. public function testPathWithoutVerifyFile()
  41. {
  42. $object = new File();
  43. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object->setPath('', false));
  44. $this->assertEmpty($object->getPath());
  45. }
  46. public function testPathWithRealFile()
  47. {
  48. $object = new File();
  49. $imagePath = PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png';
  50. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object->setPath($imagePath, false));
  51. $this->assertEquals($imagePath, $object->getPath());
  52. $this->assertEquals(0, $object->getWidth());
  53. $this->assertEquals(0, $object->getHeight());
  54. }
  55. }