2014-02-24 19:17:06 +01:00
|
|
|
<?php
|
2014-03-27 23:55:06 +07:00
|
|
|
/**
|
|
|
|
|
* PHPWord
|
|
|
|
|
*
|
|
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
|
|
|
|
* @copyright 2014 PHPWord
|
|
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
|
|
|
*/
|
|
|
|
|
|
2014-03-23 11:59:22 -04:00
|
|
|
namespace PhpOffice\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-27 23:55:06 +07:00
|
|
|
/**
|
|
|
|
|
* Test class for PhpOffice\PhpWord\Media
|
|
|
|
|
*
|
|
|
|
|
* @coversDefaultClass \PhpOffice\PhpWord\Media
|
|
|
|
|
* @runTestsInSeparateProcesses
|
|
|
|
|
*/
|
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-23 10:32:08 +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-23 12:37:31 -04:00
|
|
|
$section->addImage(__DIR__ . "/_files/images/mars_noext_jpg");
|
|
|
|
|
$section->addImage(__DIR__ . "/_files/images/mars.jpg");
|
|
|
|
|
$section->addImage(__DIR__ . "/_files/images/mario.gif");
|
|
|
|
|
$section->addImage(__DIR__ . "/_files/images/firefox.png");
|
|
|
|
|
$section->addImage(__DIR__ . "/_files/images/duke_nukem.bmp");
|
|
|
|
|
$section->addImage(__DIR__ . "/_files/images/angela_merkel.tif");
|
2014-03-12 09:25:21 -04:00
|
|
|
|
|
|
|
|
$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-23 17:37:26 +07:00
|
|
|
}
|