@@ -58,7 +58,45 @@ protected function tearDown(): void
5858 *
5959 * @requires PHP >= 7.2
6060 */
61- public function testCommandUpdatesRecipe ()
61+ public function testCommandUpdatesRecipe (): void
62+ {
63+ $ this ->prepareRecipeUpdateFixture ();
64+
65+ $ command = $ this ->createCommandUpdateRecipes ();
66+ $ command ->execute (['package ' => 'symfony/console ' ]);
67+
68+ $ this ->assertSame (0 , $ command ->getStatusCode ());
69+ $ this ->assertStringContainsString ('Recipe updated ' , $ this ->io ->getOutput ());
70+ // assert bin/console has changed
71+ $ this ->assertStringNotContainsString ('vendor/autoload.php ' , file_get_contents (FLEX_TEST_DIR .'/bin/console ' ));
72+ // assert the recipe was updated
73+ $ this ->assertStringNotContainsString ('c6d02bdfba9da13c22157520e32a602dbee8a75c ' , file_get_contents (FLEX_TEST_DIR .'/symfony.lock ' ));
74+ }
75+
76+ /**
77+ * @requires PHP >= 7.2
78+ */
79+ public function testCommandUpdatesRecipeWithNoChangelog (): void
80+ {
81+ $ this ->prepareRecipeUpdateFixture ();
82+
83+ $ command = $ this ->createCommandUpdateRecipes ();
84+ $ command ->execute ([
85+ 'package ' => 'symfony/console ' ,
86+ '--no-changelog ' => true ,
87+ ]);
88+
89+ $ this ->assertSame (0 , $ command ->getStatusCode ());
90+ $ this ->assertStringContainsString ('Recipe updated ' , $ this ->io ->getOutput ());
91+ $ this ->assertStringNotContainsString ('Calculating CHANGELOG ' , $ this ->io ->getOutput ());
92+ $ this ->assertStringNotContainsString ('No CHANGELOG could be calculated. ' , $ this ->io ->getOutput ());
93+ // assert bin/console has changed
94+ $ this ->assertStringNotContainsString ('vendor/autoload.php ' , file_get_contents (FLEX_TEST_DIR .'/bin/console ' ));
95+ // assert the recipe was updated
96+ $ this ->assertStringNotContainsString ('c6d02bdfba9da13c22157520e32a602dbee8a75c ' , file_get_contents (FLEX_TEST_DIR .'/symfony.lock ' ));
97+ }
98+
99+ private function prepareRecipeUpdateFixture (): void
62100 {
63101 @mkdir (FLEX_TEST_DIR );
64102 (new Process (['git ' , 'init ' ], FLEX_TEST_DIR ))->mustRun ();
@@ -76,16 +114,6 @@ public function testCommandUpdatesRecipe()
76114 (new Process (['git ' , 'commit ' , '-m ' , 'setup of original console files ' ], FLEX_TEST_DIR ))->mustRun ();
77115
78116 (new Process ([__DIR__ .'/../../vendor/bin/composer ' , 'install ' ], FLEX_TEST_DIR ))->mustRun ();
79-
80- $ command = $ this ->createCommandUpdateRecipes ();
81- $ command ->execute (['package ' => 'symfony/console ' ]);
82-
83- $ this ->assertSame (0 , $ command ->getStatusCode ());
84- $ this ->assertStringContainsString ('Recipe updated ' , $ this ->io ->getOutput ());
85- // assert bin/console has changed
86- $ this ->assertStringNotContainsString ('vendor/autoload.php ' , file_get_contents (FLEX_TEST_DIR .'/bin/console ' ));
87- // assert the recipe was updated
88- $ this ->assertStringNotContainsString ('c6d02bdfba9da13c22157520e32a602dbee8a75c ' , file_get_contents (FLEX_TEST_DIR .'/symfony.lock ' ));
89117 }
90118
91119 private function createCommandUpdateRecipes (): CommandTester
0 commit comments