/** * @see AM_Task_Worker_Abstract::_fire() * @throws AM_Task_Worker_Exception * @return void */ protected function _fire() { $iIssueId = intval($this->getOption('issue_id')); $sMessage = $this->getOption('message'); $iBadge = intval($this->getOption('badge')); $oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy('id', $iIssueId); /* @var $oIssue AM_Model_Db_Issue */ if (is_null($oIssue)) { throw new AM_Task_Worker_Exception('Issue not found'); } $iApplicationId = $oIssue->getApplication()->id; if (empty($iApplicationId)) { throw new AM_Task_Worker_Exception('Wrong parameters were given'); } $oTokensRow = AM_Model_Db_Table_Abstract::factory('device_token')->getTokens($iApplicationId, AM_Model_Pns_Type::PLATFORM_IOS); if (0 === $oTokensRow->count()) { $this->finish(); $this->getLogger()->debug('There are not tokens to notificate'); return; } $aSenderTaskOptions = array('message' => $sMessage, 'badge' => $iBadge, 'application_id' => $iApplicationId); $aTokensGroups = array_chunk($oTokensRow->toArray(), 100); foreach ($aTokensGroups as $aTokensGroup) { $aTokens = array(); foreach ($aTokensGroup as $aToken) { $this->getLogger()->debug(sprintf('Preparing message for token apple \'%s\'', $aToken["token"])); $aTokens[] = $aToken['token']; } $aSenderTaskOptions['tokens'] = $aTokens; $oTaskSender = new AM_Task_Worker_Notification_Sender_Apple(); $oTaskSender->setOptions($aSenderTaskOptions); $oTaskSender->create(); } }
/** * Resizes all horizontal pages */ protected function _resizeHelpPages() { $oQuery = AM_Model_Db_Table_Abstract::factory('issue_help_page')->select()->setIntegrityCheck(false)->from('issue_help_page')->joinInner('issue', 'issue.id = issue_help_page.id_issue')->joinInner('application', 'application.id = issue.application')->joinInner('client', 'client.id = application.client')->where('issue.deleted = ?', 'no')->where('application.deleted = ?', 'no')->where('client.deleted = ?', 'no')->where('name IS NOT NULL')->columns(array('id' => 'issue.id', 'type' => 'issue_help_page.type'))->order('issue_help_page.id_issue ASC'); if ($this->_iFromIssueId > 0) { $oQuery->where('issue_help_page.id_issue > ?', $this->_iFromIssueId); } if ($this->_iIssueId > 0) { $oQuery->where('issue.id = ?', $this->_iIssueId); } if ($this->_iApplicationId > 0) { $oQuery->where('application.id = ?', $this->_iApplicationId); } $oHelpPages = AM_Model_Db_Table_Abstract::factory('issue_help_page')->fetchAll($oQuery); $iCounter = 0; /* @var $oHelpPage AM_Model_Db_IssueHelpPage */ foreach ($oHelpPages as $oHelpPage) { try { $this->_resizeImage($oHelpPage->name, $oHelpPage, $oHelpPage->getThumbnailPresetType(), $oHelpPage->type); } catch (Exception $oException) { $this->_echo(sprintf('%s', $oException->getMessage()), 'error'); } if ($iCounter++ > 100) { $iCounter = 0; AM_Handler_Temp::getInstance()->end(); } } }
/** * Returns element * @return AM_Model_Db_Element */ public function getElement() { if (is_null($this->_oElement)) { $this->_oElement = AM_Model_Db_Table_Abstract::factory('element')->findOneBy(array('id' => $this->id_element)); } return $this->_oElement; }
public function execute() { $iIdRevision = intval($this->_getOption('revision')); $iIdFrom = intval($this->_getOption('from')); //If this option is set, we are building packaged for issues with id > $iIdFrom $iIssueId = intval($this->_getOption('issue')); $iApplicationId = intval($this->_getOption('application')); $oQuery = AM_Model_Db_Table_Abstract::factory('term')->select()->setIntegrityCheck(false)->from('revision')->joinInner('issue', 'issue.id = revision.issue')->joinInner('application', 'application.id = issue.application')->joinInner('client', 'client.id = application.client')->where('revision.deleted = ?', 'no')->where('issue.deleted = ?', 'no')->where('application.deleted = ?', 'no')->where('client.deleted = ?', 'no')->columns(array('id' => 'revision.id'))->order('revision.id ASC'); if ($iIdFrom > 0) { $oQuery->where('revision.id > ?', $iIdFrom); } if ($iIdRevision > 0) { $oQuery->where('revision.id = ?', $iIdRevision); } if ($iIssueId > 0) { $oQuery->where('issue.id = ?', $iIssueId); } if ($iApplicationId > 0) { $oQuery->where('application.id = ?', $iApplicationId); } $oRevisions = AM_Model_Db_Table_Abstract::factory('revision')->fetchAll($oQuery); $oExportHandler = AM_Handler_Locator::getInstance()->getHandler('export'); /* @var $oExportHandler AM_Handler_Export */ foreach ($oRevisions as $oRevision) { $oExportHandler->exportRevision($oRevision); } }
public function setUp() { parent::setUp(); $this->_oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy(array('id' => 1)); $this->_oRevisionSetMock = $this->getMock('AM_Model_Db_Rowset_Revision', array('moveToIssue'), array(array('readOnly' => true))); $this->_oIssue->setRevisions($this->_oRevisionSetMock); }
/** * @see AM_Task_Worker_Abstract::_fire() * @throws AM_Task_Worker_Exception * @return void */ protected function _fire() { $aTokensApple = (array) $this->getOption('tokens_apple'); $aTokensAndroid = (array) $this->getOption('tokens_android'); $sMessage = $this->getOption('message'); $iBadge = intval($this->getOption('badge')); $iApplicationId = intval($this->getOption('application_id')); if (empty($iApplicationId)) { throw new AM_Task_Worker_Exception('Wrong parameters were given'); } $oApplication = AM_Model_Db_Table_Abstract::factory('application')->findOneBy('id', $iApplicationId); $sProviderKey = $oApplication->push_boxcar_provider_key; $sProviderSecret = $oApplication->push_boxcar_provider_secret; if (empty($sProviderKey) || empty($sProviderSecret)) { throw new AM_Task_Worker_Exception('Empty provider key or secret'); } $oTask = $this->_getTask(); if (is_null($oTask->id)) { throw new AM_Task_Worker_Exception('Trying to run non created task'); } try { $oBoxcar = new BoxcarPHP_Api($sProviderKey, $sProviderSecret); $oBoxcar->broadcast($sMessage, $iBadge, $aTokensApple, $aTokensAndroid, $oTask->id); } catch (BoxcarPHP_Exception $e) { $bError = true; $this->error(); } if (empty($bError)) { $this->finish(); } }
/** * Get user * @return AM_Model_Db_User|null */ public function getUser() { if (is_null($this->_oUser)) { $this->_oUser = AM_Model_Db_Table_Abstract::factory('user')->findOneBy(array('id' => $this->user)); } return $this->_oUser; }
/** * Resizes all horizontal pages */ protected function _resizeHorizontalPdfs() { $oQuery = AM_Model_Db_Table_Abstract::factory('page_horisontal')->select()->setIntegrityCheck(false)->from('page_horisontal')->joinInner('issue', 'issue.id = page_horisontal.id_issue')->joinInner('application', 'application.id = issue.application')->joinInner('client', 'client.id = application.client')->where('issue.deleted = ?', 'no')->where('application.deleted = ?', 'no')->where('client.deleted = ?', 'no')->where('resource IS NOT NULL')->columns(array('id' => 'page_horisontal.id'))->order('page_horisontal.id_issue ASC'); if ($this->_iFromIssueId > 0) { $oQuery->where('page_horisontal.id_issue > ?', $this->_iFromIssueId); } if ($this->_iIssueId > 0) { $oQuery->where('issue.id = ?', $this->_iIssueId); } if ($this->_iApplicationId > 0) { $oQuery->where('application.id = ?', $this->_iApplicationId); } $oPagesHorizaontal = AM_Model_Db_Table_Abstract::factory('page_horisontal')->fetchAll($oQuery); $iCounter = 0; foreach ($oPagesHorizaontal as $oPageHorizontal) { try { $this->_resizeImage($oPageHorizontal->resource, $oPageHorizontal, AM_Model_Db_PageHorisontal::RESOURCE_TYPE, $oPageHorizontal->weight); } catch (Exception $oException) { $this->_echo(sprintf('%s', $oException->getMessage()), 'error'); } if ($iCounter++ > 100) { $iCounter = 0; AM_Handler_Temp::getInstance()->end(); } } }
/** * @see AM_Task_Worker_Abstract::_fire() * @throws AM_Task_Worker_Exception * @return void */ protected function _fire() { $iIssueId = intval($this->getOption('issue_id')); $sMessage = $this->getOption('message'); $iBadge = intval($this->getOption('badge')); $sDeviceToken = $this->getOption('token'); $this->getLogger()->debug('Token value %s', $sDeviceToken); $oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy('id', $iIssueId); /* @var $oIssue AM_Model_Db_Issue */ if (is_null($oIssue)) { throw new AM_Task_Worker_Exception('Issue not found'); } $iApplicationId = $oIssue->getApplication()->id; if (empty($iApplicationId)) { throw new AM_Task_Worker_Exception('Wrong parameters were given'); } $oToken = AM_Model_Db_Table_Abstract::factory('device_token')->findOneBy(array('token' => $sDeviceToken, 'application_id' => $iApplicationId)); $aSenderTaskOptions = array('message' => $sMessage, 'badge' => $iBadge, 'application_id' => $iApplicationId); $aSenderTaskOptions['tokens_apple'] = array(); $aSenderTaskOptions['tokens_android'] = array(); if ($oToken->type_os == 'ios') { $aSenderTaskOptions['tokens_apple'] = array($sDeviceToken); } else { $aSenderTaskOptions['tokens_android'] = array($sDeviceToken); } $oTaskSender = new AM_Task_Worker_Notification_Sender_Boxcar(); $oTaskSender->setOptions($aSenderTaskOptions); $oTaskSender->create(); }
public function setUp() { parent::setUp(); $this->_oApplication = AM_Model_Db_Table_Abstract::factory('application')->findOneBy(array('id' => 1)); $this->_oUser = AM_Model_Db_Table_Abstract::factory('user')->findOneBy(array('id' => 2)); $this->_oIssueSetMock = $this->getMock('AM_Model_Db_Rowset_Issue', array('copyToUser'), array(array("readOnly" => true))); $this->_oApplication->setIssues($this->_oIssueSetMock); }
/** * Fetch field type * @return AM_Model_Db_Field */ public function fetchFieldType() { $this->_oFieldType = AM_Model_Db_Table_Abstract::factory('field_type')->findOneBy('id', $this->field_type); if (is_null($this->_oFieldType)) { throw new AM_Model_Db_Exception(sprintf('Field "%d" has no type', $this->id)); } return $this; }
/** * Fetch issue instance from db * @return AM_Model_Db_IssueSimplePdf * @throws AM_Model_Db_Exception */ public function fetchIssue() { $this->_oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy('id', $this->id_issue); if (is_null($this->_oIssue)) { throw new AM_Model_Db_Exception(sprintf('Simple pdf "%s" has no issue', $this->id)); } return $this; }
/** * Fetchs user's client * * @throws AM_Model_Db_Exception * @return AM_Model_Db_User */ public function fetchClient() { $this->_oClient = AM_Model_Db_Table_Abstract::factory('client')->findOneBy(array('id' => $this->client)); if (empty($this->_oClient)) { throw new AM_Model_Db_Exception(sprintf('User "%s" has no client', $this->id)); } return $this; }
/** * Get tasks type * @return AM_Model_Db_TaskType | null */ public function getTaskType() { if (empty($this->task_type_id)) { return null; } $oTaskType = AM_Model_Db_Table_Abstract::factory('task_type')->findOneBy(array('id' => $this->task_type_id)); return $oTaskType; }
public function setUp() { parent::setUp(); $this->_oStaticPdf = AM_Model_Db_Table_Abstract::factory('static_pdf')->findOneBy(array('id' => 1)); $this->_oStandardMock = $this->getMock('AM_Tools_Standard', array('is_dir', 'mkdir')); $this->_oUploaderMock = $this->getMock('AM_Handler_Upload', array('isValid', 'isUploaded', 'getFileInfo', 'receive')); $this->_oThumbnailerMock = $this->getMock('AM_Handler_Thumbnail', array('addSourceFile', 'loadAllPresets', 'createThumbnails', 'getSources')); AM_Handler_Locator::getInstance()->setHandler('thumbnail', $this->_oThumbnailerMock); }
public function testShouldGetTocAsTree() { //GIVEN $oRevision = AM_Model_Db_Table_Abstract::factory('revision')->findOneBy(array('id' => 1)); $aExpectedResult = array(array('parent_term' => null, 'attr' => array('id' => 2), 'data' => '2', 'children' => array(array('parent_term' => 2, 'attr' => array('id' => 6), 'data' => '2_2', 'children' => array()), array('parent_term' => 2, 'attr' => array('id' => 5), 'data' => '2_1', 'children' => array()))), array('parent_term' => null, 'attr' => array('id' => 1), 'data' => '1', 'children' => array(array('parent_term' => 1, 'attr' => array('id' => 3), 'data' => '1_1', 'children' => array(array('parent_term' => 3, 'attr' => array('id' => 7), 'data' => '1_1_1', 'children' => array()))), array('parent_term' => 1, 'attr' => array('id' => 4), 'data' => '1_2', 'children' => array())))); //WHEN $aResult = AM_Model_Db_Table_Abstract::factory('term')->getTocAsTree($oRevision); //THEN $this->assertEquals($aExpectedResult, $aResult); }
public function testShouldGetTocAsTree() { //GIVEN $oRevision = AM_Model_Db_Table_Abstract::factory('revision')->findOneBy(array('id' => 1)); $aExpectedResult = array('4' => '1 / 1_1', '3' => '1 / 1_2', '1' => '2'); //WHEN $aResult = AM_Model_Db_Table_Abstract::factory('term')->getTocAsList($oRevision); //THEN $this->assertTrue($aExpectedResult === $aResult); }
public function setUp() { parent::setUp(); $this->_oPage = AM_Model_Db_Table_Abstract::factory('page')->findOneBy(array('id' => 1)); $this->_oElementsMock = $this->getMock('AM_Model_Db_Rowset_Element', array('copyToPage'), array(array('readOnly' => true))); $this->_oPageBackgroundMock = $this->getMock('AM_Model_Db_PageBackground', array('copyToPage'), array(array('readOnly' => true, 'table' => new AM_Model_Db_Table_PageBackground()))); $this->_oTermMock = $this->getMock('AM_Model_Db_Term', array('saveToPage'), array(array('readOnly' => true, 'table' => new AM_Model_Db_Table_PageBackground()))); $this->_oPage->setElements($this->_oElementsMock); $this->_oPage->setPageBackground($this->_oPageBackgroundMock); $this->_oPage->addTerm($this->_oTermMock); }
/** * @see AM_Task_Worker_Abstract::_fire() * @throws AM_Task_Worker_Exception * @return void */ protected function _fire() { $iIssueId = intval($this->getOption('issue_id')); $oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy(array('id' => $iIssueId)); if (is_null($oIssue)) { throw new AM_Task_Worker_Exception(sprintf('Issue with id "%d" not found'), $iIssueId); } $oHorizontalPdfHandler = AM_Handler_Locator::getInstance()->getHandler('horisontal_pdf'); /* @var $oHorizontalPdfHandler AM_Handler_HorisontalPdf */ $oHorizontalPdfHandler->setIssue($oIssue)->compile(); }
/** * Create new element * * @param AM_Model_Db_Page $oPage * @param AM_Model_Db_Field $oField * @return AM_Model_Db_Element */ public static function getElementForPageAndField(AM_Model_Db_Page $oPage, AM_Model_Db_Field $oField) { $iMaxWeight = AM_Model_Db_Table_Abstract::factory('element')->getMaxElementWeight($oPage, $oField); $oElement = new AM_Model_Db_Element(); $oElement->setPage($oPage); $oElement->weight = is_null($iMaxWeight) ? 0 : ++$iMaxWeight; $oElement->page = $oPage->id; $oElement->field = $oField->id; $oElement->save(); return $oElement; }
/** * @return AM_Mapper_Sqlite_ElementData_PdfInfo */ protected function _unmapCustom() { $aCrosswordGameData = array('id' => $this->getModel()->id, 'title' => $this->getModel()->title, 'grid_width' => $this->getModel()->getDataValue('grid_width'), 'grid_height' => $this->getModel()->getDataValue('grid_height')); $this->_getSqliteGateway('game_crossword')->insert($aCrosswordGameData); $oWords = AM_Model_Db_Table_Abstract::factory('game_crossword_word')->findAllBy(array('game' => $this->getModel()->id)); foreach ($oWords as $oWord) { $aCrosswordGameWordData = array('game' => $this->getModel()->id, 'answer' => $oWord->answer, 'question' => $oWord->question, 'length' => $oWord->length, 'direction' => $oWord->direction, 'start_x' => $oWord->start_x, 'start_y' => $oWord->start_y); $this->_getSqliteGateway('game_crossword_word')->insert($aCrosswordGameWordData); } return $this; }
/** * Compile static pdf * @return AM_Handler_HorisontalPdf * @throws AM_Handler_HorisontalPdf_Exception */ public function compile() { AM_Model_Db_Table_Abstract::factory('page')->resetHorizontalPdf($this->getIssue()); AM_Model_Db_Table_Abstract::factory('page_horisontal')->deleteBy(array('id_issue' => $this->getIssue()->id)); AM_Tools::clearContent(AM_Model_Db_StaticPdf_Data_Abstract::TYPE_CACHE, $this->getIssue()->id); AM_Tools::clearResizerCache(AM_Model_Db_StaticPdf_Data_Abstract::TYPE_CACHE, AM_Model_Db_StaticPdf_Data_Abstract::TYPE_CACHE, $this->getIssue()->id); if (!count($this->getIssue()->getHorizontalPdfs())) { return $this; } switch ($this->getIssue()->static_pdf_mode) { case AM_Model_Db_Issue::HORISONTAL_MODE_PAGE: //Get first pages of all pdfs and glue them $aFiles = (array) $this->_compilePageVersion(); break; case AM_Model_Db_Issue::HORISONTAL_MODE_ISSUE: //Get pdf's first pages and glue them $aFiles = (array) $this->_compileIssueVersion(); break; case AM_Model_Db_Issue::HORISONTAL_MODE_2PAGES: //Get all pdf's pages and glue them $aFiles = (array) $this->_compile2PagesVersion(); break; } $sCachePath = $this->_getFilesPath(); if (!empty($aFiles)) { if (!AM_Tools_Standard::getInstance()->is_dir($sCachePath)) { if (!AM_Tools_Standard::getInstance()->mkdir($sCachePath, 0777, true)) { throw new AM_Handler_HorisontalPdf_Exception('I/O error while create cache dir'); } } $oThumbnailer = AM_Handler_Locator::getInstance()->getHandler('thumbnail'); /* @var $oThumbnailer AM_Handler_Thumbnail */ $oThumbnailer->clearSources()->loadAllPresets(AM_Model_Db_StaticPdf_Data_Abstract::TYPE_CACHE)->setImageType(AM_Handler_Thumbnail::IMAGE_TYPE_JPEG); foreach ($aFiles as $sFile) { $sFilename = pathinfo($sFile, PATHINFO_BASENAME); $sNewFilePath = $sCachePath . DIRECTORY_SEPARATOR . $sFilename; if (!AM_Tools_Standard::getInstance()->rename($sFile, $sNewFilePath)) { throw new AM_Handler_HorisontalPdf_Exception('I/O error while copy file'); } AM_Tools_Standard::getInstance()->chmod($sNewFilePath, 0666); if (AM_Tools::isAllowedImageExtension($sNewFilePath)) { $oThumbnailer->addSourceFile($sNewFilePath); } $oPageHorisontal = new AM_Model_Db_PageHorisontal(); $oPageHorisontal->id_issue = $this->getIssue()->id; $oPageHorisontal->resource = $sFilename; $oPageHorisontal->weight = pathinfo($sFile, PATHINFO_FILENAME); $oPageHorisontal->save(); } $oThumbnailer->createThumbnails(); } return $this; }
public function testShouldUnmapPageImposition() { //GIVEN $oPage = AM_Model_Db_Table_Abstract::factory('page_imposition')->findOneBy('id', 1); $oMapper = AM_Mapper_Abstract::factory($oPage, "sqlite", array('adapter' => $this->_oAdapter)); /* @var $oMapper AM_Mapper_Sqlite_Page */ //WHEN $oMapper->unmap(); //THEN $oGivenDataSet = $this->_oConnectionMock->createQueryTable('page_imposition', 'SELECT page_id, is_linked_to, position_type FROM page_imposition ORDER BY id'); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/PageImpositionMapperSqliteTest.xml')->getTable('page_imposition'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function testShouldErrorWorkerTask() { //GIVEN $oTask = AM_Model_Db_Table_Abstract::factory('task')->findOneBy(array('id' => 1)); $oWorker = new AM_Task_Worker_Mock(); $oWorker->setTask($oTask); //WHEN $oWorker->error(new AM_Task_Worker_Exception('Exception given', 500)); //THEN $oGivenDataSet = $this->getConnection()->createQueryTable('task', 'SELECT id, task_type_id, status, options FROM task ORDER BY id'); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/WorkerErrorTest.xml')->getTable('task'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function testShouldUpdateTermsRelations() { //GIVEN $oTermRoot = AM_Model_Db_Table_Abstract::factory('term')->findOneBy(array('id' => 1)); $oTermChild = AM_Model_Db_Table_Abstract::factory('term')->findOneBy(array('id' => 2)); //WHEN $oTermRoot->addChild($oTermChild); $oTermChild->updateReletations(); //THEN $oGivenDataSet = $this->getConnection()->createQueryTable('term', 'SELECT id, vocabulary, revision, parent_term FROM term ORDER BY id'); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/TermUpdateRelationsTest.xml')->getTable('term'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function testShouldReturnTrueWhenCheckNotExpiredPayment() { //GIVEN $oPurchase = AM_Model_Db_Table_Abstract::factory('purchase')->findOneBy(array('id' => 1)); $oDate = new Zend_Date(); $oDate->setTimestamp(time() + 3600000); $oPurchase->expires_date = $oDate->toString('Y-m-d H:i:s'); $oPurchase->save(); //WHEN $bResult = $oPurchase->isExpired(); //THEN $this->assertFalse($bResult); }
public function testShouldFinishWorkerTask() { //GIVEN $oTask = AM_Model_Db_Table_Abstract::factory('task')->findOneBy(array('id' => 1)); $oWorker = new AM_Task_Worker_Mock(); $oWorker->setTask($oTask); //WHEN $oWorker->finish(); //THEN $oGivenDataSet = $this->getConnection()->createQueryTable("task", "SELECT id, task_type_id, status, options FROM task ORDER BY id"); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . "/_dataset/WorkerFinishTest.xml")->getTable("task"); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function testShouldUnmapTerm() { //GIVEN $oPage = AM_Model_Db_Table_Abstract::factory('term')->findOneBy('id', 1); $oMapper = AM_Mapper_Abstract::factory($oPage, "sqlite", array('adapter' => $this->_oAdapter)); /* @var $oMapper AM_Mapper_Sqlite_Page */ //WHEN $oMapper->unmap(); //THEN $oGivenDataSet = $this->_oSqliteConnectionMock->createQueryTable("menu", "SELECT title, description, thumb_stripe, thumb_summary, color, firstpage_id FROM menu ORDER BY id"); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/TermMapperSqliteTest.xml')->getTable('menu'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function testShouldUnmapPage() { //GIVEN $oPage = AM_Model_Db_Table_Abstract::factory('page')->findOneBy('id', 1); $oMapper = AM_Mapper_Abstract::factory($oPage, "sqlite", array('adapter' => $this->_oAdapter)); /* @var $oMapper AM_Mapper_Sqlite_Page */ //WHEN $oMapper->unmap(); //THEN $oGivenDataSet = $this->_oSqliteConnectionMock->createQueryTable("page", "SELECT id, title, horisontal_page_id, template, machine_name, color FROM page ORDER BY id"); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/PageMapperSqliteTest.xml')->getTable('page'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }
public function moveToIssue(AM_Model_Db_Issue $oIssueTo) { $oVocabulary = AM_Model_Db_Table_Abstract::factory('application')->findOneBy('id', $oIssueTo->application)->getVocabularyTag(); $oTag = AM_Model_Db_Table_Abstract::factory('term')->findOneBy('id', $this->term); $oNewTag = AM_Model_Db_Table_Abstract::factory('term')->findOneBy(array('title' => $oTag->title, 'vocabulary' => $oVocabulary->id)); if (empty($oNewTag)) { $oNewTag = $oVocabulary->createTag($oTag->title); } $this->term = $oNewTag->id; $this->entity = $oIssueTo->id; $this->save(); return $this; }