File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77class Installed extends Tags
88{
9+ /**
10+ * Check if composer package is installed via {{ installed package="vendor/package" }}.
11+ *
12+ * @return string|void
13+ */
14+ public function index ()
15+ {
16+ if (! $ package = $ this ->params ->get ('package ' )) {
17+ return ;
18+ }
19+
20+ return $ this ->installed ($ package );
21+ }
22+
923 /**
1024 * Check if composer package is installed via {{ installed:* }}.
1125 *
1226 * @param string $package
1327 * @return string|void
1428 */
1529 public function wildcard ($ package )
30+ {
31+ return $ this ->installed ($ package );
32+ }
33+
34+ protected function installed ($ package )
1635 {
1736 $ installed = Composer::isInstalled ($ package );
1837
Original file line number Diff line number Diff line change @@ -34,4 +34,18 @@ public function it_can_check_if_package_is_installed_using_tag_pair()
3434 $ this ->assertEquals ('yes ' , $ this ->tag ('{{ installed:hasselhoff/baywatch-embeds }}yes{{ /installed:hasselhoff/baywatch-embeds }} ' ));
3535 $ this ->assertEquals ('' , $ this ->tag ('{{ installed:hasselhoff/lotr-embeds }}yes{{ /installed:hasselhoff/lotr-embeds }} ' ));
3636 }
37+
38+ #[Test]
39+ public function it_can_check_if_package_is_installed_using_param ()
40+ {
41+ $ this ->assertEquals ('yes ' , $ this ->tag ('{{ installed package="hasselhoff/baywatch-embeds" }}yes{{ /installed }} ' ));
42+ $ this ->assertEquals ('' , $ this ->tag ('{{ installed package="hasselhoff/lotr-embeds" }}yes{{ /installed }} ' ));
43+ }
44+
45+ #[Test]
46+ public function it_outputs_empty_when_passing_nothing ()
47+ {
48+ $ this ->assertEquals ('' , $ this ->tag ('{{ installed package="" }}yes{{ /installed }} ' ));
49+ $ this ->assertEquals ('' , $ this ->tag ('{{ installed :package="null" }}yes{{ /installed }} ' ));
50+ }
3751}
You can’t perform that action at this time.
0 commit comments