bootstrap.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * This file is part of PHPPresentation - A pure PHP library for reading and writing
  4. * presentations documents.
  5. *
  6. * PHPPresentation is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
  12. *
  13. * @copyright 2010-2014 PhpPresentation contributors
  14. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  15. * @link https://github.com/PHPOffice/PHPPresentation
  16. */
  17. date_default_timezone_set('UTC');
  18. // defining base dir for tests
  19. if (!defined('PHPPRESENTATION_TESTS_BASE_DIR')) {
  20. define('PHPPRESENTATION_TESTS_BASE_DIR', realpath(__DIR__));
  21. }
  22. $vendor = realpath(__DIR__ . '/../vendor');
  23. if (file_exists($vendor . "/autoload.php")) {
  24. require $vendor . "/autoload.php";
  25. } else {
  26. $vendor = realpath(__DIR__ . '/../../../');
  27. if (file_exists($vendor . "/autoload.php")) {
  28. require $vendor . "/autoload.php";
  29. } else {
  30. throw new Exception("Unable to load dependencies");
  31. }
  32. }
  33. spl_autoload_register(function ($class) {
  34. $class = ltrim($class, '\\');
  35. $prefix = 'PhpOffice\\PhpPresentation\\Tests';
  36. if (strpos($class, $prefix) === 0) {
  37. $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
  38. $class = join(DIRECTORY_SEPARATOR, array('PhpPresentation', 'Tests', '_includes')) .
  39. substr($class, strlen($prefix));
  40. $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
  41. if (file_exists($file)) {
  42. require_once $file;
  43. }
  44. }
  45. });
  46. require_once __DIR__ . "/../src/PhpPresentation/Autoloader.php";
  47. \PhpOffice\PhpPresentation\Autoloader::register();