コード例 #1
0
ファイル: AppViewTest.php プロジェクト: UnionCMS/Core
 /**
  * Test form view.
  *
  * @return void
  */
 public function testFormView()
 {
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'add', 'pass' => []]]);
     $controller = new DisplayController($request);
     $view = $controller->createView('Union\\Core\\View\\AppView');
     $view->templatePath('Display');
     $actual = $view->render('Display/Inserted/add');
     $this->assertRegExp('/Is add view/', $actual);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $request = new Request(['params' => ['prefix' => 'admin', 'plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'edit', 'pass' => []]]);
     $controller = new AdminDisplayController($request);
     $view = $controller->createView('Union\\Core\\View\\AppView');
     $view->templatePath('Admin/Display');
     $actual = $view->render();
     $this->assertRegExp('/Is admin form view/', $actual);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $request = new Request(['params' => ['prefix' => 'admin', 'plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'add', 'pass' => []]]);
     $controller = new AdminDisplayController($request);
     $view = $controller->createView('Union\\Core\\View\\AppView');
     $view->templatePath('Admin/Display');
     $actual = $view->render();
     $this->assertRegExp('/Is admin add view/', $actual);
 }
コード例 #2
0
 /**
  * Check process action in admin.
  *
  * @return void
  */
 public function testAdminProcess()
 {
     $Request = new Request(['params' => ['prefix' => 'admin', 'plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'process'], 'post' => ['Fields' => [1 => ['id' => 1]], 'action' => 'params.delete']]);
     $Controller = new DisplayController($Request);
     $result = $Controller->process();
     $session = $Controller->request->session()->read('Flash.admin');
     $expected = [['message' => 'Please choose only one item for this operation.', 'key' => 'admin', 'element' => 'Flash/error', 'params' => []]];
     $this->assertSame($expected, $session);
     $this->assertSame(['Location' => 'http://localhost/admin/TestPlugin/Display/index'], $result->header());
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $Request = new Request(['params' => ['prefix' => 'admin', 'plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'process'], 'post' => ['Display' => [2 => ['id' => 1]], 'action' => 'params.delete']]);
     $Controller = new DisplayController($Request);
     $result = $Controller->process();
     $session = $Controller->request->session()->read('Flash.admin');
     $expected = [['message' => 'Removal was successful (Total: 1).', 'key' => 'admin', 'element' => 'Flash/success', 'params' => []]];
     $this->assertSame($expected, $session);
     $this->assertSame(['Location' => 'http://localhost/admin/TestPlugin/Display/index'], $result->header());
 }