Exemplo n.º 1
0
 public function testCreateError()
 {
     $manager = \FelixOnline\Core\BaseManager::build('FelixOnline\\Core\\EmailValidation', 'email_validation');
     $this->assertEquals($manager->count(), 2);
     $code = \FelixOnline\Core\EmailValidation::create('*****@*****.**');
     $this->assertFalse($code);
     $this->assertEquals($manager->count(), 2);
 }
Exemplo n.º 2
0
 public function testSetContent()
 {
     $this->assertEquals(3, $this->getConnection()->getRowCount('text_story'));
     $article = new \FelixOnline\Core\Article(1);
     $article->setContent('Foo bar');
     $this->assertEquals(4, $this->getConnection()->getRowCount('text_story'));
     $manager = \FelixOnline\Core\BaseManager::build('\\FelixOnline\\Core\\Text', 'text_story');
     $text = $manager->filter('content = "Foo bar"')->one();
     $this->assertEquals($text->getId(), $article->getText1()->getId());
 }
Exemplo n.º 3
0
 public function getResponses()
 {
     $answers = array();
     $total_count = 0;
     // get answers
     $option = \FelixOnline\Core\BaseManager::build('FelixOnline\\Core\\PollOption', 'polls_option');
     $option->filter("poll = '%s'", array($this->getId()));
     $option = $option->values();
     foreach ($option as $option_inst) {
         $resp = \FelixOnline\Core\BaseManager::build('FelixOnline\\Core\\PollResponse', 'polls_response');
         $resp->filter("poll = '%s'", array($this->getId()))->filter("option = '%s'", array($option_inst->getId()));
         $resp = $resp->count();
         $answers[$option_inst->getId()] = array('id' => $option_inst->getId(), 'label' => $option_inst->getText(), 'count' => $resp);
         $total_count += $resp;
     }
     return array('total' => $total_count, 'answers' => $answers);
 }
Exemplo n.º 4
0
 /**
  * Public: Get the date the article was originally published
  * Legacy compatability function
  */
 public function getPublished()
 {
     $manager = BaseManager::build('\\FelixOnline\\Core\\ArticlePublication', 'article_publication');
     try {
         $date = $manager->filter('article = %i', array($this->getId()))->filter('republished = 0')->one();
     } catch (\FelixOnline\Exceptions\InternalException $e) {
         return null;
     }
     return $date->getPublicationDate();
 }
Exemplo n.º 5
0
 public function testBuild()
 {
     $manager = \FelixOnline\Core\BaseManager::build('FelixOnline\\Core\\Article', 'article', 'id');
     $this->assertEquals($manager->class, 'FelixOnline\\Core\\Article');
     $this->assertEquals($manager->table, 'article');
     $this->assertEquals($manager->pk, 'id');
 }
Exemplo n.º 6
0
 public function getExplicitRoles()
 {
     $manager = \FelixOnline\Core\BaseManager::build('FelixOnline\\Core\\UserRole', 'user_roles', 'id');
     $manager->filter('user = "******"', array($this->getUser()));
     $values = $manager->values();
     if (!$values) {
         return null;
     }
     $roles = array();
     foreach ($values as $value) {
         $roles[] = $value->getRole();
     }
     return $roles;
 }