PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/site/application/third_party/php-activerecord/test/helpers/config.php

https://bitbucket.org/thiscode/thiscode-shop
PHP | 76 lines | 50 code | 15 blank | 11 comment | 11 complexity | 4d7d9ffcb2793ac23549522aa835a577 MD5 | raw file
  1. <?php
  2. /**
  3. * In order to run these unit tests, you need to install:
  4. * - PHPUnit
  5. * - PEAR Log (otherwise logging SQL queries will be disabled)
  6. * - Memcache (otherwise Caching tests will not be executed)
  7. *
  8. * To run all tests : phpunit AllTests.php --slow-tests
  9. * To run a specific test : phpunit ????Test.php
  10. */
  11. @include_once 'Log.php';
  12. @include_once 'Log/file.php';
  13. require_once 'PHPUnit/Framework/TestCase.php';
  14. require_once 'SnakeCase_PHPUnit_Framework_TestCase.php';
  15. require_once 'DatabaseTest.php';
  16. require_once 'AdapterTest.php';
  17. require_once __DIR__ . '/../../ActiveRecord.php';
  18. // whether or not to run the slow non-crucial tests
  19. $GLOBALS['slow_tests'] = false;
  20. // whether or not to show warnings when Log or Memcache is missing
  21. $GLOBALS['show_warnings'] = true;
  22. if (getenv('LOG') !== 'false')
  23. DatabaseTest::$log = true;
  24. ActiveRecord\Config::initialize(function($cfg)
  25. {
  26. $cfg->set_model_directory(realpath(__DIR__ . '/../models'));
  27. $cfg->set_connections(array(
  28. 'mysql' => getenv('PHPAR_MYSQL') ?: 'mysql://test:test@127.0.0.1/test',
  29. 'pgsql' => getenv('PHPAR_PGSQL') ?: 'pgsql://test:test@127.0.0.1/test',
  30. 'oci' => getenv('PHPAR_OCI') ?: 'oci://test:test@127.0.0.1/dev',
  31. 'sqlite' => getenv('PHPAR_SQLITE') ?: 'sqlite://test.db'));
  32. $cfg->set_default_connection('mysql');
  33. for ($i=0; $i<count($GLOBALS['argv']); ++$i)
  34. {
  35. if ($GLOBALS['argv'][$i] == '--adapter')
  36. $cfg->set_default_connection($GLOBALS['argv'][$i+1]);
  37. elseif ($GLOBALS['argv'][$i] == '--slow-tests')
  38. $GLOBALS['slow_tests'] = true;
  39. }
  40. if (class_exists('Log_file')) // PEAR Log installed
  41. {
  42. $logger = new Log_file(dirname(__FILE__) . '/../log/query.log','ident',array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
  43. $cfg->set_logging(true);
  44. $cfg->set_logger($logger);
  45. }
  46. else
  47. {
  48. if ($GLOBALS['show_warnings'] && !isset($GLOBALS['show_warnings_done']))
  49. echo "(Logging SQL queries disabled, PEAR::Log not found.)\n";
  50. DatabaseTest::$log = false;
  51. }
  52. if ($GLOBALS['show_warnings'] && !isset($GLOBALS['show_warnings_done']))
  53. {
  54. if (!extension_loaded('memcache'))
  55. echo "(Cache Tests will be skipped, Memcache not found.)\n";
  56. }
  57. date_default_timezone_set('UTC');
  58. $GLOBALS['show_warnings_done'] = true;
  59. });
  60. error_reporting(E_ALL | E_STRICT);
  61. ?>