@@ -21,6 +21,11 @@ class NewCommandTest extends Base {
2121 '--useremail ' =>
'[email protected] ' 2222 );
2323
24+ /**
25+ * @var array Extended configuration for tests
26+ */
27+ protected $ extends = array ();
28+
2429 /**
2530 * @before
2631 */
@@ -50,7 +55,8 @@ public function testDownload() {
5055
5156 $ this ->assertDirectoryExists (Base::INSTALLATION_FOLDER );
5257 $ this ->assertDirectoryExists (Base::INSTALLATION_FOLDER . '/wire ' );
53- $ this ->assertDirectoryNotExists (Base::INSTALLATION_FOLDER . '/site ' );
58+ $ this ->assertFileExists (Base::INSTALLATION_FOLDER . '/index.php ' );
59+ $ this ->assertFileExists (Base::INSTALLATION_FOLDER . '/install.php ' );
5460 }
5561
5662 public function testDownloadWithRelativeSrc () {
@@ -106,13 +112,14 @@ public function testDownloadWithMixedSlashesAndSpacesSrc() {
106112 }
107113
108114 /**
109- * @depends testDownload
110- * @expectedException RuntimeException
111- * @expectedExceptionMessageRegExp /(Database connection information did not work)./
112- */
115+ * @depends testDownload
116+ */
113117 public function testInstallWrongPassword () {
114118 // check ProcessWire has not been installed yet
115- if ($ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) return ;
119+ if ($ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) {
120+ $ this ->markTestSkipped ('ProcessWire is already installed ' );
121+ return ;
122+ }
116123
117124 // return the input you want to answer the question with
118125 $ this ->mockQuestionHelper ($ this ->command , function ($ text , $ order , Question $ question ) {
@@ -127,16 +134,20 @@ public function testInstallWrongPassword() {
127134 '--dbPass ' => 'wrong '
128135 );
129136
137+ $ this ->expectException (\RuntimeException::class);
138+ $ this ->expectExceptionMessageMatches ('/(Database connection information did not work)./ ' );
130139 $ this ->tester ->execute (array_merge ($ this ->defaults , $ options ));
131140 }
132141
133142 /**
134- * @depends testDownload
135- * @expectedExceptionMessageRegExp /(enter a valid email address)/
136- */
143+ * @depends testDownload
144+ */
137145 public function testInstallInvalidEmailAddress () {
138146 // check ProcessWire has not been installed yet
139- if ($ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) return ;
147+ if ($ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) {
148+ $ this ->markTestSkipped ('ProcessWire is already installed ' );
149+ return ;
150+ }
140151
141152 // return the input you want to answer the question with
142153 $ this ->mockQuestionHelper ($ this ->command , function ($ text , $ order , Question $ question ) {
@@ -150,6 +161,8 @@ public function testInstallInvalidEmailAddress() {
150161 '--useremail ' => 'invalid '
151162 );
152163
164+ $ this ->expectException (\RuntimeException::class);
165+ $ this ->expectExceptionMessageMatches ('/(enter a valid email address)/ ' );
153166 $ this ->tester ->execute (array_merge ($ this ->defaults , $ options ));
154167 }
155168
@@ -158,21 +171,30 @@ public function testInstallInvalidEmailAddress() {
158171 */
159172 public function testInstall () {
160173 // check ProcessWire has not been installed yet
161- if ($ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) return ;
174+ if ($ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) {
175+ $ this ->markTestSkipped ('ProcessWire is already installed ' );
176+ return ;
177+ }
162178
163179 $ this ->tester ->execute ($ this ->defaults );
164180 $ output = $ this ->tester ->getDisplay ();
165181
166182 $ this ->assertDirectoryExists (Base::INSTALLATION_FOLDER . '/site ' );
167183 $ this ->assertFileExists (Base::INSTALLATION_FOLDER . '/site/config.php ' );
168- $ this ->assertContains ('Congratulations, ProcessWire has been successfully installed. ' , $ output );
184+ $ this ->assertStringContainsString ('Congratulations, ProcessWire has been successfully installed. ' , $ output );
169185 }
170186
171187 /**
172188 * @depends testInstall
173- * @expectedExceptionMessageRegExp /(There is already a \')(.*)(\' project)/
174189 */
175190 public function testIsInstalled () {
191+ if (!$ this ->fs ->exists (Base::INSTALLATION_FOLDER . '/site/config.php ' )) {
192+ $ this ->markTestSkipped ('ProcessWire is not installed ' );
193+ return ;
194+ }
195+
196+ $ this ->expectException (\RuntimeException::class);
197+ $ this ->expectExceptionMessageMatches ('/(There is already a \')(.*)( \' project)/ ' );
176198 $ this ->tester ->execute ($ this ->defaults );
177199 }
178200}
0 commit comments