victortb
(usa Ubuntu)
Enviado em 18/09/2009 - 16:23h
Caros,
Estou tendo problemas para instanciar um objeto da classe PDO.
Segue abaixo a linha de comando:
set_include_path('.:/usr/share/php:/var/www/programs/includes:/usr/share/php/PHPUnit:/home/tec/selenium-remote-control-1.0.1/selenium-php-client-driver-1.0.1/PEAR');
require_once 'PHPUnit/Util/PDO.php';
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'PHPUnit/Extensions/Database/TestCase.php';
require_once 'PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php';
require_once 'PHPUnit/Extensions/Database/Operation/DeleteAll.php';
require_once 'PHPUnit/Extensions/Database/Operation/Delete.php';
require_once '../../src/ImportAll.php';
class GeralTest extends PHPUnit_Extensions_Database_TestCase{
private $pdo;
private $empresaVO;
private $empresaBO;
protected function getSetUpOperation() {
return PHPUnit_Extensions_Database_Operation_Factory::INSERT();
}
protected function getTearDownOperation(){
return PHPUnit_Extensions_Database_Operation_Factory::NONE();
}
protected function getConnection() {
if ($this->pdo == null)
try {
$this->pdo = new PDO('NAME', 'SCHEMA', 'SENHA');
}catch (PDOException $e) {
print "Error!: " . $e->getMessage();
}
return $this->createDefaultDBConnection($this->pdo, 'SCHEMA');
}
protected function getDataSet() {
return $this->createFlatXMLDataSet( dirname ( __FILE__ ) . 'dataSet.xml' );
}
protected function setUp() {
parent::setUp();
$this->empresaBO = new GenericBusinessObject(false);
$this->empresaVO = new EmpresaVO();
}
protected function tearDown() {
$this->EmpresaVO = null ;
parent::tearDown() ;
}
public function testLoad() {
$this->empresaVO->setId(550);
$this->empresaVO = $this->EmpresaBO->findByPK($this->empresaVO);
$this->assertEquals(550, $this->empresaVO->getId());
}
}
Quando executo a classe o print do console é o seguinte:
PHPUnit 3.3.17 by Sebastian Bergmann.
Error!: could not find driverE
Time: 0 seconds
There was 1 error:
1) testLoad(GeralTest)
Argument 1 passed to PHPUnit_Extensions_Database_TestCase::createDefaultDBConnection() must be an instance of PDO, null given, called in /var/www/programas/unit/GeralTest.php on line 35 and defined
/var/www/programas/src-test/unit/VictorTest.php:35
/var/www/programas/src-test/unit/VictorTest.php:43
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
Alguem já passou por algo parecido para poder me ajudar?
Abraço!