No Description

AutoloaderTest.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class AutoloaderTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function setUp()
  5. {
  6. if (!defined('PHPEXCEL_ROOT'))
  7. {
  8. define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
  9. }
  10. require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  11. }
  12. public function testAutoloaderNonPHPExcelClass()
  13. {
  14. $className = 'InvalidClass';
  15. $result = PHPExcel_Autoloader::Load($className);
  16. // Must return a boolean...
  17. $this->assertTrue(is_bool($result));
  18. // ... indicating failure
  19. $this->assertFalse($result);
  20. }
  21. public function testAutoloaderInvalidPHPExcelClass()
  22. {
  23. $className = 'PHPExcel_Invalid_Class';
  24. $result = PHPExcel_Autoloader::Load($className);
  25. // Must return a boolean...
  26. $this->assertTrue(is_bool($result));
  27. // ... indicating failure
  28. $this->assertFalse($result);
  29. }
  30. public function testAutoloadValidPHPExcelClass()
  31. {
  32. $className = 'PHPExcel_IOFactory';
  33. $result = PHPExcel_Autoloader::Load($className);
  34. // Check that class has been loaded
  35. $this->assertTrue(class_exists($className));
  36. }
  37. public function testAutoloadInstantiateSuccess()
  38. {
  39. $result = new PHPExcel_Calculation_Function(1,2,3);
  40. // Must return an object...
  41. $this->assertTrue(is_object($result));
  42. // ... of the correct type
  43. $this->assertTrue(is_a($result,'PHPExcel_Calculation_Function'));
  44. }
  45. }