I’m not very familiar with PHP and struggling with the PHPUnit setup for hours. This is the situation:
functions.php
– contains functions to be tested
<?
/**
* test function
*/
function simple($url){
return true
}
...
phpunit.xml
– phpunit configuration
<phpunit bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name='Functions tests'>
<directory prefix="" suffix=".test.php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
tests/functions.test.php
– contains the unit tests for the functions
<?php
use PHPUnitFrameworkTestCase;
class FunctionsTest extends TestCase {
public function test_simple(){
$this->assertEquals(simple(), true);
}
...
}
tests/bootstrap.php
– bootstrapping file for the unittests
The content of bootstrap.php
is
<?php
require_once(__DIR__ . '/../functions.php');
I then run php vendor/bin/phpunit
which has a weird output.
- The content of the
functions.php
file gets printed to the terminal - All tests fail with
Call to undefined function simple
When I copy the content of functions.php
in front of the functions.test.php
all tests pass, but this shouldn’t be the solution.