Skip to content

Commit a1df607

Browse files
committed
fix(cli): robust path handling, modernize deps, fix deprecations
1 parent 2e88118 commit a1df607

File tree

8 files changed

+514
-555
lines changed

8 files changed

+514
-555
lines changed

.cursor/environment.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"terminals": []
3+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ ProcessWire
1515
Tests/processwire.zip
1616

1717
Tests/pw
18+
.cursorrules
19+
.phpunit.result.cache
20+
.phpunit.cache/test-results

.repomix/bundles.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"bundles": {}
3+
}

Tests/Commands/Common/NewCommandTest.php

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

composer.json

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,34 @@
3636
}
3737
},
3838
"require": {
39-
"php": ">=8.1.0",
40-
"guzzlehttp/guzzle": "~7.7",
41-
"monolog/monolog": "~3.4",
39+
"php": "^8.1",
40+
"guzzlehttp/guzzle": "^7.8",
41+
"monolog/monolog": "^3.5",
4242
"pmjones/auto-shell": "^1.0.1",
43-
"symfony/console": "^6.3",
44-
"symfony/filesystem": "^6.3",
45-
"symfony/process": "^6.3"
43+
"symfony/console": "^6.4",
44+
"symfony/filesystem": "^6.4",
45+
"symfony/process": "^6.4",
46+
"ext-pdo_mysql": "*",
47+
"ext-gd": "*",
48+
"ext-json": "*",
49+
"ext-iconv": "*",
50+
"ext-ctype": "*",
51+
"ext-zip": "*"
4652
},
4753
"require-dev": {
48-
"phpunit/phpunit": "^10.2",
49-
"whatthejeff/nyancat-phpunit-resultprinter": "~1.2"
54+
"phpunit/phpunit": "^10.5"
5055
},
51-
"extra": {
52-
"symfony": {
53-
"require": "5.2.*"
56+
"config": {
57+
"sort-packages": true,
58+
"platform": {
59+
"php": "8.1.0"
5460
}
5561
},
56-
"version": "1.4.12"
62+
"version": "1.4.12",
63+
"extra": {
64+
"processwire": {
65+
"min-version": "3.0.0",
66+
"max-version": "4.0.0"
67+
}
68+
}
5769
}

0 commit comments

Comments
 (0)