Skip to content

Commit

Permalink
docs(docs) cleanup 2
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Aug 26, 2023
1 parent c0d28d5 commit 5a4a69f
Show file tree
Hide file tree
Showing 34 changed files with 1,798 additions and 3,645 deletions.
74 changes: 19 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can use wp-browser to test WordPress sites, plugins and themes.

## Installation

Add wp-browser to your project as a development dependency using [Composer](https://getcomposer.org/):
Add wp-browser to your project as a development dependency using [Composer][1]

```bash
cd my-wordrpess-project
Expand All @@ -19,18 +19,13 @@ Initialize wp-browser to quickly configured to suite your project and setup:
vendor/bin/codecept init wpbrowser
```

The command walks you through a series of questions to configure wp-browser for your project by either following a
default configuration or by asking you to provide the information needed to configure it.
The command will set up your project to run integration and end-to-end tests using:

### Configuration
* SQLite as the database engine, leveragin the [SQLite Database Integration plugin][2]
* PHP built-in web server to serve the WordPress site on localhost (e.g. `http://localhost:8080`)
* Chromedriver to dirve the local version of Chrome installed on your machine

The default configuration will get you started in little time using:

* MySQL as the database engine, using [Docker][1] to run the database server
* PHP built-in web server to serve the WordPress site
* Chromedriver installed using [the `webdriver-binary/binary-chromedriver`][2] Composer package

If you're working on a plugin or theme project, he default configuration will add some extra steps:
If you're working on a plugin or theme project, the default configuration will add some extra steps:

* install the latest version of WordPress in the `tests/_wordpress` directory
* create a `tests/_plugins` directory: any file or directory in this directory will be symlinked into the WordPress
Expand All @@ -39,71 +34,40 @@ If you're working on a plugin or theme project, he default configuration will ad
installation in `tests/_wordpress/wp-content/themes`

For most projects this configuration will be enough to get started with testing.
The default configuration will start all the required services before running the tests; you can start and stop the
running services with the following commands:

```bash
vendor/bin/codecept dev:start
vendor/bin/codecept dev:stop
````
You can run your tests immediately using the `vendor/bin/codecept run` command.

[Read more about the commands provided by the library here.](docs/commands.md)

### Using a custom configuration

If you decide to skip the default configuration, you will be able to set up `wp-browser` to suit your needs and local
setup by editing the `tests/.env` file.
The inline documentation in the file will guide you through the configuration process.

### Running tests

The configuration will set up two test suites:

* `integration` to run your project code in the context of WordPress. This suite works like the one used
by [WordPress Core][6] to run [PHPUnit][3] tests. Integration tests are often referred to as "unit tests" in the
WordPress ecosystem. These are usually low-level and fast tests.
* `end2end` to run tests that interact with the WordPress site using a browser. The default configuration will "drive"
Chrome using ChromeDriver. These tests are high-level and slower than integration tests.

You can run all the tests using this command:

```bash
vendor/bin/codecept run
```

> Note: the project replaces Codeception `run` command with one that will run each suite in a separate process. You can
> invoke the original Codeception command using the `codeception:run` command.

You can run a single test suite using this command:

```bash
vendor/bin/codecept run integration
vendor/bin/codecept run end2end
```

There are more commands available to run tests, you can find them in the [Codeception documentation][4].
[Read more about using a custom configuration here.](docs/custom-configuration.md)

## Getting support for wp-browser configuration and usage

The best place to get support for wp-browser is [the project documentation][7].
The best place to get support for wp-browser is [the project documentation](docs/README.md).
Since this project builds on top of [PHPUnit][3] and [Codeception][4], you can also refer to their documentation.

If you can't find the answer to your question here you can ask on
the ["Issues" section of the wp-browser repository][5].
the ["Issues" section of the wp-browser repository][5] taking care to provide as much information as possible.

Finally, you can [contact me directly][7] to set up a call to discuss your project needs and how wp-browser can help
you.
Finally, you can <a href="mailto:luca@theaveragedev.com">contact me directly</a> to set up a call to discuss your
project needs and how wp-browser can help you.

## Sponsors

A thanks to my sponsors: you make maintaining this project easier.

[1]: https://www.docker.com/
[1]: https://getcomposer.org/

[2]: https://packagist.org/packages/webdriver-binary/binary-chromedriver
[2]: https://wordpress.org/plugins/sqlite-database-integration/

[3]: https://phpunit.de/

[4]: https://codeception.com/

[5]: https://github.com/lucatume/wp-browser/issues
[6]: https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/
[7]: /docs/README.md
[5]: https://github.com/lucatume/wp-browser/issues/new/choose
48 changes: 48 additions & 0 deletions bin/extract-api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$class = $argv[1];

if (!class_exists($class)) {
throw new \InvalidArgumentException("Class $class does not exist.");
}

$classReflection = new ReflectionClass($class);
$classMethods = $classReflection->getMethods(ReflectionMethod::IS_PUBLIC);
$apiClassMethods = array_filter($classMethods, function (ReflectionMethod $m): bool {
return !str_starts_with($m->getName(), '_');
});
usort(
$apiClassMethods,
fn(ReflectionMethod $a, ReflectionMethod $b) => $a->getName() <=> $b->getName()
);

// From each ReflectionMethod create a string in the format `method_name( ...parameters) : return_type - description`
// and add it to the array of methods.
$methods = array_map(function (ReflectionMethod $m): string {
$parameters = $m->getParameters();
$parametersString = implode(
', ',
array_map(
fn(ReflectionParameter $p): string => sprintf(
'%s%s%s%s$%s',
$p->isPassedByReference() ? '&' : '',
$p->hasType() ? $p->getType() . ' ' : '',
$p->isVariadic() ? '...' : '',
$p->isOptional() ? '[' : '',
$p->getName() . ($p->isOptional() ? ']' : '')
),
$parameters
)
);
$returnType = $m->hasReturnType() ? (string)$m->getReturnType() : 'void';
return sprintf(
'* `%s(%s)` : `%s`',
$m->getName(),
$parametersString,
$returnType
);
}, $apiClassMethods);

array_map(fn(string $m) => print($m . PHP_EOL), $methods);
105 changes: 87 additions & 18 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,93 @@
# wp-browser documentation
# wp-browser documentaion

Check warning on line 1 in docs/README.md

View workflow job for this annotation

GitHub Actions / 文A Typos check

"documentaion" should be "documentation".

You can use wp-browser to test WordPress sites, plugins and themes.

## Installation

Add wp-browser to your project as a development dependency using [Composer][1]

```bash
cd my-wordrpess-project
composer require --dev lucatume/wp-browser
```

Initialize wp-browser to quickly configured to suite your project and setup:

```bash
vendor/bin/codecept init wpbrowser
```

The command will set up your project to run integration and end-to-end tests using:

* SQLite as the database engine, leveragin the [SQLite Database Integration plugin][2]
* PHP built-in web server to serve the WordPress site on localhost (e.g. `http://localhost:8080`)
* Chromedriver to dirve the local version of Chrome installed on your machine

If you're working on a plugin or theme project, the default configuration will add some extra steps:

* install the latest version of WordPress in the `tests/_wordpress` directory
* create a `tests/_plugins` directory: any file or directory in this directory will be symlinked into the WordPress
installation in `tests/_wordpress/wp-content/plugins`
* create a `tests/_themes` directory: any file or directory in this directory will be symlinked into the WordPress
installation in `tests/_wordpress/wp-content/themes`

For most projects this configuration will be enough to get started with testing.

You can run your tests immediately using the `vendor/bin/codecept run` command.

[Read more about the commands provided by the library here.](commands.md)

### Using a custom configuration

If you decide to skip the default configuration, you will be able to set up `wp-browser` to suit your needs and local
setup by editing the `tests/.env` file.
The inline documentation in the file will guide you through the configuration process.

[Read more about using a custom configuration here.](custom-configuration.md)

## Getting support for wp-browser configuration and usage

The best place to get support for wp-browser is this documentation.
Since this project builds on top of [PHPUnit][3] and [Codeception][4], you can also refer to their documentation.

If you can't find the answer to your question here you can ask on
the ["Issues" section of the wp-browser repository][5] taking care to provide as much information as possible.

Finally, you can <a href="mailto:luca@theaveragedev.com">contact me directly</a> to set up a call to discuss your
project needs and how wp-browser can help you.

Table of contents:

* [Getting started](./getting-started.md)
* [Getting support](./getting-started.md#getting-support-for-wp-browser-configuration-and-usage)
* [The default configuration](./default-configuration.md)
* [The default configuration](default-configuration.md)
* [Using a custom configuration](custom-configuration.md)
* Modules
* [WPLoader](./modules/WPLoader.md)
* [WPDb](./modules/WPDb.md)
* [WPFilesystem](./modules/WPFilesystem.md)
* [WPBrowser](./modules/WPBrowser.md)
* [WPCLI](./modules/WPCLI.md)
* [WPWebDriver](./modules/WPWebDriver.md)
* [WPBrowser](modules/WPBrowser.md)
* [WPCLI](modules/WPCLI.md)
* [WPDb](modules/WPDb.md)
* [WPFilesystem](modules/WPFilesystem.md)
* [WPLoader](modules/WPLoader.md)
* [WPQueries](modules/WPQueries.md)
* [WPWebDriver](modules/WPWebDriver.md)
* Extensions
* [BuiltInServerController](./extensions.md#builtinservercontroller)
* [ChromeDriverController](./extensions.md#chromedrivercontroller)
* [DockerComposeController](./extensions.md#dockercomposecontroller)
* [BuiltInServerController](extensions.md#builtinservercontroller)
* [ChromeDriverController](extensions.md#chromedrivercontroller)
* [DockerComposeController](extensions.md#dockercomposecontroller)
* Commands
* [`run` and `codeception:run`](./commands.md#run-and-codeceptionrun)
* [`wp:dev-start`](./commands.md#wpdev-start)
* [`wp:dev-stop`](./commands.md#wpdev-stop)
* [`wp:cli`](./commands.md#wpcli)
* [`generate:wpunit`](./commands.md#generatewpunit)
* [`run` and `codeception:run`](commands.md#run-and-codeceptionrun)
* [`dev:start`](commands.md#devstart)
* [`dev:stop`](commands.md#wpdevstop)
* [`dev:restart`](commands.md#devrestart)
* [`wp:db:import`](commands.md#wpdbimport)
* [`wp:db:export`](commands.md#wpdbexport)
* [`chromedriver:update`](commands.md#chromedriverupdate)
* [`generate:wpunit`](commands.md#generatewpunit)

[1]: https://getcomposer.org/

[2]: https://wordpress.org/plugins/sqlite-database-integration/

[3]: https://phpunit.de/

[4]: https://codeception.com/

[5]: https://github.com/lucatume/wp-browser/issues/new/choose
38 changes: 0 additions & 38 deletions docs/SUMMARY.md

This file was deleted.

54 changes: 0 additions & 54 deletions docs/bin/update_doc.php

This file was deleted.

Loading

0 comments on commit 5a4a69f

Please sign in to comment.