Using PHPUnit
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
Paths on Windows and OSX
Any reference to the file system path to web resources in the development environment would be Windows paths on the web server, but if unit testing locally on a Mac, the path will be different, e.g. /Volumes/shared_dir/path/to/project/
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