示例#1
0
 /**
  * Get storage
  *
  * @return Storage
  */
 public function getStorage()
 {
     if (!$this->storage instanceof Storage) {
         $this->storage = Manager::getStorage($this->getConnectionName());
     }
     return $this->storage;
 }
示例#2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     Manager::setModelPath(dirname(__FILE__) . '/_testdata/');
     Manager::addDefaultConnectionConfig('sqlite', ':memory:', null, null, '127.0.0.1', null, array(PDO::ATTR_PERSISTENT => true));
     $dbPath = dirname(__FILE__) . '/_testdata/test.sqlite';
     touch($dbPath);
     Manager::addConnectionConfig('tick_connection', 'sqlite', $dbPath);
     $storage = Manager::getStorage();
     $storage->getConnection()->exec(file_get_contents(dirname(__FILE__) . '/_testdata/schema.sql'));
     $storage = Manager::getStorage("tick_connection");
     $storage->getConnection()->exec(file_get_contents(dirname(__FILE__) . '/_testdata/schema.sql'));
 }
示例#3
0
 /**
  * Test
  *
  * @test
  *
  * @return void
  */
 public function getConnection()
 {
     $this->assertTrue(Manager::getStorage() instanceof Storage);
     $this->assertTrue(Manager::getStorage() instanceof MongoStorage);
 }
示例#4
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     Manager::removeAllConnections();
 }
示例#5
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     Manager::setModelPath(dirname(__FILE__) . '/_testdata/');
     $this->expected = array("properties" => array("id" => array("field" => "user_id", "type" => "integer", 'default' => null, "size" => 11, "unique" => true), "name" => array("field" => "full_name", "type" => "string", "size" => 255, "null" => true, "default" => "Jane"), "username" => array("field" => "email", "type" => "string", "size" => 128, "default" => "Doe Doe"), "created" => array("field" => "created", "type" => "DateTime", 'default' => null), "updated" => array("field" => "updated", "type" => "DateTime", 'default' => null, "null" => true)), "fields" => array("user_id" => array('property' => 'id', "field" => "user_id", "type" => "integer", "size" => 11, "unique" => true, 'default' => null), "full_name" => array('property' => 'name', "field" => "full_name", "type" => "string", "size" => 255, "null" => true, "default" => "Jane"), "email" => array('property' => 'username', "field" => "email", "type" => "string", "size" => 128, "default" => "Doe Doe"), "created" => array('property' => 'created', "field" => "created", "type" => "DateTime", 'default' => null), "updated" => array('property' => 'updated', "field" => "updated", "type" => "DateTime", "null" => true, 'default' => null)));
 }
示例#6
0
 /**
  * Test
  *
  * @tests
  *
  * @return void
  */
 public function defaultIsNotAddedToGlobalBeforeStorageIsRequested()
 {
     Manager::addDefaultConnectionConfig('sqlite', ':memory:');
     $this->assertFalse(key_exists("TickConnection:default", $GLOBALS));
 }
 /**
  * The unigue name of connection in $GLOBALS
  *
  * @param string $name Connection name
  *
  * @return string unique name
  */
 public static function getUniqueName($name)
 {
     return parent::getUniqueName($name);
 }
示例#8
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     Manager::setModelPath(dirname(__FILE__) . '/_testdata/');
 }