PHPWord/Tests/PHPWord/AutoloaderTest.php

32 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace PHPWord\Tests;
use PHPUnit_Framework_TestCase;
use PHPWord_Autoloader;
2014-03-02 13:11:33 -05:00
use PHPWord_Autoloader as Autoloader;
class AutoloaderTest extends PHPUnit_Framework_TestCase
{
2014-02-24 19:17:06 +01:00
public function testRegister()
{
PHPWord_Autoloader::register();
$this->assertContains(array('PHPWord_Autoloader', 'load'), spl_autoload_functions());
2014-03-02 13:11:33 -05:00
$this->assertContains(array('PHPWord_Autoloader', 'autoload'), spl_autoload_functions());
2014-02-24 19:17:06 +01:00
}
2014-03-02 13:11:33 -05:00
public function testAutoloadLegacy()
{
$this->assertNull(PHPWord_Autoloader::load('Foo'), 'PHPWord_Autoloader::load() is trying to load classes outside of the PHPWord namespace');
$this->assertTrue(PHPWord_Autoloader::load('PHPWord'), 'PHPWord_Autoloader::load() failed to autoload the PHPWord class');
}
2014-03-02 13:11:33 -05:00
public function testAutoload()
{
$declared = get_declared_classes();
$declaredCount = count($declared);
Autoloader::autoload('Foo');
$this->assertEquals($declaredCount, count(get_declared_classes()), 'PHPWord\\Autoloader::autoload() is trying to load classes outside of the PHPWord namespace');
Autoloader::autoload('PHPWord\\Exceptions\\InvalidStyleException'); // TODO change this class to the main PHPWord class when it is namespaced
$this->assertTrue(in_array('PHPWord\\Exceptions\\InvalidStyleException', get_declared_classes()), 'PHPWord\\Autoloader::autoload() failed to autoload the PHPWord\\Exceptions\\InvalidStyleException class');
}
}