cerebrate/tests
Luciano Righetti 3923064d07 chg: migrate mysql.sql initial schema to a phinx migration 2022-01-07 14:37:04 +01:00
..
Fixture new: add /api openapi spec view with redoc, add faker to fixtures, validate api responses with openapi spec, add /api/v1/ prefix to api routes 2022-01-07 13:45:52 +01:00
Helper new: add /api openapi spec view with redoc, add faker to fixtures, validate api responses with openapi spec, add /api/v1/ prefix to api routes 2022-01-07 13:45:52 +01:00
TestCase fix: test 2022-01-07 13:47:20 +01:00
README.md new: add /api openapi spec view with redoc, add faker to fixtures, validate api responses with openapi spec, add /api/v1/ prefix to api routes 2022-01-07 13:45:52 +01:00
bootstrap.php chg: migrate mysql.sql initial schema to a phinx migration 2022-01-07 14:37:04 +01:00

README.md

Testing

  1. Add a cerebrate_test database to the db:
CREATE DATABASE cerebrate_test;
GRANT ALL PRIVILEGES ON cerebrate_test.* to cerebrate@localhost;
FLUSH PRIVILEGES;
QUIT;
  1. Add a the test database to your config/app_local.php config file and set debug mode to true.
'debug' => true,
'Datasources' => [
    'default' => [
        ...
    ],
    /*
        * The test connection is used during the test suite.
        */
    'test' => [
        'host' => 'localhost',
        'username' => 'cerebrate',
        'password' => 'cerebrate',
        'database' => 'cerebrate_test',
    ],
],

Runing the tests

$ composer install
$ vendor/bin/phpunit
PHPUnit 8.5.22 by Sebastian Bergmann and contributors.

.....                                     5 / 5 (100%)

Time: 11.61 seconds, Memory: 26.00 MB

OK (5 tests, 15 assertions)

Running a specific suite:

$ vendor/bin/phpunit --testsuite=api

Available suites:

  • app: runs all test suites
  • api: runs only api tests
  • controller: runs only controller tests
  • to be continued ...

By default the database is re-generated before running the test suite, to skip this step and speed up the test run use the -d skip-migrations option:

$ vendor/bin/phpunit -d skip-migrations