Beispiel #1
0
 /**
  * @param string intfName
  */
 public function build($intfName)
 {
     $classPath = $this->config->daoClassPath;
     $className = $this->getDaoClassName($intfName);
     $path = $this->normalizePath("{$classPath}/{$className}.php");
     if (!file_exists(dirname($path))) {
         mkdir(dirname($path), 0777, true);
     }
     $ref = new \ReflectionClass($intfName);
     if ($this->watcher->outdated($ref->getFileName()) || $this->watcher->sqlOutdated($className::AccessRoute)) {
         $builder = new DaoBuilder($ref, $className);
         $builder->setParamCaseSensor(CaseSensor::{$this->config->paramCaseSensor}());
         $builder->setReturnCaseSensor(CaseSensor::{$this->config->returnCaseSensor}());
         $builder->prepare();
         file_put_contents($path, $builder->export(true));
     }
 }
Beispiel #2
0
 /**
  * @test
  */
 public function test_update_dao_with_whenever_mode_permanently()
 {
     $w = new ChangeWatcher(self::daoRoot, WatchMode::Whenever());
     $this->modifyDao();
     $w->clear();
     $class = new \ReflectionClass(SwitchDao::class);
     $path = $class->getFileName();
     $this->assertTrue($w->outdated($path));
     $w->save(true);
     $this->assertFalse($w->outdated($path));
     $w = new ChangeWatcher(self::daoRoot, WatchMode::Whenever());
     $this->assertFalse($w->outdated($path));
     $this->modifyDao();
     $this->assertTrue($w->outdated($path));
     $w->save(true);
     $this->assertFalse($w->outdated($path));
     $w = new ChangeWatcher(self::daoRoot, WatchMode::Whenever());
     $this->assertFalse($w->outdated($path));
 }