public function testReturnResultFromQueryBuilder() { $stub = \Mockery::mock('Entity\\Posts'); MockEntityController::mock('post', $stub); $entityName = \PHPUnit_Framework_Assert::readAttribute($this->query->setQuery('post'), 'entityName'); $this->assertEquals('Entity\\Posts', $entityName); }
/** * * @param string $position */ private function loadMenuItmsByPosition(string $position) { $this->query->setQuery('menu')->findBy('position', $position)->limit(1); $content = $this->query->getStaticQuery(); if (array_key_exists(0, $content)) { $this->menuItemsArray = $content[0]->getMenuItems(); } }
/** * * @param string $column * @param mixed $value * @return boolean */ private function dataNotExistInDatabase(string $column, $value, array $exception) : bool { $query = $this->query->setQuery($this->entityKey); if (!empty($exception)) { $query->query("c.{$column} NOT IN(?0)", [$exception]); } $query->findBy($column, $value); $result = $this->query->getStaticQuery(); return count($result) === 0 ? true : false; }
private function selectPosts() { switch ($this->http->router->group()) { case 'post': $this->query->setQuery('post'); break; case 'category': $catIdArray = RegistryFactory::start()->register('App\\Resource\\CategoryList')->child(); $this->query->setQuery('post')->categoryId($catIdArray)->force(); break; case 'date': $this->query->setQuery('post')->date($this->getDate())->force(); break; default: $this->query->setQuery('post'); } $this->post = $this->query->getQuery(); }
private function setPageFromDB() { $this->query->setQuery('page'); $this->page = $this->query->getQuery(); }
/** * * @param string $alias * @return integer */ public function getIdByAlias(string $alias) : int { $this->query->setQuery('category')->alias($alias); $content = $this->query->getStaticQuery(); return $content ? $content[0]->getId() : 0; }
/** * @param $table Table name * @param $connName Connection name * @return Query */ public function query($table, $connName) { $query = new Query($this->getConnection($connName), $this->getGrammar()); return $query->table($table); }
/** * todo do something with paginate() * @return array */ public function getResult() : array { return $this->query->getQuery(); }