Example #1
0
 /**
  * Test render toggle element.
  *
  * @return void
  */
 public function testToggle()
 {
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Pages', 'action' => 'add', 'pass' => []]]);
     $entity = new Entity();
     $view = new AppView($request);
     $union = new UnionHelper($view);
     $entity->set('id', 10);
     $entity->set('status', 0);
     $actual = $union->toggle($entity);
     $expected = ['div' => ['class' => 'un-toggle-wrapper jsToggle'], 'a' => ['href' => 'javascript:void(0);', 'class' => 'un-red un-link', 'data-url' => '/test_plugin/pages/toggle/10/0'], 'i' => ['class' => 'un-icon fa fa-circle'], '/i', '/a', '/div'];
     $this->assertHtml($expected, $actual);
     $actual = $union->toggle($entity, '/my/path/1/2');
     $expected = ['div' => ['class' => 'un-toggle-wrapper jsToggle'], 'a' => ['href' => 'javascript:void(0);', 'class' => 'un-red un-link', 'data-url' => '/my/path/1/2'], 'i' => ['class' => 'un-icon fa fa-circle'], '/i', '/a', '/div'];
     $this->assertHtml($expected, $actual);
 }