Exemplo n.º 1
0
 /**
  * @param array $import
  *
  * @return $this|void
  */
 function merge($import)
 {
     # set normalize paths
     array_map(function ($key, $path) use(&$import) {
         $this->set($key, Util::normalize_path($path));
     }, array_keys($import), array_values($import));
     return $this;
 }
Exemplo n.º 2
0
/**
 * @param     $var
 * @param int $depth
 *
 * @return mixed
 */
function og_dump($var = NULL, $depth = 12)
{
    \Tracy\Debugger::$maxDepth = $depth;
    $args = func_get_args();
    Util::array_forget(func_num_args() - 1, $args);
    $dumper = defined('PHPUNIT_TESTS__') ? 'Tracy\\Dumper::toTerminal' : 'Tracy\\Debugger::dump';
    array_map($dumper, $args);
    return $var;
}
Exemplo n.º 3
0
 function test_Paths()
 {
     $paths = $this->paths;
     $this->assertEquals($paths->copy(), ['root' => ROOT, 'vendors' => VENDOR, 'config' => Util::strip_tail('/', realpath(__DIR__ . '/../../config/')) . '/']);
     $paths->add('goop', '/here/to/goop');
     $this->assertEquals(VENDOR, $paths['vendors']);
     $this->assertEquals(ROOT, $paths->{'root'});
     $this->assertEquals('/here/to/goop', $paths['goop']);
     $paths->set('test', 'nothing');
     $this->assertTrue($paths->has('test'));
     $this->assertNull($paths->set(0, 'value'));
     $paths['test'] = 'something';
     $paths->offsetUnset('test');
     $this->assertFalse($paths->has('test'));
 }
Exemplo n.º 4
0
 /**
  * Glob a set of file names from a normalized path.
  *
  * @param $base_path
  *
  * @return array
  */
 private function files_from_path($base_path)
 {
     $base_path = Util::normalize_path($base_path);
     $files = glob($base_path . "*.php");
     return $files;
 }
Exemplo n.º 5
0
 /**
  * @param $controller
  *
  * @return string
  */
 private function normalize_namespace($controller)
 {
     $namespace = Util::parse_class_name($controller);
     if (empty($namespace['namespace_path'])) {
         return static::APP_NAMESPACE . $controller;
     }
     return $controller;
 }
Exemplo n.º 6
0
 public function test06()
 {
     $searchRA = ['name' => 'greg', 'record' => ['age' => 100, 'amount' => 26.58, 'source' => 'pension']];
     $this->assertEquals('not found', Util::array_get('record.lazy', $searchRA, 'not found'));
     $this->assertEquals($searchRA['record'], Util::array_search_and_replace('record.lazy', $searchRA, 'not found'));
     $this->assertEquals(26.58, Util::array_get('record.amount', $searchRA, 'not found'));
     //$this->assertEquals('not found', Util::search('not.there', $searchRA, 'not found'));
     //die_dump([$resultSearch, $resultGet]);
 }
Exemplo n.º 7
0
 /**
  * Get the wildcard listeners for the event.
  *
  * @param  string $eventName
  *
  * @return array
  */
 private function get_wildcard_listeners($eventName)
 {
     $wildcards = [];
     foreach ($this->wildcards as $wildcard => $listeners) {
         if (Util::pattern_matches($eventName, $wildcard)) {
             $wildcards = array_merge($wildcards, $listeners);
         }
     }
     return $wildcards;
 }
Exemplo n.º 8
0
 public function test8_Iteration()
 {
     # iteration
     $this->assertTrue(static::$collection->getIterator() instanceof \ArrayIterator);
     $result = [];
     foreach (static::$collection as $key => $value) {
         $result[] = $key;
     }
     sort($result);
     $this->assertEquals($result, Util::array_from_str('json part1 part2 yaml'));
 }
Exemplo n.º 9
0
 public function test06()
 {
     ### http_code($key, $default = NULL)
     $this->assertEquals('404 Not Found', Util::http_code(404));
     $this->assertEquals(502, Util::http_code('Bad Gateway'));
     $this->assertEquals(900, Util::http_code('Purple Rain', 900));
     ### file_in_path($name, Array $paths)
     $this->assertStringEndsWith('readable_jason.json', Util::file_in_path('readable_jason.json', [__DIR__ . '/']));
     ### format_for_url($string)
     $this->assertEquals('the-balls-are-bouncy-eh', Util::str_to_url('The balls are bouncy, eh?'));
 }
Exemplo n.º 10
0
 public function test_02_BladeView_layout()
 {
     $html = $this->view->render('pages.home', ['contents' => 'This was passed at render time.']);
     $this->assertTrue(Util::string_has('<div class="container">', $html));
     $this->assertTrue(Util::string_has('This was passed at render time', $html));
 }