/**
  * @Given /^there is a model "([^"]*)"$/
  */
 public function thereIsAModel($modelName)
 {
     if (!class_exists($modelName)) {
         eval('class ' . $modelName . ' extends \\Illuminate\\Database\\Eloquent\\Model {  }');
     }
     $this->models[] = $modelName;
     $this->lastModel = $modelName;
     $config = new ModelConfig($modelName);
     $this->lastConfig = $config;
     $this->databaseHelper->shouldReceive('hasTable')->with($config->getTableName())->andReturn(true);
 }
示例#2
0
 /**
  * Finds the name of the table for given Model, using the `ModelConfig` class for the `Model`.
  * Uses the overridden value if present, or falls back to the generated value.
  *
  * @param Model       $model  The `Model` to find the table name for.
  * @param ModelConfig $config The `ModelConfig` to use for retrieving the table name.
  *
  * @return String The name of table for given Model.
  */
 public function getTableName(Model $model, ModelConfig $config = null)
 {
     if (empty($this->models)) {
         throw new \LogicException('AujaConfigurator not configured yet! Call configure first.');
     }
     if (!isset($this->configs[$model->getName()])) {
         throw new \LogicException(sprintf('AujaConfigurator not configured for model %s', $model->getName()));
     }
     $result = null;
     if ($config != null && $config->getTableName() != null) {
         $result = $config->getTableName();
     } else {
         $modelConfig = $this->configs[$model->getName()];
         $result = $modelConfig->getTableName();
     }
     return $result;
 }