Example #1
0
 /**
  * @dataProvider provideGetTableClassWithoutAutoload
  * @param string $tableBaseClass
  * @param string $recordBaseClass
  * @param string $recordClass
  * @param string $expectedRecordClass
  * @param string $expectedTableClass
  */
 public function testGetTableClassWithoutAutoload($tableBaseClass, $recordBaseClass, $recordClass, $expectedRecordClass, $expectedTableClass)
 {
     $this->schema->setRecordClass('user', null);
     if ($tableBaseClass) {
         $this->schema->setTableBaseClass($tableBaseClass);
     }
     if ($recordBaseClass) {
         $this->schema->setRecordBaseClass($recordBaseClass);
     }
     if ($recordClass) {
         $this->schema->setRecordClass('user', $recordClass);
     }
     $recordClass = $this->schema->getRecordClass('user');
     $this->assertEquals($expectedRecordClass, $recordClass);
     $tableClass = $this->schema->getTableClass('user', false);
     $this->assertEquals($expectedTableClass, $tableClass);
 }
Example #2
0
 /**
  * @param string $viewName
  * @return \Dive\Table
  * @throws SchemaException
  */
 private function createView($viewName)
 {
     $viewClass = $this->schema->getViewClass($viewName, true);
     $recordClass = $this->schema->getRecordClass($viewName);
     $fields = $this->schema->getViewFields($viewName);
     $relationsData = $this->schema->getTableRelations($viewName);
     $relations = $this->instantiateRelations($relationsData);
     return new $viewClass($this, $viewName, $recordClass, $fields, $relations);
 }
Example #3
0
 /**
  * @param string $modelClassName
  * @param Schema $schema
  * @return string
  */
 private function getTableName($modelClassName, Schema $schema)
 {
     $tableNames = $schema->getTableNames();
     foreach ($tableNames as $tableName) {
         if ($modelClassName == $schema->getRecordClass($tableName)) {
             return $tableName;
         }
     }
     return null;
 }