Exemplo n.º 1
0
 /**
  * Tests creating the table.
  *
  * @covers empire\framework\mvc\model\DbStorageModel::create
  */
 public function testCreate()
 {
     $this->instance->create();
     $this->assertTrue(self::$db->tableExists('mod_mock_testdbstorage'));
     $tables = self::$db->getFieldNames('mod_mock_testdbstorage');
     $this->assertContains('name', $tables);
     $this->assertContains('length', $tables);
 }
Exemplo n.º 2
0
 /**
  * Creates the table.
  */
 private function createTable()
 {
     $table = new Table($this->table);
     $table->addField(new Field('role', new Type(Field::TYPE_VARCHAR, 255), '', false, false));
     $table->addField(new Field('page', new Type(Field::TYPE_VARCHAR, 255), '', false, false));
     $table->addField(new Field('task', new Type(Field::TYPE_VARCHAR, 255), '', false, false));
     $table->setPrimaryKey(new PrimaryKey($this->table, array('role', 'page', 'task')));
     $this->db->createTable($table);
 }
Exemplo n.º 3
0
 /**
  * Creates the table.
  *
  * @param string $name the table name
  */
 private function createTable($name)
 {
     $table = new Table($name);
     $table->addField(new Field('idx', Field::TYPE_INT, '', false, true));
     $table->addField(new Field('id', new Type(Field::TYPE_VARCHAR, 32), '', false, false));
     $table->addField(new Field('role', Field::TYPE_TEXT, '', false, false));
     $table->setPrimaryKey(new PrimaryKey($name, array('idx')));
     $this->db->createTable($table);
 }
Exemplo n.º 4
0
 private function getEntireSize()
 {
     if ($this->db->tableExists($this->tableName)) {
         $query = 'SELECT count(id) AS numberOfEntries FROM :::table';
         $bindings = array(':::table' => $this->tableName);
         $res = $this->db->fetch($query, $bindings);
         return (int) $res[0]['numberOfEntries'];
     }
     return 0;
 }
Exemplo n.º 5
0
 /**
  * Creates the table.
  *
  * @param string $name the table name
  */
 private function createTable()
 {
     $name = $this->table;
     $table = new Table($name, '');
     $table->addField(new Field('idx', new Type(Field::TYPE_VARCHAR, 255), '', false, false));
     $table->addField(new Field('data', new Type(Field::TYPE_BLOB), '', false, false));
     if ($this->useTimestamps) {
         $table->addField(new Field('ts', new Type(Field::TYPE_INT, 10), '', false, false));
     }
     $table->setPrimaryKey(new PrimaryKey($name, array('idx')));
     $this->db->createTable($table);
 }
Exemplo n.º 6
0
 /**
  * Tests removing the storage.
  *
  * @covers empire\framework\authorization\rolebased\DbRoleStorage::remove
  */
 public function testRemove()
 {
     $this->instance->addRole('peterchen', 'editor');
     $this->instance->addRole('fritzchen', 'editor');
     $this->instance->addRole('fritzchen', 'admin');
     $this->instance->addRole('fritzchen', 'reader');
     $this->instance->addRole('hänschen', 'reader');
     $this->instance->remove();
     $this->assertEmpty($this->instance->getRoles('fritzchen'));
     $this->assertEmpty($this->instance->getRoles('peterchen'));
     $this->assertEmpty($this->instance->getRoles('hänschen'));
     $this->assertFalse($this->db->tableExists(self::TABLE));
 }
Exemplo n.º 7
0
 /**
  * Creates the table.
  *
  * @param string $name the table name
  */
 private function createTable($name)
 {
     $table = new Table($name);
     $table->addField(new Field('id', new Type(Field::TYPE_VARCHAR, 32), '', false, false));
     $table->addField(new Field('username', new Type(Field::TYPE_VARCHAR, 255), null, true, false));
     $table->addField(new Field('fullName', Field::TYPE_TEXT, null, true, false));
     $table->addField(new Field('email', new Type(Field::TYPE_VARCHAR, 255), null, true, false));
     $table->addField(new Field('birthdate', Field::TYPE_DATE, null, true, false));
     $table->addField(new Field('gender', new Type(Field::TYPE_VARCHAR, 255), '', true, false));
     $table->addField(new Field('timezoneOffset', new Type(Field::TYPE_SMALLINT, 4), 0, false, false));
     $table->addField(new Field('locale', new Type(Field::TYPE_VARCHAR, 10), 'en-US', false, false));
     $table->addField(new Field('lastLogin', new Type(Field::TYPE_INT, 12), -1, false, false));
     $table->addField(new Field('secret', Field::TYPE_TEXT, '', false, false));
     $table->setPrimaryKey(new PrimaryKey($name, array('id')));
     $table->addIndex(new Index('username', $name, true, array('username')));
     $table->addIndex(new Index('email', $name, true, array('email')));
     $this->db->createTable($table);
 }
Exemplo n.º 8
0
 public function tearDown()
 {
     if ($this->db->databaseExists(self::DB_ID)) {
         $this->db->dropDatabase(self::DB_ID);
     }
 }
Exemplo n.º 9
0
 /**
  * Tests whether a DB object can be constructed from a DSN string using the connection objects
  * provided by the <code>setUpBeforeClass()</code> method.
  *
  * @covers empire\framework\db\DB::constructFromDSN
  */
 public function testConstructFromDSN()
 {
     foreach (self::$connections as $connection) {
         $dsn = $connection->getDSN();
         $db = DB::constructFromDSN($dsn);
         $this->assertInstanceOf('empire\\framework\\db\\DB', $db);
     }
 }