assertEquals( 'localhost', $instance->getConfig()['host'] ); } public function testGetInstanceWithSERVERLocal(){ // Pour regenerer une instance, on definit une erreur \database\core\DatabaseDriver::$error = \error\core\Error::PDOConnection; $instance = \database\core\DatabaseDriver::get(); $this->assertEquals( 'localhost', $instance->getConfig()['host'] ); } /* [2] Verification du singleton (getInstance) =========================================================*/ public function testInstancePersistence(){ \database\core\DatabaseDriver::$error = \error\core\Error::PDOConnection; $instance_construct = \database\core\DatabaseDriver::get(); $instance_nextuse = \database\core\DatabaseDriver::get(); $this->assertSame( $instance_construct, $instance_nextuse ); } public function testInstancePersistenceRefutation(){ \database\core\DatabaseDriver::$error = \error\core\Error::PDOConnection; $instance_construct = \database\core\DatabaseDriver::get(); \database\core\DatabaseDriver::$error = \error\core\Error::PDOConnection; $instance_nextuse = \database\core\DatabaseDriver::get(); $this->assertNotSame( $instance_construct, $instance_nextuse ); } /* [3] Verification de l'objet PDO =========================================================*/ public function testPDO(){ $pdo = \database\core\DatabaseDriver::getPDO(); $this->assertGreaterThan( 10, count($pdo->query('SELECT * FROM user')->fetchAll()), '[!] Moins de 10 utilisateurs trouves.'); } } ?>