PHPWord/tests/PhpWord/Tests/AutoloaderTest.php

56 lines
1.5 KiB
PHP
Raw Normal View History

<?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
*/
namespace PhpOffice\PhpWord\Tests;
use PhpOffice\PhpWord\Autoloader;
2014-03-27 23:55:06 +07:00
/**
* Test class for PhpOffice\PhpWord\Autoloader
*
* @runTestsInSeparateProcesses
*/
class AutoloaderTest extends \PHPUnit_Framework_TestCase
{
2014-03-28 13:50:53 +07:00
/**
* Register
*/
2014-02-24 19:17:06 +01:00
public function testRegister()
{
Autoloader::register();
$this->assertContains(
array('PhpOffice\\PhpWord\\Autoloader', 'autoload'),
spl_autoload_functions()
);
}
2014-03-02 13:11:33 -05:00
2014-03-28 13:50:53 +07:00
/**
* Autoload
*/
2014-03-02 13:11:33 -05:00
public function testAutoload()
{
$declared = get_declared_classes();
$declaredCount = count($declared);
2014-03-02 13:11:33 -05:00
Autoloader::autoload('Foo');
$this->assertEquals(
$declaredCount,
count(get_declared_classes()),
'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' .
'classes outside of the PhpOffice\\PhpWord namespace'
);
// TODO change this class to the main PhpWord class when it is namespaced
Autoloader::autoload('PhpOffice\\PhpWord\\Exception\\InvalidStyleException');
$this->assertTrue(
in_array('PhpOffice\\PhpWord\\Exception\\InvalidStyleException', get_declared_classes()),
'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' .
'PhpOffice\\PhpWord\\Exception\\InvalidStyleException class'
);
2014-03-02 13:11:33 -05:00
}
}