File tree Expand file tree Collapse file tree 6 files changed +115
-4
lines changed
Expand file tree Collapse file tree 6 files changed +115
-4
lines changed Original file line number Diff line number Diff line change 2222 <listeners >
2323 <listener class =" Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
2424 </listeners >
25+ <coverage >
26+ <include >
27+ <directory suffix =" .php" >src</directory >
28+ </include >
29+ </coverage >
2530</phpunit >
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ public function resolve(Registry $registry): array
2424 $ unresolved = [];
2525
2626 $ concernedComponents = [];
27- foreach ($ registry ->all () as $ item ) {
28- if ($ item -> type !== RegistryItemType::Component ) {
27+ foreach ($ registry ->all () as $ item ) {
28+ if (RegistryItemType::Component !== $ item -> type ) {
2929 continue ;
3030 }
3131
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public static function fromTwigFile(SplFileInfo $file): self
8383 if ($ name === $ parentName ) {
8484 $ parentName = null ;
8585 }
86- // @todo: we should improve the way to detect examples
86+ // @todo: we should improve the way we detect examples
8787 $ isExample = preg_match ('#examples# ' , $ file ->getRelativePathname ());
8888 $ type = $ isExample ? RegistryItemType::Example : RegistryItemType::Component;
8989 $ theme = '' ;
Original file line number Diff line number Diff line change 1111
1212namespace Symfony \UX \Toolkit \Tests \Command ;
1313
14- use PHPUnit \Framework \TestCase ;
1514use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
1615use Zenstruck \Console \Test \InteractsWithConsole ;
1716
1817/**
1918 * @author Jean-François Lépine
19+ *
2020 * @group wip
2121 */
2222class UxToolkitInstallCommandTest extends KernelTestCase
@@ -43,4 +43,32 @@ public function testShouldAbleToCreateTheBadgeComponent(): void
4343 $ actualContent = file_get_contents ($ expectedFile );
4444 $ this ->assertEquals ($ expectedContent , $ actualContent );
4545 }
46+
47+ public function testShouldFailWhenComponentDoesNotExist (): void
48+ {
49+ $ destination = sys_get_temp_dir ().\DIRECTORY_SEPARATOR .uniqid ();
50+ mkdir ($ destination );
51+
52+ $ this ->bootKernel ();
53+ $ this ->consoleCommand ('ux:toolkit:install unknown --destination= ' .$ destination )
54+ ->execute ()
55+ ->assertFaulty ()
56+ ->assertOutputContains ('The component "Unknown" does not exist. ' );
57+ }
58+
59+ public function testShouldFailWhenComponentFileAlreadyExistsInNonInteractiveMode (): void
60+ {
61+ $ destination = sys_get_temp_dir ().\DIRECTORY_SEPARATOR .uniqid ();
62+ mkdir ($ destination );
63+
64+ $ this ->bootKernel ();
65+ $ this ->consoleCommand ('ux:toolkit:install badge --destination= ' .$ destination )
66+ ->execute ()
67+ ->assertSuccessful ();
68+
69+ $ this ->consoleCommand ('ux:toolkit:install badge --destination= ' .$ destination )
70+ ->execute ()
71+ ->assertFaulty ()
72+ ->assertOutputContains ('The component "Badge" already exists. ' );
73+ }
4674}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <[email protected] > 7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \UX \Toolkit \Tests \DependencyInjection ;
13+
14+ use PHPUnit \Framework \TestCase ;
15+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
16+ use Symfony \UX \Toolkit \DependencyInjection \ToolkitExtension ;
17+
18+ /**
19+ * @author Jean-François Lépine
20+ */
21+ class ToolkitExtensionTest extends TestCase
22+ {
23+ public function testGetAlias (): void
24+ {
25+ $ extension = new ToolkitExtension ();
26+ $ this ->assertEquals ('ux_toolkit ' , $ extension ->getAlias ());
27+ }
28+
29+ public function testLoadInjectUsefulParameters (): void
30+ {
31+ $ configs = [
32+ 'prefix ' => 'Acme ' ,
33+ 'theme ' => 'default ' ,
34+ ];
35+
36+ $ container = new ContainerBuilder ();
37+ $ extension = new ToolkitExtension ();
38+ $ extension ->load ([$ configs ], $ container );
39+
40+ $ this ->assertTrue ($ container ->hasParameter ('ux_toolkit.prefix ' ));
41+ $ this ->assertEquals ('Acme ' , $ container ->getParameter ('ux_toolkit.prefix ' ));
42+
43+ $ this ->assertTrue ($ container ->hasParameter ('ux_toolkit.theme ' ));
44+ $ this ->assertEquals ('default ' , $ container ->getParameter ('ux_toolkit.theme ' ));
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <[email protected] > 7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \UX \Toolkit \Tests ;
13+
14+ use PHPUnit \Framework \TestCase ;
15+ use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
16+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
17+ use Symfony \UX \Toolkit \DependencyInjection \ToolkitExtension ;
18+ use Symfony \UX \Toolkit \UxToolkitBundle ;
19+
20+ /**
21+ * @author Jean-François Lépine
22+ */
23+ class UxToolkitBundleTest extends KernelTestCase
24+ {
25+ public function testBundleBuildsSuccessfully (): void
26+ {
27+ self ::bootKernel ();
28+ $ container = self ::$ kernel ->getContainer ();
29+
30+ $ this ->assertInstanceOf (UxToolkitBundle::class, $ container ->get ('kernel ' )->getBundles ()['UxToolkitBundle ' ]);
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments