Пример #1
0
 public function setUp()
 {
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     $this->di = Di::getDefault();
     Cache::flush();
     Config::clearCache();
     PHPUnit_Framework_TestCase::setUp();
     $class = get_class($this);
     Log::debug("Running {$class}::{$this->getName()}() ...");
 }
Пример #2
0
 public function __construct($config)
 {
     $this->config = $config;
     $ormOptions = $config['orm_options'];
     $ormOptions['distributed'] = $config['distributed'];
     Model::setup($ormOptions);
     if (fnGet($this->config, 'query_log')) {
         Events::attach('db:beforeQuery', function (Event $event) {
             /* @var Adapter $adapter */
             $adapter = $event->getSource();
             $binds = $adapter->getSqlVariables();
             Log::debug($adapter->getSQLStatement() . '; binds = ' . var_export($binds, 1));
         });
     }
 }
Пример #3
0
 public function getContent($basePath = null)
 {
     if ($this->content === null) {
         if (ResourceTrait::$runningUnitTest) {
             Log::debug(sprintf('Asset path: [%s]', $this->_path));
         }
         try {
             if ($this->_local) {
                 $this->content = parent::getContent($basePath);
             } else {
                 $path = $this->_path;
                 substr($this->_path, 0, 2) == '//' and $path = 'http:' . $path;
                 $this->content = file_get_contents($path, false, stream_context_create(['http' => ['method' => 'GET', 'timeout' => 1]]));
             }
         } catch (Exception $e) {
             Log::exception($e);
             $this->content = '';
         }
     }
     return $this->content;
 }
Пример #4
0
 public function tearDown()
 {
     $elapsed = Timer::stop();
     parent::tearDown();
     Log::debug("================== Finished, time elapsed: {$elapsed}. ==================");
 }
Пример #5
0
 public function start($dryRun = false)
 {
     try {
         $dryRun or Log::debug('Starting...');
         return parent::start($dryRun);
     } catch (Exception $e) {
         Log::exception($e);
     }
     return false;
 }