Using PHPUnit: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
== Testing URLs == | == Testing URLs == | ||
=== Selenium Server === | |||
==== Installation ==== | |||
Installation instructions can be found [https://phpunit.de/manual/current/en/selenium.html here] under "Installation". | |||
Make sure Composer is installed: <ref>[https://getcomposer.org/doc/00-intro.md Getting Started] - Comoser website</ref> | |||
<syntaxhighlight lang="bash"> | |||
$ composer -v | |||
/* or */ | |||
$ php composer.phar -V | |||
</syntaxhighlight> | |||
Add The PHPUnit Selenium dependency to `composer.json` in the project root directory: | |||
<syntaxhighlight lang="javascript"> | |||
{ | |||
"require-dev": | |||
{ | |||
phpunit/phpunit-selenium": ">=1.2" | |||
} | |||
} | |||
</syntaxhighlight> | |||
Then install with either | |||
<syntaxhighlight lang="bash"> | |||
$ php composer.phar install | |||
/* or */ | |||
$ php composer.phar update | |||
</syntaxhighlight> | |||
(To uninstall un-needed dependencies:) | |||
<syntaxhighlight lang="bash"> | |||
$ php composer.phar remove [LIBRARY_NAME]/[PACKAGE_NAME] --update-with-dependencies | |||
</syntaxhighlight> | |||
==== Running the test suite ==== | |||
<syntaxhighlight lang="bash"> | |||
$ java -har /usr/bin/local/selenium-server-standalone-2.x.x.jar | |||
</syntaxhighlight> | |||
== Installation/Configuration errors and fixes == | == Installation/Configuration errors and fixes == | ||
Revision as of 11:51, 16 September 2015
Testing URLs
Selenium Server
Installation
Installation instructions can be found here under "Installation".
Make sure Composer is installed: [1]
$ composer -v /* or */ $ php composer.phar -V
Add The PHPUnit Selenium dependency to composer.json in the project root directory:
{
"require-dev":
{
phpunit/phpunit-selenium": ">=1.2"
}
}
Then install with either
$ php composer.phar install /* or */ $ php composer.phar update
(To uninstall un-needed dependencies:)
$ php composer.phar remove [LIBRARY_NAME]/[PACKAGE_NAME] --update-with-dependencies
Running the test suite
$ java -har /usr/bin/local/selenium-server-standalone-2.x.x.jar
Installation/Configuration errors and fixes
mysqli no such file or directory
Run a unit test that makes a database connection and receive
mysqli::mysqli(): (HY000/2002): No such file or directory
First Google results suggested making sure that the mysql extension was compiled into PHP. I don't think this was the actual issue.
I installed PHP using homebrew, according to these instructions. This version of PHP comes with MySQL compiled into it, but I think that PHP that comes installed on the Mac most likely does also.
The issue ended up being that the MySQL connection was configured to use localhost as the host name. locahost for the PHP CLI resolves to something very different than when running on the development web server. [2]
Notes
See also
- Getting Started With PHPUnit - PHPUnit Documentation
Footnotes
- ↑ Getting Started - Comoser website
- ↑ Warning: mysql_connect() [function.mysql-connect]: No such file or directory - Devster Journey blog