2014-02-24 19:17:06 +01:00
|
|
|
<?php
|
|
|
|
|
namespace PHPWord\Tests;
|
|
|
|
|
|
|
|
|
|
use PHPUnit_Framework_TestCase;
|
|
|
|
|
use PHPWord;
|
|
|
|
|
use PHPWord_IOFactory;
|
|
|
|
|
use PHPWord_Writer_Word2007;
|
2014-03-09 14:18:49 -04:00
|
|
|
use Exception;
|
2014-02-24 19:17:06 +01:00
|
|
|
|
|
|
|
|
/**
|
2014-03-09 14:18:49 -04:00
|
|
|
* Class IOFactoryTest
|
2014-02-24 19:17:06 +01:00
|
|
|
* @package PHPWord\Tests
|
|
|
|
|
* @runTestsInSeparateProcesses
|
|
|
|
|
*/
|
2014-03-09 14:18:49 -04:00
|
|
|
class IOFactoryTest extends \PHPUnit_Framework_TestCase
|
2014-03-02 14:40:58 -05:00
|
|
|
{
|
|
|
|
|
public function testGetSearchLocations()
|
|
|
|
|
{
|
|
|
|
|
$this->assertAttributeEquals(PHPWord_IOFactory::getSearchLocations(), '_searchLocations', 'PHPWord_IOFactory');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetSearchLocationsWithArray()
|
|
|
|
|
{
|
|
|
|
|
PHPWord_IOFactory::setSearchLocations(array());
|
|
|
|
|
$this->assertAttributeEquals(array(), '_searchLocations', 'PHPWord_IOFactory');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-09 14:18:49 -04:00
|
|
|
* @expectedException Exception
|
2014-03-02 14:40:58 -05:00
|
|
|
* @expectedExceptionMessage Invalid parameter passed.
|
|
|
|
|
*/
|
|
|
|
|
public function testSetSearchLocationsWithNotArray()
|
|
|
|
|
{
|
|
|
|
|
PHPWord_IOFactory::setSearchLocations('String');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAddSearchLocation()
|
|
|
|
|
{
|
|
|
|
|
PHPWord_IOFactory::setSearchLocations(array());
|
|
|
|
|
PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname');
|
|
|
|
|
$this->assertAttributeEquals(array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')), '_searchLocations', 'PHPWord_IOFactory');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-09 14:18:49 -04:00
|
|
|
* @expectedException Exception
|
2014-03-02 14:40:58 -05:00
|
|
|
* @expectedExceptionMessage No IWriter found for type
|
|
|
|
|
*/
|
|
|
|
|
public function testCreateWriterException()
|
|
|
|
|
{
|
|
|
|
|
$oPHPWord = new PHPWord();
|
|
|
|
|
|
|
|
|
|
PHPWord_IOFactory::setSearchLocations(array());
|
|
|
|
|
PHPWord_IOFactory::createWriter($oPHPWord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCreateWriter()
|
|
|
|
|
{
|
|
|
|
|
$oPHPWord = new PHPWord();
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'), new PHPWord_Writer_Word2007($oPHPWord));
|
|
|
|
|
}
|
2014-03-11 21:44:54 +07:00
|
|
|
}
|