Beispiel #1
0
 /**
  * Core dispatch event.
  *
  * @param string $name
  * @param object|null $subject
  * @param null $data
  * @return \Cake\Event\Event
  */
 public static function dispatch($name, $subject = null, $data = null)
 {
     $event = new CakeEvent($name, $subject, $data);
     if ($subject) {
         $event = $subject->eventManager()->dispatch($event);
     } else {
         $event = EventManager::instance()->dispatch($event);
     }
     return $event;
 }
Beispiel #2
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::loadList(['TestPlugin']);
     EventManager::loadListeners();
 }
Beispiel #3
0
Request::addDetector('tablet', function ($request) {
    $detector = new \Detection\MobileDetect();
    return $detector->isTablet();
});
//  Load union core plugin.
Plugin::load('Union/Core', ['bootstrap' => true, 'routes' => true]);
Plugin::load('Migrations');
//  Load DebugKit plugin.
if (Configure::read('debug')) {
    Plugin::load('DebugKit', ['bootstrap' => true]);
}
$plugins = ROOT . '/config/plugins.php';
if (file_exists($plugins)) {
    /** @noinspection PhpIncludeInspection */
    $plugins = (include $plugins);
    if (is_array($plugins)) {
        \Union\Core\Plugin::loadList($plugins);
    }
}
//  Connect middleware/dispatcher filters.
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
/**
 * Enable default locale format parsing.
 * This is needed for matching the auto-localized string output of Time() class when parsing dates.
 */
Type::build('date')->useLocaleParser();
Type::build('datetime')->useLocaleParser();
EventManager::loadListeners();
 /**
  * Test success save in add action.
  *
  * @return void
  */
 public function testAddAction()
 {
     Configure::load($this->plugin . '.events');
     EventManager::loadListeners();
     $this->enableCsrfToken();
     $this->enableSecurityToken();
     $this->url['action'] = 'add';
     $this->data['username'] = '******';
     $this->data['password'] = '******';
     $this->data['notify'] = 1;
     $this->data['password_confirm'] = '123456';
     $this->_unlocked = ['password', 'password_confirm'];
     $this->post($this->url, $this->data);
     $this->assertResponseSuccess();
     $this->assertRedirect(['prefix' => 'admin', 'plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'index']);
 }