Reputation: 358
I have set up the PHPunit Framework for testing and upon running a simple test I am getting a TypeError below:
SampleTest::testTrueAssertsToTrue
TypeError: Argument 3 passed to
SebastianBergmann\GlobalState\Snapshot::__construct() must be of the type boolean, null given, called in /usr/share/php/PHPUnit/Framework/TestCase.php on line 2412
My test case is below:
class SampleTest extends \PHPUnit_Framework_TestCase
{
public function testTrueAssertsToTrue()
{
$this->assertTrue(true);
}
}
The PHPunit version is ^6.2 and below is the configuration XML file:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
stopOnFailure="false">
<testsuites>
<testsuite name ="Test suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
Please help I have searched online whole day and I cant find a solution.
Upvotes: 2
Views: 3641
Reputation: 40841
Because you're using phpunit 6.2, \PHPUnit_Framework_TestCase
has been removed and you should be instead extending the namespaced PHPUnit\Framework\TestCase
<?php
use PHPUnit\Framework\TestCase;
class SampleTest extends TestCase
{
public function testTrueAssertsToTrue()
{
$this->assertTrue(true);
}
}
You can verify the successful build here on travis-ci:
https://travis-ci.org/scratchers/phpunit6truetest/builds/242989226
Upvotes: 3