Exemplo n.º 1
0
 protected function withoutEvents()
 {
     $mock = Mockery::mock('Illuminate\\Contracts\\Events\\Dispatcher');
     $mock->shouldReceive('fire');
     App::instance('events', $mock);
     return $this;
 }
Exemplo n.º 2
0
 function sendEmail($email_template, $subject = '', $additional_data = array(), $from_email = '', $from_name = '')
 {
     $config = (require APPDIR . 'config/email.php');
     $app = App::instance();
     $data = array('user' => $this);
     $data = array_merge($data, $additional_data);
     $message = $app->twig->render('emails/' . $email_template, $data);
     $this->last_email_html = $message;
     $mail = $app->email;
     foreach ($config as $key => $value) {
         $mail->{$key} = $value;
     }
     if ($from_email) {
         $mail->From = $from_email;
     }
     if ($from_name) {
         $mail->FromName = $from_name;
     }
     $mail->Subject = $subject;
     $mail->Body = $message;
     $mail->isHTML($config['isHTML']);
     $mail->addAddress($this->email);
     $mail->send();
     return $this;
 }
Exemplo n.º 3
0
Arquivo: app.php Projeto: nopsky/mbct
	/**
	 * 单例模式
	 * 
	 * @return obj
	 */
	public static function getInstance() {
		if(!isset(self::$instance)) {
			$class = __CLASS__;
			self::$instance = new $class();
		}
		return self::$instance;
	}
Exemplo n.º 4
0
 /**
  * Get singleton instance
  *
  * @return Event
  */
 public static function get_instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new App();
     }
     return self::$instance;
 }
Exemplo n.º 5
0
 public function __construct($config)
 {
     $this->_objects['app'] = App::instance();
     $this->_objects['router'] = Router::instance();
     $this->_objects['inputs'] = Inputs::instance();
     $this->_objects['session'] = Session::instance();
     $this->_objects['log'] = Log::factory();
     if (!isset($this->app->config['database']['redis'][$config['serverId']])) {
         $config['serverId'] = 0;
     }
     $current = $this->app->config['database']['redis'][$config['serverId']];
     $current['serverId'] = $config['serverId'];
     $this->_objects['db'] = Db::factory($current);
     $this->_objects['infoModel'] = new Info_Model($current);
     $info = $this->db->info();
     $dbs = $this->infoModel->getDbs($info);
     if (!isset($current['max_databases'])) {
         $databasesConfig = $this->_objects['db']->config('GET', 'databases');
         $current['max_databases'] = $databasesConfig['databases'];
     }
     // Take care of invalid dbId's. If invalid, set to first available database
     if (!is_numeric($config['dbId']) || $config['dbId'] < 0 || $config['dbId'] >= $current['max_databases']) {
         $config['dbId'] = $dbs[0];
     }
     $current['newDB'] = !in_array($config['dbId'], $dbs) ? true : false;
     $current['database'] = $config['dbId'];
     // Extract number of keys
     foreach ($dbs as $i) {
         if (preg_match('/^keys=([0-9]+),expires=([0-9]+)/', $info["db{$i}"], $matches)) {
             $current['dbs'][$i] = array('id' => $i, 'keys' => $matches[1], 'name' => isset($current['dbNames'][$i]) ? $current['dbNames'][$i] : null);
         }
     }
     $this->db->select($current['database']);
     $this->app->current = $current;
 }
Exemplo n.º 6
0
 public function setupTestModel($name)
 {
     $mock = Mockery::mock($name);
     $mock->shouldIgnoreMissing();
     \App::instance($name, $mock);
     return $mock;
 }
Exemplo n.º 7
0
 /** 
  * @static 
  * @return App 
  */
 public static function Main()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 8
0
 public static function app()
 {
     if (is_null(App::$instance)) {
         App::$instance = new App();
     }
     return App::$instance;
 }
Exemplo n.º 9
0
 static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 10
0
 public function setUp()
 {
     $this->dbRef = new DBTest();
     $this->dbRef->setUp();
     $this->DB = $this->dbRef->DB;
     $this->Person = new PersonModelTest(\App::instance());
 }
Exemplo n.º 11
0
 public static function start()
 {
     self::init();
     self::safe();
     self::checkFolders();
     return App::instance();
 }
Exemplo n.º 12
0
 public static function shouldReceive()
 {
     $repo = get_called_class() . 'RepositoryInterface';
     $mock = Mockery::mock($repo);
     App::instance($repo, $mock);
     return call_user_func_array([$mock, 'shouldReceive'], func_get_args());
 }
Exemplo n.º 13
0
 public function __construct()
 {
     // constructor
     $this->app = App::instance();
     // Get variables by post request
     if ($this->app->post('columns')) {
         $columns = $this->app->post()->get('columns');
         $order = $this->app->post()->get('order');
         $start = $this->app->post()->get('start');
         $length = $this->app->post()->get('length');
         $search = $this->app->post()->get('search');
         $draw = $this->app->post()->get('draw');
     } else {
         // Get variables by get request
         $columns = $this->app->get()->get('columns');
         $order = $this->app->get()->get('order');
         $start = $this->app->get()->get('start');
         $length = $this->app->get()->get('length');
         $search = $this->app->get()->get('search');
         $draw = $this->app->get()->get('draw');
     }
     // Save for later use
     $this->columns = $columns;
     $this->order = $order;
     $this->start = $start;
     $this->length = $length;
     $this->search = $search;
     $this->draw = $draw;
 }
 public function testDestroyShouldCallDestroyMethod()
 {
     $mock = Mockery::mock('PostRepositoryInterface');
     $mock->shouldReceive('destroy')->once()->andReturn(true);
     App::instance('PostRepositoryInterface', $mock);
     $response = $this->call('DELETE', route('v1.posts.destroy', array(1)));
     $this->assertTrue(empty($response->original));
 }
Exemplo n.º 15
0
function baseUrl($path = '')
{
    $baseUrl = App::instance()->request()->getBaseUrl();
    $strippedBaseUrl = str_replace('index.php/', '', $baseUrl);
    $generated = $strippedBaseUrl . '/' . $path;
    $sanitized = str_replace('index.php/', '', $generated);
    return $sanitized;
}
Exemplo n.º 16
0
 public function setupTestService($name = 'test')
 {
     $mock = Mockery::mock($name);
     $mock->shouldIgnoreMissing();
     $mock->actions = ['get' => 'testMethod'];
     \App::instance($name, $mock);
     return $mock;
 }
Exemplo n.º 17
0
 public function __construct($config)
 {
     $this->_objects['app'] = App::instance();
     $this->_objects['router'] = Router::instance();
     $this->_objects['session'] = Session::instance();
     $this->_objects['db'] = Db::factory($config);
     $this->_objects['log'] = Log::factory();
 }
Exemplo n.º 18
0
/**
 * Shortcut untuk mendapatkan semua instance kelas App
 *
 * @return  object
 */
function app($container = '')
{
    $app =& App::instance();
    if ($container) {
        return $app->get($container);
    }
    return $app;
}
 protected function shouldReceive()
 {
     $class = get_called_class();
     $repo = 'Agrosistemas\\Storage\\' . $class . '\\' . $class . 'RepositoryInterface';
     $mock = Mockery::mock($repo);
     App::instance($repo, $mock);
     return call_user_func_array([$mock, 'shouldReceive'], func_get_args());
 }
 /**
  * Creates mock object to this model.
  *
  * @return \Mockery
  */
 public static function shouldReceive()
 {
     $class = get_called_class();
     $repo = 'PullAutomaticallyGalleries\\Storage\\' . $class . '\\' . $class . 'RepositoryInterface';
     $mock = Mockery::mock($repo);
     App::instance($repo, $mock);
     return call_user_func_array([$mock, 'shouldReceive'], func_get_args());
 }
Exemplo n.º 21
0
 protected function __construct()
 {
     ini_set('session.gc_probability', App::instance()->config['session']['gc_probability']);
     ini_set('session.gc_divisor', 100);
     ini_set('session.gc_maxlifetime', App::instance()->config['session']['lifetime']);
     session_name(App::instance()->config['session']['name']);
     session_start();
 }
Exemplo n.º 22
0
 public function testHelperSingleWithFailedCompile()
 {
     \App::instance('gcc', Mockery::mock('GCCompiler')->shouldReceive('reset')->once()->shouldReceive('setFiles')->with('file1.js')->once()->shouldReceive('compile')->once()->andReturn(false)->shouldReceive('getJsDir')->once()->andReturn('js')->shouldReceive('getFiles')->once()->andReturn(array('file1.js' => ''))->mock());
     \Config::set('laravel-gcc::env', array('testing'));
     \File::shouldReceive('lastModified')->once()->andReturn(12345);
     $scriptTag = javascript_compiled('file1.js');
     $this->assertEquals("<script src=\"http://localhost/js/file1.js?12345\"></script>\n", $scriptTag);
 }
Exemplo n.º 23
0
 public static function shouldReceive()
 {
     $class = get_called_class();
     $repo = "Joy\\Storage\\{$class}\\{$class}RepositoryInterface";
     $mock = Mockery::mock($repo);
     App::instance($repo, $mock);
     return call_user_func_array([$mock, 'shouldReceive'], func_get_args());
 }
 public function testStates()
 {
     $model = Mockery::mock('Days\\Day018\\State');
     $model->shouldReceive('where->get')->once();
     App::instance('Days\\Day018\\State', $model);
     $this->call('GET', '/day018/states', array('term' => 'c'));
     $this->assertResponseOk();
 }
Exemplo n.º 25
0
 public function testWithInvalidCep()
 {
     $finder = m::mock('\\Skape\\Zipcode\\Finder');
     $finder->shouldReceive('find')->andThrow('\\Skape\\Zipcode\\Exception');
     App::instance('ZipcodeFinder', $finder);
     $validation = new ZipcodeExists();
     $this->assertFalse($validation->validate('', '', ''));
 }
Exemplo n.º 26
0
 public function testFireWith()
 {
     $mock = m::mock();
     $mock->shouldReceive('get')->once()->andReturn(array());
     App::instance('StriveJobs\\Services\\ListJobInfo', $mock);
     $tester = new CommandTester(new ListJobs());
     $tester->execute(array());
     $this->assertEquals("", $tester->getDisplay());
 }
Exemplo n.º 27
0
 protected function configure()
 {
     $this->query = \App::instance()->db->createSelectQuery();
     $this->setDefinition(array('name' => 'limit', 'mode' => Method::VALUE_OPTIONAL, 'default' => 10));
     $this->setDefinition(array('name' => 'offset', 'mode' => Method::VALUE_OPTIONAL, 'default' => 0));
     $this->setDefinition(array('name' => 'fields', 'mode' => Method::VALUE_OPTIONAL, 'default' => array(), 'parse' => 'parseFields'));
     $this->setDefinition(array('name' => 'sort', 'mode' => Method::VALUE_OPTIONAL));
     $this->setDefinition(array('name' => 'desc', 'mode' => Method::VALUE_OPTIONAL));
 }
Exemplo n.º 28
0
 public function testCleanCommand()
 {
     // mock the compiler
     \App::instance('gcc', Mockery::mock('GCCompiler')->shouldReceive('cleanup')->once()->mock());
     // start the actual test
     $testerClean = new Symfony\Component\Console\Tester\CommandTester(new Jboysen\LaravelGcc\Commands\Clean());
     $testerClean->execute(array());
     $output = $testerClean->getDisplay();
     $this->assertEquals("All compiled bundles are now removed.\n", $output);
 }
Exemplo n.º 29
0
 public function base($withUri = false)
 {
     $app = \App::instance();
     $req = $app->request;
     $uri = $req->getPath();
     if ($withUri) {
         $uri = $req->getUrl() . $uri;
     }
     return $uri;
 }
Exemplo n.º 30
0
 public static function factory($driver = null)
 {
     $driver = isset($driver) ? $driver : App::instance()->config['log']['driver'];
     if (!isset(self::$_instances[$driver])) {
         include_once App::instance()->drivers . 'log/' . strtolower($driver) . '.php';
         $class = ucwords(strtolower($driver)) . 'Log';
         self::$_instances[$driver] = new $class();
     }
     return self::$_instances[$driver];
 }