Skip to content

Commit edbe0cc

Browse files
committed
doc(README.md) add Requirements section, improve site failure messaging
1 parent 299c517 commit edbe0cc

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

docs/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
44
The wp-browser library provides a set of [Codeception][4] modules and middleware to enable the testing of WordPress sites, plugins and themes.
55

6+
## Requirements
7+
8+
Depending on the nature of your project, there are different requirements it will need to satisfy before getting started.
9+
10+
### Site
11+
12+
* Ensure you're running the `vendor/bin/codecept init wpbrowser` command from the root directory of your WordPress site.
13+
* Ensure the directory contains the WordPress installation files. In a standard scenario you should have extracted WordPress files in this directory.
14+
* Ensure your installation is configured: it should contain a `wp-config.php` file.
15+
16+
### Plugin
17+
18+
* Ensure you're running the `vendor/bin/codecept init wpbrowser` command from the root directory of your plugin; this should be the directory that contains the PHP file defining the [plugin header][6].
19+
20+
### Theme
21+
22+
* Ensure you're running the `vendor/bin/codecept init wpbrowser` command from the root directory of your theme; this should be the directory that contains the `style.css` file defining [the theme header][7].
23+
24+
If you decide to use the quick installation, then your PHP version should have the `sqlite3` extensions installed and activated. You can check this using the `php -m` command and verifying the `sqlite3` extension is among the active extensions.
25+
626
## Installation
727

828
Add wp-browser to your project as a development dependency using [Composer][1]
@@ -66,3 +86,7 @@ project needs and how wp-browser can help you.
6686
[4]: https://codeception.com/
6787

6888
[5]: https://github.com/lucatume/wp-browser/issues/new/choose
89+
90+
[6]: https://developer.wordpress.org/plugins/plugin-basics/header-requirements/
91+
92+
[7]: https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/

src/Project/SiteProject.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,30 @@ public function __construct(InputInterface $input, OutputInterface $output, prot
3838
try {
3939
$this->installation = Installation::findInDir($this->workDir, false);
4040
$installationState = $this->installation->getState();
41-
42-
if ($installationState instanceof EmptyDir) {
43-
throw new RuntimeException(
44-
'The WordPress installation directory is empty'
45-
);
46-
}
47-
48-
if ($installationState instanceof Scaffolded) {
49-
throw new RuntimeException(
50-
'The WordPress installation directory is scaffolded, but not configured.'
51-
);
52-
}
53-
54-
$this->testEnvironment = new TestEnvironment();
5541
} catch (Throwable $t) {
5642
throw new RuntimeException(
5743
'Failed to initialize the WordPress installation: ' . lcfirst($t->getMessage()),
5844
0,
5945
$t
6046
);
6147
}
48+
49+
$suggest = "Make sure you're initializing wp-browser at the root of your site project,".
50+
" and that the directory contains the WordPress files and a wp-config.php file.";
51+
52+
if ($installationState instanceof EmptyDir) {
53+
throw new RuntimeException(
54+
"The WordPress installation directory is empty.\n{$suggest}"
55+
);
56+
}
57+
58+
if ($installationState instanceof Scaffolded) {
59+
throw new RuntimeException(
60+
"The WordPress installation directory is scaffolded, but not configured.\n{$suggest}"
61+
);
62+
}
63+
64+
$this->testEnvironment = new TestEnvironment();
6265
}
6366

6467
public function getType(): string

tests/unit/lucatume/WPBrowser/Project/SiteProjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public function should_throw_if_trying_scaffold_on_site_that_is_empty(): void
4343
}
4444

4545
/**
46-
* It should throw if trying to scaffol on site that is not configured
46+
* It should throw if trying to scaffold on site that is not configured
4747
*
4848
* @test
4949
*/
50-
public function should_throw_if_trying_to_scaffol_on_site_that_is_not_configured(): void
50+
public function should_throw_if_trying_to_scaffold_on_site_that_is_not_configured(): void
5151
{
5252
$composerFileCode = <<< EOT
5353
{

0 commit comments

Comments
 (0)