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); }
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()); }
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); }
/** * 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(); }
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'); }
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; }