2013-12-11 15:08:54 -05:00
|
|
|
<?php
|
2014-03-23 11:59:22 -04:00
|
|
|
namespace PhpOffice\PhpWord\Tests;
|
2013-12-11 15:08:54 -05:00
|
|
|
|
2014-03-22 10:06:08 +04:00
|
|
|
use PhpOffice\PhpWord\Autoloader;
|
2013-12-11 15:08:54 -05:00
|
|
|
|
2014-03-12 20:13:06 +04:00
|
|
|
class AutoloaderTest extends \PHPUnit_Framework_TestCase
|
2013-12-11 15:08:54 -05:00
|
|
|
{
|
2014-02-24 19:17:06 +01:00
|
|
|
public function testRegister()
|
|
|
|
|
{
|
2014-03-22 10:06:08 +04:00
|
|
|
Autoloader::register();
|
|
|
|
|
$this->assertContains(
|
|
|
|
|
array('PhpOffice\\PhpWord\\Autoloader', 'autoload'),
|
|
|
|
|
\spl_autoload_functions()
|
2014-03-12 13:30:02 +07:00
|
|
|
);
|
2013-12-11 15:08:54 -05:00
|
|
|
}
|
2014-03-02 13:11:33 -05:00
|
|
|
|
|
|
|
|
public function testAutoload()
|
|
|
|
|
{
|
2014-03-22 10:06:08 +04:00
|
|
|
$declared = \get_declared_classes();
|
|
|
|
|
$declaredCount = \count($declared);
|
2014-03-02 13:11:33 -05:00
|
|
|
Autoloader::autoload('Foo');
|
2014-03-12 13:30:02 +07:00
|
|
|
$this->assertEquals(
|
|
|
|
|
$declaredCount,
|
2014-03-22 10:06:08 +04:00
|
|
|
\count(get_declared_classes()),
|
2014-03-23 17:37:26 +07:00
|
|
|
'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' .
|
|
|
|
|
'classes outside of the PhpOffice\\PhpWord namespace'
|
2014-03-12 13:30:02 +07:00
|
|
|
);
|
2014-03-20 16:54:12 +04:00
|
|
|
// TODO change this class to the main PhpWord class when it is namespaced
|
2014-03-22 10:06:08 +04:00
|
|
|
Autoloader::autoload('PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException');
|
2014-03-12 13:30:02 +07:00
|
|
|
$this->assertTrue(
|
2014-03-22 10:06:08 +04:00
|
|
|
\in_array('PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException', \get_declared_classes()),
|
2014-03-23 17:37:26 +07:00
|
|
|
'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' .
|
|
|
|
|
'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException class'
|
2014-03-12 13:30:02 +07:00
|
|
|
);
|
2014-03-02 13:11:33 -05:00
|
|
|
}
|
2014-03-23 17:37:26 +07:00
|
|
|
}
|