No Description

bootstrap.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord 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/PHPWord/contributors. test bootstrap
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. date_default_timezone_set('UTC');
  18. // defining base dir for tests
  19. if (!defined('PHPWORD_TESTS_BASE_DIR')) {
  20. define('PHPWORD_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. throw new Exception('Unable to load dependencies');
  27. }
  28. spl_autoload_register(function ($class) {
  29. $class = ltrim($class, '\\');
  30. $prefix = 'PhpOffice\\PhpWord\\Tests';
  31. if (strpos($class, $prefix) === 0) {
  32. $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
  33. $class = join(DIRECTORY_SEPARATOR, array('PhpWord', 'Tests', '_includes')) .
  34. substr($class, strlen($prefix));
  35. $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
  36. if (file_exists($file)) {
  37. require_once $file;
  38. }
  39. }
  40. });
  41. require_once __DIR__ . '/../src/PhpWord/Autoloader.php';
  42. \PhpOffice\PhpWord\Autoloader::register();