I've recently set up PHPUnit in PHPStorm via Composer.
I'm trying to test some functionality that requires me to bootstrap Processwire (a CMS).
I keep constantly getting the message "You cannot serialize or unserialize PDO instances" despite applying the conditions below which I researched to be the correct way of fixing this issue.
* @backupGlobals disabled
* @backupStaticAttributes disabled
* @runTestsInSeparateProcesses
* @runInSeparateProcess
* @preserveGlobalState disabled
Is there anything else I have missed or need to do to get this working?
These are the resources I have referenced so far.
https://phpunit.de/manual/current/en/phpunit-book.html#appendixes.annotations.preserveGlobalState
http://edmondscommerce.github.io/php/phpunit-and-pdoexception-solution.html
I've seen this article that flagged my article as a duplicate but I don't believe it to be the same : PDOException: You cannot serialize or unserialize PDO instances
The test in that article has direct references to the PDO object whereas I'm just trying to get my tests to run with a bootstrap reference to Processwire. This is my test I'm trying to run :
namespace Test;
include_once(__DIR__."/../../../../index.php"); //Bootstrap to Processwire CMS
class ImageTest extends \PHPUnit_Framework_TestCase {
/**
* @backupGlobals disabled
* @backupStaticAttributes disabled
* @runTestsInSeparateProcesses
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
protected function setUp()
{
//$this->testpages = wire(pages)->find("template=fingergames|template=songs|template=poems");
}
public function testImageEmptyLinks()
{
//$testpages = wire(pages)->find("template=fingergames|template=songs|template=poems");
$blanks = wire(pages)->find("image=''");
$this->assertEquals($blanks->count(),0);
}
public function testImageMismatchedLinks()
{
//$this->assertTrue(true);
$this->assertEquals(0,0);
}
public function testImageMissingSiblings()
{
$this->assertEquals(0,0);
}
protected function tearDown()
{
}
}