예제 #1
0
 public function test_Listening()
 {
     $di = Forge::getInstance();
     /** @var Collection $collection */
     $collection = new Collection();
     /** @var Events $events */
     $events = $di['events'];
     $events->subscribe(Collection::class);
     # we start with nothing
     $this->assertFalse($collection->any());
     # now listen for a collection new item
     $events->listen('collection.new.item', EventsTest::class . '@test_CollectionEvent');
     $this->assertEquals('collection.fired', $events->fire('collection.new.item')[0]);
 }
예제 #2
0
 public function register()
 {
     /** @var Forge $di */
     $di = $this->forge;
     # register collections and paths
     # $forge->add(['collection', Collection::class]);
     $di->add(['paths', Paths::class]);
     # cogs principle service container
     $di->singleton([ContainerInterface::class, Forge::class], new Forge());
     # illuminate/container service container
     $di->singleton(['ioc', IlluminateContainer::class], function () {
         return Forge::getInstance()->container();
     });
     # register Application context
     $di->singleton(['context', Context::class], new Context());
     # register cogs principle event dispatcher
     $di->singleton(['events', Events::class], new Events());
     $this->provides += [Context::class, Events::class, Paths::class];
 }
예제 #3
0
파일: debug.php 프로젝트: anctemarry27/cogs
<?php

/**
 * @package Og
 * @version 0.1.0
 * @author  Greg Truesdell <*****@*****.**>
 */
use Og\Forge;
use Og\Support\Util;
use Tracy\Debugger;
use Tracy\FireLogger;
Debugger::$maxDepth = 6;
Debugger::enable(Debugger::DEVELOPMENT, LOCAL_LOGS);
Debugger::$showLocation = TRUE;
$logger = Debugger::getLogger();
Forge::getInstance()->instance(['logger', FireLogger::class], $logger);
/**
 * @param bool $raw
 *
 * @return string
 */
function elapsed_time_since_request($raw = FALSE)
{
    return !$raw ? sprintf("%8.1f ms", (microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000) : (microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000;
}
/**
 * @param $index
 *
 * @return string
 */
function location_from_backtrace($index = 2)
예제 #4
0
 /**
  * @param $alias
  *
  * @return Forge|object
  */
 function forge($alias = '')
 {
     static $forge;
     $forge = $forge ?: Forge::getInstance();
     return empty($alias) ? $forge : $forge->get($alias);
 }
예제 #5
0
파일: boot.php 프로젝트: anctemarry27/cogs
<?php

/**
 * @package Og
 * @author  Greg Truesdell <*****@*****.**>
 */
namespace Og;

use Dotenv\Dotenv;
use Og\Kernel\Kernel;
# get the root
define('TEST_PATH', dirname(__DIR__) . '/../');
define('Og\\COLLECT_FUNCTIONS_AND_CLASSES', FALSE);
date_default_timezone_set('America/Vancouver');
include TEST_PATH . 'boot/paths.php';
include SUPPORT . 'helpers.php';
include SUPPORT . 'messages.php';
include TEST_PATH . 'vendor/autoload.php';
# load environment
if (file_exists(TEST_PATH . 'tests/.env')) {
    $dotenv = new Dotenv(TEST_PATH);
    $dotenv->load();
}
include BOOT . 'debug.php';
$forge = Forge::getInstance();
$forge->add(['config', Config::class], Config::createFromFolder(CONFIG));
//new Application(new Kernel(Forge::getInstance()));
new Kernel(Forge::getInstance());
예제 #6
0
 /**
  * Middleware 'Factory'
  *
  * @return static
  */
 public static function create()
 {
     # cache a forge reference
     static $forge = NULL;
     $forge = $forge ?: Forge::getInstance();
     return new static($forge);
 }
예제 #7
0
 /**
  * AbstractView constructor.
  *
  * @param array $settings
  *
  */
 public function __construct($settings = [])
 {
     $this->forge = Forge::getInstance();
     parent::__construct($settings);
 }
예제 #8
0
 /**
  * @return null|Events
  */
 static function getInstance()
 {
     return static::$instance ?: new static(Forge::getInstance());
 }
예제 #9
0
 /** @return static */
 public function getInstance()
 {
     return static::$instance ?: new static(new Kernel(Forge::getInstance()));
 }
예제 #10
0
 public function setUp()
 {
     $this->di = Forge::getInstance();
     $this->sm = new Services($this->di);
 }
예제 #11
0
 public function test01()
 {
     $app = new Application(new Kernel(Forge::getInstance()));
     //$this->assertEquals($app, app('app'));
 }
예제 #12
0
 public function test_Instances()
 {
     $di = $this->forge;
     # verify forge() equivalency
     $this->assertEquals($di, forge());
     $this->assertEquals(Forge::getInstance(), forge());
     $this->assertTrue($di->container() instanceof Illuminate\Container\Container);
     $this->assertTrue(array_key_exists('Og\\Forge', $di->container('getBindings')));
 }