File tree Expand file tree Collapse file tree
Configuration/TCA/Overrides
Tests/Unit/Tca/DisplayCond Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Ayacoo \AyacooSoundcloud \Tca \DisplayCond ;
6+
7+ class IsSoundcloud
8+ {
9+ /**
10+ * @param array<string,mixed> $parameters
11+ */
12+ public function match (array $ parameters ): bool
13+ {
14+ $ record = $ parameters ['record ' ] ?? [];
15+ if (!is_array ($ record )) {
16+ return false ;
17+ }
18+
19+ return (!empty ($ record ['soundcloud_html ' ] ?? '' ));
20+ }
21+ }
Original file line number Diff line number Diff line change 1616 'readOnly ' => true ,
1717 'size ' => 40 ,
1818 ],
19+ 'displayCond ' => 'USER:Ayacoo \\AyacooSoundcloud \\Tca \\DisplayCond \\IsSoundcloud->match ' ,
1920 ],
2021 'soundcloud_html ' => [
2122 'exclude ' => true ,
2728 'rows ' => 4 ,
2829 'readOnly ' => true ,
2930 ],
31+ 'displayCond ' => 'USER:Ayacoo \\AyacooSoundcloud \\Tca \\DisplayCond \\IsSoundcloud->match ' ,
3032 ],
3133 'soundcloud_author_url ' => [
3234 'exclude ' => true ,
3840 'readOnly ' => true ,
3941 'size ' => 40 ,
4042 ],
43+ 'displayCond ' => 'USER:Ayacoo \\AyacooSoundcloud \\Tca \\DisplayCond \\IsSoundcloud->match ' ,
4144 ],
4245];
4346
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Ayacoo \AyacooSoundcloud \Tests \Unit \Tca \DisplayCond ;
6+
7+ use Ayacoo \AyacooSoundcloud \Tca \DisplayCond \IsSoundcloud ;
8+ use PHPUnit \Framework \TestCase ;
9+
10+ final class IsSoundcloudTest extends TestCase
11+ {
12+ private IsSoundcloud $ subject ;
13+
14+ protected function setUp (): void
15+ {
16+ parent ::setUp ();
17+ $ this ->subject = new IsSoundcloud ();
18+ }
19+
20+ public function testReturnsFalseIfParametersAreEmpty (): void
21+ {
22+ self ::assertFalse ($ this ->subject ->match ([]));
23+ }
24+
25+ public function testReturnsFalseIfRecordIsNotArray (): void
26+ {
27+ $ params = ['record ' => 'not-an-array ' ];
28+ self ::assertFalse ($ this ->subject ->match ($ params ));
29+ }
30+
31+ public function testReturnsFalseIfSoundcloudHtmlIsMissing (): void
32+ {
33+ $ params = ['record ' => []];
34+ self ::assertFalse ($ this ->subject ->match ($ params ));
35+ }
36+
37+ public function testReturnsFalseIfSoundcloudHtmlIsEmptyString (): void
38+ {
39+ $ params = ['record ' => ['soundcloud_html ' => '' ]];
40+ self ::assertFalse ($ this ->subject ->match ($ params ));
41+ }
42+
43+ public function testReturnsTrueIfSoundcloudHtmlHasContent (): void
44+ {
45+ $ params = ['record ' => ['soundcloud_html ' => '<iframe>...</iframe> ' ]];
46+ self ::assertTrue ($ this ->subject ->match ($ params ));
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments