Пример #1
0
 /**
  * @param string $filename
  * @return string
  * */
 public function contentRaw($filename)
 {
     if (!$this->has($filename)) {
         throw new IOException(self::T_DOWNLOADER_STR_FILE_NOT_FOUND, self::T_DOWNLOADER_CODE_FILE_NOT_FOUND);
     }
     $this->_before->__invoke();
     return file_get_contents($this->__fullpath($filename));
 }
Пример #2
0
 /**
  * Asserts specific queries going into the database. Currently assumes mongo.
  *
  * Yikes this is a stubby method, but honey badger don't give a shit.
  *
  * {{{
  * $this->assertQueries()
  * }}}
  *
  * @param  string    $class     Fully namespaced model class.
  * @param  int       $expected  Number of queries expected.
  * @param  callback  $query     Callback to be executed, contains the `::find` or `::all`.
  * @param  string    $message   optional
  * @return bool
  */
 public function assertQueries($class, $expected, $query, $message = '{:message}')
 {
     $result = array();
     $args = array();
     $connection = $class::connection();
     $connection->applyFilter('read', function ($self, $params, $chain) use(&$result, &$args) {
         $args = $params['query']->export($self);
         $queryParams = array('name' => $params['query']->config('source'));
         foreach (array('conditions', 'fields', 'order', 'limit', 'offset') as $key) {
             if (!empty($args[$key])) {
                 $queryParams[$key] = $args[$key];
             }
         }
         $result[] = $queryParams;
         return $chain->next($self, $params, $chain);
     });
     $query->__invoke();
     $connection->applyFilter('read', false);
     return $this->assertEqual($expected, $result, $message, compact('expected', 'result'));
 }