TYPO3 CMS  TYPO3_8-7
SplitButtonTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
24 class SplitButtonTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
25 {
32  {
33  $button = new SplitButton();
34  $isValid = $button->isValid();
35  $this->assertFalse($isValid);
36  }
37 
44  {
45  $this->expectException(\InvalidArgumentException::class);
46  $this->expectExceptionCode(1441706330);
47  $button = new SplitButton();
48 
49  $primaryAction = new LinkButton();
50  $button->addItem($primaryAction);
51 
52  $isValid = $button->isValid();
53  $this->assertFalse($isValid);
54  }
55 
62  {
63  $this->expectException(\InvalidArgumentException::class);
64  $this->expectExceptionCode(1441706340);
65  $button = new SplitButton();
66 
67  $primaryAction = new LinkButton();
68  $icon = new Icon();
69  $primaryAction->setTitle('husel')->setHref('husel')->setIcon($icon);
70  $button->addItem($primaryAction, true);
71 
72  $anotherPrimaryAction = new LinkButton();
73  $anotherPrimaryAction->setTitle('husel')->setHref('husel')->setIcon($icon);
74  $button->addItem($anotherPrimaryAction, true);
75 
76  $isValid = $button->isValid();
77  $this->assertFalse($isValid);
78  }
79 
86  {
87  $this->expectException(\InvalidArgumentException::class);
88  $this->expectExceptionCode(1441706330);
89  $button = new SplitButton();
90 
91  $primaryAction = new LinkButton();
92  $icon = new Icon();
93  $primaryAction->setTitle('husel')->setHref('husel')->setIcon($icon);
94  $button->addItem($primaryAction, true);
95 
96  $anotherPrimaryAction = new LinkButton();
97  $anotherPrimaryAction->setTitle('husel')->setHref('husel');
98  $button->addItem($anotherPrimaryAction, true);
99 
100  $isValid = $button->isValid();
101  $this->assertFalse($isValid);
102  }
103 
110  {
111  $button = new SplitButton();
112 
113  $primaryAction = new LinkButton();
114  $icon = new Icon();
115  $primaryAction->setTitle('husel')->setHref('husel')->setIcon($icon);
116  $button->addItem($primaryAction, true);
117 
118  $anotherAction = new LinkButton();
119  $anotherAction->setTitle('husel')->setHref('husel')->setIcon($icon);
120  $button->addItem($anotherAction);
121 
122  $isValid = $button->isValid();
123  $this->assertTrue($isValid);
124  }
125 }