I follow the PHPUnit documentation ; I try the following example; but he continues to give me the following error:
"Fatal error: class 'PHPUnit_Extensions_Database_TestCase' not found!
It works great for PHPUnit_Framework_TestCase ! I also added
require_once 'PHPUnit/Autoload.php';
but still the same mistake!
<?php class MyGuestbookTest extends PHPUnit_Extensions_Database_TestCase { public function getConnection() { $pdo = new PDO('sqlite::memory:'); return $this->createDefaultDBConnection($pdo, ':memory:'); } public function getDataSet() { return $this->createFlatXMLDataSet(dirname(__FILE__).'/_files/guestbook-seed.xml'); } } ?>
Updated:
Actually, I am very new to testing PHPUnit:
I used Slim framework for PHP: I did not start testing; just trying to understand the logic by looking at the documentation; I have a composer.json file that looks like this: (now I added "phpunit / dbunit": "> = 1.2" to require / require-dev, but none of them solved the problem!):
{ "name": "slim/slim", "type": "library", "description": "Slim Framework, a PHP micro framework", "keywords": ["microframework","rest","router"], "homepage": "http://github.com/codeguy/Slim", "license": "MIT", "authors": [ { "name": "Josh Lockhart", "email": "info@joshlockhart.com", "homepage": "http://www.joshlockhart.com/" } ], "require": { "php": ">=5.3.0" } ,"require-dev": { "phpunit/dbunit": ">=1.2" }, "suggest": { "ext-mcrypt": "Required for HTTP cookie encryption" }, "autoload": { "psr-0": { "Slim": "." } } }
If you need more clarification, please let me know well in advance.
php phpunit
user3421904
source share