2014-02-24 19:17:06 +01:00
|
|
|
<?php
|
2014-03-20 16:54:12 +04:00
|
|
|
namespace PhpWord\Tests;
|
2014-02-24 19:17:06 +01:00
|
|
|
|
2014-03-18 17:26:03 +04:00
|
|
|
use PhpOffice\PhpWord\Media;
|
|
|
|
|
use PhpOffice\PhpWord\Section;
|
2014-02-24 19:17:06 +01:00
|
|
|
|
2014-03-09 14:18:49 -04:00
|
|
|
class MediaTest extends \PHPUnit_Framework_TestCase
|
2014-03-02 14:40:58 -05:00
|
|
|
{
|
|
|
|
|
public function testGetSectionMediaElementsWithNull()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertEquals(Media::getSectionMediaElements(), array());
|
2014-03-02 14:40:58 -05:00
|
|
|
}
|
2014-02-24 19:17:06 +01:00
|
|
|
|
2014-03-02 14:40:58 -05:00
|
|
|
public function testCountSectionMediaElementsWithNull()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertEquals(Media::countSectionMediaElements(), 0);
|
2014-03-02 14:40:58 -05:00
|
|
|
}
|
2014-02-24 19:17:06 +01:00
|
|
|
|
2014-03-02 14:40:58 -05:00
|
|
|
public function testGetHeaderMediaElements()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertAttributeEquals(
|
|
|
|
|
Media::getHeaderMediaElements(),
|
|
|
|
|
'_headerMedia',
|
|
|
|
|
'PhpOffice\\PhpWord\\Media'
|
|
|
|
|
);
|
2014-03-02 14:40:58 -05:00
|
|
|
}
|
2014-02-24 19:17:06 +01:00
|
|
|
|
2014-03-02 14:40:58 -05:00
|
|
|
public function testGetFooterMediaElements()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertAttributeEquals(
|
|
|
|
|
Media::getFooterMediaElements(),
|
|
|
|
|
'_footerMedia',
|
|
|
|
|
'PhpOffice\\PhpWord\\Media'
|
|
|
|
|
);
|
2014-03-02 14:40:58 -05:00
|
|
|
}
|
2014-03-12 09:25:21 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Todo: add memory image to this test
|
|
|
|
|
*
|
2014-03-18 17:26:03 +04:00
|
|
|
* @covers PhpOffice\PhpWord\Media::addSectionMediaElement
|
2014-03-12 09:25:21 -04:00
|
|
|
*/
|
|
|
|
|
public function testAddSectionMediaElement()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$section = new Section(0);
|
2014-03-12 09:25:21 -04:00
|
|
|
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg");
|
|
|
|
|
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg");
|
|
|
|
|
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif");
|
|
|
|
|
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png");
|
|
|
|
|
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp");
|
|
|
|
|
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif");
|
|
|
|
|
|
|
|
|
|
$elements = $section->getElements();
|
|
|
|
|
$this->assertEquals(6, count($elements));
|
|
|
|
|
foreach ($elements as $element) {
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
|
2014-03-12 09:25:21 -04:00
|
|
|
}
|
|
|
|
|
}
|
2014-03-18 17:26:03 +04:00
|
|
|
}
|