ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once("vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "/../../../Base.php");
23 
26 use ILIAS\Data;
29 
34 {
35  protected Implementation\Standard $link_action;
36  protected Data\URI $link_target;
37  protected Implementation\Standard $signal_action;
39 
40  protected function buildFactories()
41  {
42  return [
43  new Implementation\Factory(),
44  new Data\Factory()
45  ];
46  }
47 
48  public function setUp(): void
49  {
50  list($f, $df) = $this->buildFactories();
51  $target = $df->uri('http://wwww.ilias.de?ref_id=1');
52 
53  $url_builder = new URLBuilder($target);
54  list($builder, $token) = array_values(
55  $url_builder->acquireParameter(['namespace'], 'rowids')
56  );
57 
58  $label = 'label';
59  $this->link_target = $target;
60  $this->link_action = $f->standard($label, $builder, $token);
61  $this->signal_target = new Signal('sig_id');
62  $this->signal_action = $this->link_action->withAsync(true);
63  }
64 
65  public function testDataTableActionAttributes(): void
66  {
67  $act = $this->link_action;
68  $this->assertEquals('label', $act->getLabel());
69  $this->assertEquals($this->link_target . "&namespace_rowids=", $act->getTarget());
70  $this->assertFalse($this->link_action->isAsync());
71  $this->assertTrue($this->signal_action->isAsync());
72  $this->assertIsString($this->signal_action->getURLBuilderJS());
73  $this->assertIsString($this->signal_action->getURLBuilderTokensJS());
74  }
75 
76  public function testDataTableActionSignalTarget(): void
77  {
78  $act = $this->signal_action->withSignalTarget($this->signal_target);
79  $this->assertEquals($this->signal_target, $act->getTarget());
80  }
81 
82  public function testDataTableActionStringTarget(): void
83  {
84  $this->expectException(\TypeError::class);
85  list($f, $df) = $this->buildFactories();
86  $act = $f->standard('', '', '');
87  }
88 
89  public function testDataTableActionRowIdOnURI(): void
90  {
91  $act = $this->link_action->withRowId('test-id');
92  $this->assertEquals(
93  'ref_id=1&namespace_rowids[]=test-id',
94  urldecode($act->getTarget()->getQuery())
95  );
96  }
97 }
Implementation Standard $signal_action
Definition: ActionTest.php:37
Basic Tests for Table-Actions.
Definition: ActionTest.php:33
Implementation Standard $link_action
Definition: ActionTest.php:35
Signal $signal_target
Definition: ActionTest.php:38
testDataTableActionRowIdOnURI()
Definition: ActionTest.php:89
$token
Definition: xapitoken.php:70
testDataTableActionStringTarget()
Definition: ActionTest.php:82
testDataTableActionSignalTarget()
Definition: ActionTest.php:76
testDataTableActionAttributes()
Definition: ActionTest.php:65
buildFactories()
Definition: ActionTest.php:40
Data URI $link_target
Definition: ActionTest.php:36
URLBuilder.
Definition: URLBuilder.php:40