Example #1
0
 /**
  * Verify test create database works.
  */
 public function testCreateSourceContainer()
 {
     if (!empty(xPDOTestHarness::$debug)) {
         print "\n" . __METHOD__ . " = ";
     }
     $xpdo = xPDOTestHarness::getInstance(true);
     $created = $xpdo->getManager()->createSourceContainer();
     $this->assertTrue($created == true, "Could not create database.");
 }
Example #2
0
 public static function tearDownAfterClass()
 {
     $xpdo = xPDOTestHarness::getInstance();
     $paths = array(xPDOTestHarness::$properties['xpdo_test_path'] . "fs/zip/");
     foreach ($paths as $path) {
         $xpdo->getCacheManager()->deleteTree($path, array('deleteTop' => true, 'skipDirs' => false, 'extensions' => array()));
     }
     $files = array(xPDOTestHarness::$properties['xpdo_test_path'] . "fs/test-1.zip", xPDOTestHarness::$properties['xpdo_test_path'] . "fs/test-2.zip", xPDOTestHarness::$properties['xpdo_test_path'] . "fs/test-3.zip");
     foreach ($files as $file) {
         if (is_file($file)) {
             unlink($file);
         }
     }
 }
Example #3
0
 /**
  * Verify drop database works.
  */
 public function testRemoveSourceContainer()
 {
     if (!empty(xPDOTestHarness::$debug)) {
         print "\n" . __METHOD__ . " = ";
     }
     $xpdo = xPDOTestHarness::getInstance(true);
     $success = false;
     if ($xpdo) {
         $driver = xPDOTestHarness::$properties['xpdo_driver'];
         $dsn = xPDOTestHarness::$properties[$driver . '_string_dsn_test'];
         $dsn = xPDO::parseDSN($dsn);
         $success = $xpdo->getManager()->removeSourceContainer($dsn);
     }
     $this->assertTrue($success, "Test container exists and could not be removed for initialization via xPDOManager->removeSourceContainer()");
 }
Example #4
0
 protected function setUp()
 {
     $this->xpdo = xPDOTestHarness::getInstance();
 }
 /**
  * Grab a persistent instance of the xPDO class to share sample model data
  * across multiple tests and test suites.
  * 
  * @param boolean $new Indicate if a new singleton should be created
  * @return xPDO An xPDO object instance.
  */
 public static function getInstance($new = false)
 {
     if ($new || !is_object(xPDOTestHarness::$xpdo)) {
         $driver = xPDOTestHarness::$properties['xpdo_driver'];
         $xpdo = new xPDO(xPDOTestHarness::$properties["{$driver}_string_dsn_test"], xPDOTestHarness::$properties["{$driver}_string_username"], xPDOTestHarness::$properties["{$driver}_string_password"], xPDOTestHarness::$properties["{$driver}_array_options"], xPDOTestHarness::$properties["{$driver}_array_driverOptions"]);
         if (is_object($xpdo)) {
             $logLevel = array_key_exists('logLevel', xPDOTestHarness::$properties) ? xPDOTestHarness::$properties['logLevel'] : xPDO::LOG_LEVEL_WARN;
             $logTarget = array_key_exists('logTarget', xPDOTestHarness::$properties) ? xPDOTestHarness::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
             $xpdo->setLogLevel($logLevel);
             $xpdo->setLogTarget($logTarget);
             if (!empty(xPDOTestHarness::$debug)) {
                 $xpdo->setDebug(xPDOTestHarness::$properties['debug']);
             }
             $xpdo->setPackage('sample', xPDOTestHarness::$properties['xpdo_test_path'] . '/model/');
             xPDOTestHarness::$xpdo = $xpdo;
         }
     }
     return xPDOTestHarness::$xpdo;
 }