Most PartKeepr tests are actually functional tests. Because we do automated testing using Travis CI, you need to specify your test database prior executing phpunit:
# Specifies the database connection to use. Other choices are mysql and pgsql as specified in [https://github.com/partkeepr/PartKeepr/blob/sf2migration/app/config/config_test.yml config_test.yml] export SYMFONY__TESTDB=sqlite vendor/bin/phpunit -c app/
You can also specify a test file by appending it to the command line:
vendor/bin/phpunit -c app/ src/PartKeepr/UnitBundle/Tests/Model/UnitTest.php
Since the functional tests use quite some disk I/O, it is recommended that you place your files on a SSD for unit testing (8 seconds vs. several minutes).
Fatal error: Call to undefined method PHPUnit_TextUI_TestRunner::printVersionString()
This might happen if you are using a local PHPUnit installation. You should use the phpunit version installed in
Unable to find file "@PartKeeprFrontendBundle/Resources/public/js/"
Sometimes the cache messes up unit tests, as we are doing functional tests. You should regenerate the environment.
Writing unit tests
Whenever you write tests, your test class should extend
PartKeepr\CoreBundle\Tests\WebTestCase. Don't confuse it with
Liip\FunctionalTestBundle\Test\WebTestCase, which will lead to strange problems since it loads the wrong
Using the iri_converter
Since PartKeepr uses IRIs instead of simple numeric IDs, you should use the
iri_converter to convert your objects to IRIs and vice versa.
Inside your tests, you can use
$this->getContainer()->get("api.iri_converter") to retrieve the IRI converter.