/** * Set up * * @return void */ protected function setUp() { $this->database = $this->getMock(DatabaseConnection::class, array('exec_SELECTgetSingleRow')); $this->database->expects($this->any())->method('exec_SELECTgetSingleRow')->will($this->returnValue(array('uid' => 0, 'parent' => ''))); $this->treeData = new TreeNode(); $GLOBALS['TYPO3_DB'] = $this->database; }
/** * Migrate tt_news_categorymounts to category_pems in either be_groups or be_users * * @param string $table either be_groups or be_users */ public function migrateTtNewsCategoryMountsToSysCategoryPerms($table) { /** @var \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler */ $dataHandler = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $dataHandler->admin = TRUE; /* assign imported categories to be_groups or be_users */ $whereClause = 'tt_news_categorymounts != \'\'' . BackendUtility::deleteClause($table); $beGroupsOrUsersWithTtNewsCategorymounts = $this->databaseConnection->exec_SELECTgetRows('*', $table, $whereClause); $data = array(); foreach ((array) $beGroupsOrUsersWithTtNewsCategorymounts as $beGroupOrUser) { $ttNewsCategoryPermissions = GeneralUtility::trimExplode(',', $beGroupOrUser['tt_news_categorymounts']); $sysCategoryPermissions = array(); foreach ($ttNewsCategoryPermissions as $ttNewsCategoryPermissionUid) { $whereClause = 'import_source = \'TT_NEWS_CATEGORY_IMPORT\' AND import_id = ' . $ttNewsCategoryPermissionUid; $sysCategory = $this->databaseConnection->exec_SELECTgetSingleRow('uid', 'sys_category', $whereClause); if (!empty($sysCategory)) { $sysCategoryPermissions[] = $sysCategory['uid']; } } if (count($sysCategoryPermissions)) { $data[$table][$beGroupOrUser['uid']] = array('category_perms' => implode(',', $sysCategoryPermissions) . ',' . $beGroupOrUser['category_perms']); } } $dataHandler->start($data, array()); $dataHandler->process_datamap(); }
/** * @param \S3b0\ProjectRegistration\Scheduler\InfoMail\Task $task * * @return bool */ public function run(\S3b0\ProjectRegistration\Scheduler\InfoMail\Task $task) { $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extensionName]); $upperLimit = new \DateTime(); $lowerLimit = new \DateTime(); $daysLeft = $settings['warnXDaysBeforeExpireDate']; $sender = [$task->getSenderAddress()]; $receiver = [$task->getReceiverAddress()]; $subject = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('infomail.subject', $this->extensionName); $this->databaseConnection = $GLOBALS['TYPO3_DB']; // Upper limit (expiry) = Current date + Days left $upperLimit->setTimestamp($upperLimit->getTimestamp() + $daysLeft * 86400); // Lower limit (expiry) = Current date + Days left - Scheduler frequency $lowerLimit->setTimestamp($lowerLimit->getTimestamp() + $daysLeft * 86400 - $task->getExecution()->getInterval()); $where = "date_of_expiry > '{$lowerLimit->format('Y-m-d h:i:s')}' AND date_of_expiry < '{$upperLimit->format('Y-m-d h:i:s')}'"; if ($this->databaseConnection->exec_SELECTcountRows('*', 'tx_projectregistration_domain_model_project', $where)) { $expiredProjects = $this->databaseConnection->exec_SELECTgetRows('project.*, registrant.name as registrant_name, registrant.company as registrant_company', 'tx_projectregistration_domain_model_project as project join tx_projectregistration_domain_model_person as registrant on project.registrant=registrant.uid', $where); $list = []; /** @var array $expiredProject */ foreach ($expiredProjects as $expiredProject) { $list[] = "#{$expiredProject['uid']} - '{$expiredProject['title']}' by {$expiredProject['registrant_name']} ({$expiredProject['registrant_company']})"; } $mailContent = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('infomail.message', $this->extensionName, [$daysLeft, '<li>' . implode('</li><li>', $list) . '</li>']); /** @var \TYPO3\CMS\Core\Mail\MailMessage $mail */ $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class); $mail->setContentType('text/html'); /** * Email to sender */ $mail->setFrom($sender)->setTo($receiver)->setPriority(1)->setSubject($subject)->setBody($mailContent)->send(); } return true; }
/** * @test */ public function addDataSetsPageLanguageOverlayRows() { $input = ['effectivePid' => '23']; $expected = $input; $expected['pageLanguageOverlayRows'] = [0 => ['uid' => '1', 'pid' => '42', 'sys_language_uid' => '2']]; $this->dbProphecy->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=23')->shouldBeCalled()->willReturn($expected['pageLanguageOverlayRows']); $this->assertSame($expected, $this->subject->addData($input)); }
/** * @param \TYPO3\Sso\Domain\Model\FrontendUser $frontendUser * * @throws EmptyUserException * @return void */ public function registerSession($frontendUser) { if (!$frontendUser) { throw new EmptyUserException('No user given that can be dropped into the session.', 1329749957); } $row = $this->db->exec_SELECTgetSingleRow('*', 'fe_users', 'uid = ' . $frontendUser->getUid()); $this->getFeUser()->createUserSession($row); $this->getFeUser()->setSessionCookie(); }
/** * @return boolean TRUE on success, FALSE otherwise */ public function release() { $res = $this->connection->sql_query(sprintf('SELECT RELEASE_LOCK("%s") AS res', $this->identifier)); if ($res) { $releaseLockRes = $res->fetch_assoc(); return (int) $releaseLockRes['res'] === 1; } return false; }
/** * Return Form Uid from content element * * @param int $ttContentUid * @return int */ protected function getFormUidFromTtContentUid($ttContentUid) { $row = $this->databaseConnection->exec_SELECTgetSingleRow('pi_flexform', 'tt_content', 'uid=' . (int) $ttContentUid); $flexform = GeneralUtility::xml2array($row['pi_flexform']); if (is_array($flexform) && isset($flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'])) { return (int) $flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF']; } return 0; }
/** * @test * * @return void */ public function prepareSelectQueryCreateValidQuery() { $this->assertTrue($this->subject->admin_query("INSERT INTO {$this->testTable} ({$this->testField}) VALUES ('aTestValue')")); $preparedQuery = $this->subject->prepare_SELECTquery("{$this->testField},{$this->anotherTestField}", $this->testTable, 'id=:id', '', '', '', [':id' => 1]); $preparedQuery->execute(); $result = $preparedQuery->fetch(); $expectedResult = [$this->testField => 'aTestValue', $this->anotherTestField => null]; $this->assertSame($expectedResult, $result); }
/** * @test */ public function databaseResultIsUsedWhenNoCachedResultIsPresent() { $fakeConfiguration = array('select.' => array('checkRootPageId' => true, 'checkLanguage' => true, 'SELECT' => '', 'FROM' => '', 'ADD_WHERE' => '', 'GROUP_BY' => '', 'ORDER_BY' => ''), 'limit'); $this->configurationMock->expects($this->once())->method('getSearchFrequentSearchesConfiguration')->will($this->returnValue($fakeConfiguration)); $this->databaseMock->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array(array('search_term' => 'my search', 'hits' => 22)))); //we fake that we have no frequent searches in the cache and therefore expect that the database will be queried $this->fakeIdentifierNotInCache(); $frequentTerms = $this->frequentSearchesService->getFrequentSearchTerms(); $this->assertSame($frequentTerms, array('my search' => 22), 'Could not retrieve frequent search terms'); }
/** * initializes this class * * @param integer $pageUid * * @return void */ public function init($pageUid) { $this->setDatabaseConnection($GLOBALS['TYPO3_DB']); if (!$this->layoutSetup instanceof LayoutSetup) { if ($pageUid < 0) { $triggerElement = $this->databaseConnection->exec_SELECTgetSingleRow('pid', 'tt_content', 'uid = ' . -$pageUid); $pageUid = (int) $triggerElement['pid']; } $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid)); } }
/** * @param $uid * @param $parentUid */ function validateParentUid($uid, $parentUid) { # Always validate for new forums. if ($uid == -1) { return; } $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_forums', 'parentID=' . intval($uid) . ' AND deleted=0 ' . $this->parent->getStoragePIDQuery()); if ($this->databaseHandle->sql_num_rows($res) > 0 && $parentUid != 0) { $this->addErrorForField('parent', 'no-nested-forums', array($this->databaseHandle->sql_num_rows($res))); } }
/** * add cities to selectbox. * * @param array $parentArray * @param \TYPO3\CMS\Backend\Form\FormEngine $fObj */ public function addCityItems(array $parentArray, \TYPO3\CMS\Backend\Form\FormEngine $fObj) { $this->init(); $rows = $this->database->exec_SELECTgetRows('city', 'tx_clubdirectory_domain_model_address', '1=1 ' . BackendUtility::BEenableFields('tx_clubdirectory_domain_model_address') . BackendUtility::deleteClause('tx_clubdirectory_domain_model_address'), 'city', 'city', ''); foreach ($rows as $row) { $item = array(); $item[0] = $row['city']; $item[1] = $row['city']; $item[2] = null; $parentArray['items'][] = $item; } }
/** * Check if the note plugin expects output. If there are no sys_note records on the given * pages, the extbase bootstrap doesn't have to run the complete plugin. * This mechanism should increase the performance of the hooked backend modules heavily. * * @param array $arguments Arguments for the extbase plugin * @return bool */ protected function expectOutput(array $arguments = array()) { // no pids set if (!isset($arguments['pids']) || empty($arguments['pids']) || empty($GLOBALS['BE_USER']->user['uid'])) { return false; } $pidList = $this->databaseConnection->cleanIntList($arguments['pids']); if (empty($pidList)) { return false; } // check if there are records return $this->databaseConnection->exec_SELECTcountRows('*', 'sys_note', 'pid IN (' . $pidList . ')' . BackendUtility::deleteClause('sys_note')) > 0; }
/** * @param int $startPage * @param array $basePages * @param SitemapController $obj * * @return array */ public function getRecords($startPage, $basePages, SitemapController $obj) { $nodes = array(); foreach ($basePages as $uid) { if ($this->currentLanguageUid) { $fields = $this->cObject->enableFields('pages_language_overlay'); $overlay = $this->database->exec_SELECTgetSingleRow('uid', 'pages_language_overlay', ' pid=' . intval($uid) . ' AND sys_language_uid=' . $this->currentLanguageUid . $fields); if (!is_array($overlay)) { continue; } } // Build URL $url = $obj->getUriBuilder()->setTargetPageUid($uid)->build(); // can't generate a valid url if (!strlen($url)) { continue; } // Get Record $record = BackendUtility::getRecord('pages', $uid); // exclude Doctypes if (in_array($record['doktype'], array(4))) { continue; } // Check FE Access if ($record['fe_group'] != 0) { continue; } $rootLineList = $GLOBALS['TSFE']->sys_page->getRootLine($record['uid']); $addToNode = true; foreach ($rootLineList as $rootPage) { if ($rootPage['extendToSubpages'] == 1 && $rootPage['fe_group'] != 0) { $addToNode = false; break; } } if ($addToNode == false) { continue; } // Build Node $node = new Node(); $node->setLoc($url); $node->setPriority($this->getPriority($startPage, $record)); $node->setChangefreq(SitemapDataService::mapTimeout2Period($record['cache_timeout'])); $node->setLastmod($this->getModifiedDate($record)); #$geo = new Geo(); #$geo->setFormat('kml'); #$node->setGeo($geo); $nodes[] = $node; } return $nodes; }
/** * Get a user from DB by social identifier * * @param string $identifier social identifier * @param string $extraWhere Additional WHERE clause: " AND ... * @param array $dbUserSetup User db table definition: $this->db_user * @return mixed User array or FALSE */ public function fetchUserRecordByIdentifier($identifier, $extraWhere = '', $dbUserSetup = '') { $result = FALSE; $identityClassName = 'Portrino\\PxHybridAuth\\Domain\\Model\\Identity\\' . ucfirst($this->getServiceProvider()) . 'Identity'; if (class_exists($identityClassName) && defined($identityClassName . '::EXTBASE_TYPE')) { $extbaseType = constant($identityClassName . '::EXTBASE_TYPE'); $identityClause = 'deleted=0 AND hidden=0 AND identifier=' . $this->db->fullQuoteStr($identifier, 'tx_pxhybridauth_domain_model_identity') . ' AND ' . 'tx_extbase_type=' . $this->db->fullQuoteStr($extbaseType, 'tx_pxhybridauth_domain_model_identity'); $socialIdentities = $this->db->exec_SELECTgetRows('*', 'tx_pxhybridauth_domain_model_identity', $identityClause); foreach ($socialIdentities as $socialIdentity) { if (isset($socialIdentity['fe_user'])) { $dbUser = is_array($dbUserSetup) ? $dbUserSetup : $this->db_user; // Look up the user by the username and/or extraWhere: $dbres = $this->db->exec_SELECTquery('*', $dbUser['table'], 'uid' . '=' . $this->db->fullQuoteStr($socialIdentity['fe_user'], $dbUser['table']) . $this->db->fullQuoteStr($dbUser['check_pid_clause'], $dbUser['table']) . $dbUser['enable_clause'] . $extraWhere); if ($dbres) { $result = $this->db->sql_fetch_assoc($dbres); $this->db->sql_free_result($dbres); if ($result) { break; } } } } } return $result; }
/** * Migrate news_category.image (CSV) to sys_category.images (sys_file_reference) * * @return void */ protected function migrateCategoryImages() { $oldCategories = $this->databaseConnection->exec_SELECTgetRows('uid, pid, image, migrate_sys_category_uid', 'tx_mooxnews_domain_model_category', 'deleted=0 AND image!=""'); // no images to process then skip if (!count($oldCategories)) { return; } $processedImages = 0; foreach ($oldCategories as $oldCategory) { $files = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $oldCategory['image'], TRUE); $i = 0; foreach ($files as $file) { if (file_exists(PATH_site . 'uploads/tx_mooxnews/' . $file)) { $fileObject = $this->getCategoryImageFolder()->addFile(PATH_site . 'uploads/tx_mooxnews/' . $file); $dataArray = array('uid_local' => $fileObject->getUid(), 'tstamp' => $_SERVER['REQUEST_TIME'], 'crdate' => $_SERVER['REQUEST_TIME'], 'tablenames' => 'sys_category', 'uid_foreign' => $oldCategory['migrate_sys_category_uid'], 'pid' => $oldCategory['pid'], 'fieldname' => 'images', 'table_local' => 'sys_file', 'sorting_foreign' => $i); $this->databaseConnection->exec_INSERTquery('sys_file_reference', $dataArray); $processedImages++; } $i++; } } $message = 'Migrated ' . $processedImages . ' category images'; $status = FlashMessage::INFO; $title = ''; $this->messageArray[] = array($status, $title, $message); }
/** * Get column names * * @since 1.0.0 * * @param $table * * @return array */ protected function getColumnNames($table) { $table = preg_replace('/[^a-z0-9_]/', '', $table); if (isset($this->tableColumnCache[$table])) { return $this->tableColumnCache[$table]; } else { $result = $this->databaseConnection->exec_SELECTgetSingleRow('*', $table, '1 = 1'); if ($result) { $columnNames = array_keys($result); $this->tableColumnCache[$table] = $columnNames; } else { $columnNames = array(); $result = $this->databaseConnection->sql_query('SELECT DATABASE();'); $row = $this->databaseConnection->sql_fetch_row($result); $databaseName = $row[0]; $this->databaseConnection->sql_free_result($result); $result = $this->databaseConnection->sql_query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $databaseName . "' AND TABLE_NAME = '" . $table . "';"); while ($row = $this->databaseConnection->sql_fetch_row($result)) { $columnNames[] = $row[0]; } $this->databaseConnection->sql_free_result($result); $this->tableColumnCache[$table] = $columnNames; } return $columnNames; } }
/** * Determines if the current user may write in a certain topic. * @param mixed $topic The topic identifier. This may either be a topic UID pointing to * a record in the tx_mmforum_topics table or an associative array * already containing this record. * @return boolean TRUE, if the user that is currently logged in may write in the * specified topic, otherwise FALSE. * @author Martin Helmich <*****@*****.**> */ function getMayWrite_topic($topic) { $userId = $this->getUserID(); // If the $topic parameter is not an array, treat this parameter as a topic UID. if (!is_array($topic)) { $topic = intval($topic); // Look in the cache. In case of a hit, just return the result $cacheRes = $this->cache->restore('getMayWrite_topic_' . $topic . '_' . $userId); if ($cacheRes !== null) { return $cacheRes; } // Load the topic's forum UID $res = $this->databaseHandle->exec_SELECTquery('f.*', 'tx_mmforum_forums f, tx_mmforum_topics t', 't.uid="' . $topic . '" AND f.uid = t.forum_id'); $arr = $this->databaseHandle->sql_fetch_assoc($res); $result = $this->getMayWrite_forum($arr); // Save the result to cache and return $this->cache->save('getMayWrite_topic_' . $topic . '_' . $userId, $result); return $result; } else { /* If the topic's forum UID is already known, just delegate to the * getMayWrite_forum function. Since the result of that function is * already being cached, there is no need to cache the result at this * place again. */ return $this->getMayWrite_forum($topic['forum_id']); } }
/** * Implement normalization according to OpenID 2.0 specification * See http://openid.net/specs/openid-authentication-2_0.html#normalization * * @param string $openIDIdentifier OpenID identifier to normalize * @return string Normalized OpenID identifier * @throws Exception */ protected function normalizeOpenID($openIDIdentifier) { if (empty($openIDIdentifier)) { throw new Exception('Empty OpenID Identifier given.', 1381922460); } // Strip everything with and behind the fragment delimiter character "#" if (strpos($openIDIdentifier, '#') !== FALSE) { $openIDIdentifier = preg_replace('/#.*$/', '', $openIDIdentifier); } // A URI with a missing scheme is normalized to a http URI if (!preg_match('#^https?://#', $openIDIdentifier)) { $escapedIdentifier = $this->databaseConnection->quoteStr($openIDIdentifier, $this->authenticationInformation['db_user']['table']); $condition = 'tx_openid_openid IN (' . '\'http://' . $escapedIdentifier . '\',' . '\'http://' . $escapedIdentifier . '/\',' . '\'https://' . $escapedIdentifier . '\',' . '\'https://' . $escapedIdentifier . '/\'' . ')'; $row = $this->databaseConnection->exec_SELECTgetSingleRow('tx_openid_openid', $this->authenticationInformation['db_user']['table'], $condition); if (is_array($row)) { $openIDIdentifier = $row['tx_openid_openid']; } else { // This only happens when the OpenID provider will select the final OpenID identity // In this case we require a valid URL as we cannot guess the scheme // So we throw an Exception and do not start the OpenID handshake at all throw new Exception('Trying to authenticate with OpenID but identifier is neither found in a user record nor it is a valid URL.', 1381922465); } } // An empty path component is normalized to a slash // (e.g. "http://domain.org" -> "http://domain.org/") if (preg_match('#^https?://[^/]+$#', $openIDIdentifier)) { $openIDIdentifier .= '/'; } return $openIDIdentifier; }
/** * @return array */ protected function tables() { if (!isset($this->_tables)) { $this->_tables = array_keys($this->db->admin_get_tables()); } return $this->_tables; }
/** * Checking if parameters bound to the statement by bindValues() * are properly replaced in the query. * * @test * @dataProvider parametersAndQueriesDataProvider * @param string $query Query with unreplaced markers * @param array $parameters Array of parameters to be replaced in the query * @param string $expectedResult Query with all markers replaced * @return void */ public function parametersAreReplacedInQueryWhenBoundWithBindValues($query, $parameters, $expectedResult) { $statement = $this->createPreparedStatement($query); $this->databaseStub->expects($this->any())->method('prepare_PREPAREDquery')->with($this->equalTo($expectedResult)); $statement->bindValues($parameters); $statement->execute(); }
/** * Creates file identifier hashes for a single storage. * * @param ResourceStorage $storage The storage to update * @return array The executed database queries */ protected function updateIdentifierHashesForStorage(ResourceStorage $storage) { $queries = array(); if (!ExtensionManagementUtility::isLoaded('dbal')) { // if DBAL is not loaded, we're using MySQL and can thus use their // SHA1() function if ($storage->usesCaseSensitiveIdentifiers()) { $updateCall = 'SHA1(identifier)'; } else { $updateCall = 'SHA1(LOWER(identifier))'; } $queries[] = $query = sprintf('UPDATE sys_file SET identifier_hash = %s WHERE storage=%d', $updateCall, $storage->getUid()); $this->db->sql_query($query); // folder hashes cannot be done with one call: so do it manually $files = $this->db->exec_SELECTgetRows('uid, storage, identifier', 'sys_file', sprintf('storage=%d AND folder_hash=""', $storage->getUid())); foreach ($files as $file) { $folderHash = $storage->hashFileIdentifier($storage->getFolderIdentifierFromFileIdentifier($file['identifier'])); $queries[] = $query = $this->db->UPDATEquery('sys_file', 'uid=' . $file['uid'], array('folder_hash' => $folderHash)); $this->db->sql_query($query); } } else { // manually hash the identifiers when using DBAL $files = $this->db->exec_SELECTgetRows('uid, storage, identifier', 'sys_file', sprintf('storage=%d AND identifier_hash=""', $storage->getUid())); foreach ($files as $file) { $hash = $storage->hashFileIdentifier($file['identifier']); $folderHash = $storage->hashFileIdentifier($storage->getFolderIdentifierFromFileIdentifier($file['identifier'])); $queries[] = $query = $this->db->UPDATEquery('sys_file', 'uid=' . $file['uid'], array('identifier_hash' => $hash, 'folder_hash' => $folderHash)); $this->db->sql_query($query); } } return $queries; }
/** * Open a (persistent) connection to a MySQL server * * @return bool|void * * @throws \RuntimeException Thrown in parent if php ext mysqli is not loaded. * @throws MigrationException If something went wrong during migration */ public function sql_pconnect() { $link = parent::sql_pconnect(); $this->initializeMediator(); $this->mediator->negotiate(); return $link; }
/** * @test */ public function addDataThrowsExceptionIfDatabaseFetchingReturnsInvalidRowResultData() { $input = ['tableName' => 'tt_content', 'command' => 'edit', 'vanillaUid' => 10]; $this->dbProphecy->quoteStr(Argument::cetera())->willReturn($input['tableName']); $this->dbProphecy->exec_SELECTgetSingleRow(Argument::cetera())->willReturn('invalid result data'); $this->setExpectedException(\UnexpectedValueException::class, '', 1437656323); $this->subject->addData($input); }
/** * Relative filemounts are transformed to relate to our fileadmin/ storage * and their path is modified to be a valid resource location * * @return void */ protected function migrateRelativeFilemounts() { $relativeFilemounts = $this->db->exec_SELECTgetRows('*', 'sys_filemounts', 'base = 1' . BackendUtility::deleteClause('sys_filemounts')); foreach ($relativeFilemounts as $filemount) { $this->db->exec_UPDATEquery('sys_filemounts', 'uid=' . (int) $filemount['uid'], array('base' => $this->storage->getUid(), 'path' => '/' . ltrim($filemount['path'], '/'))); $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery; } }
/** * Checks if there are SQL errors in the last query, and if yes, throw an exception. * * @return void * @param string $sql The SQL statement * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException */ protected function checkSqlErrors($sql = '') { $error = $this->databaseHandle->sql_error(); if ($error !== '') { $error .= $sql ? ': ' . $sql : ''; throw new \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException($error, 1247602160); } }
/** * Remove dummy record and drop field * * @return void */ private function dropDummyField() { $sql = 'ALTER TABLE %s DROP COLUMN is_dummy_record'; foreach ($this->tables as $table) { $_sql = sprintf($sql, $table); $this->database->sql_query($_sql); } }
/** * @test */ public function deleteMethodCallsExpectedDatabaseMethodWithRecord() { $table = 'test'; $uid = 123; $record = array('uid' => 123); $mock = $this->getMockServiceInstance(array(), array('exec_DELETEquery')); self::$connectionMock->expects($this->once())->method('exec_DELETEquery')->with($table, "uid = '" . $uid . "'"); $mock->delete($table, $record); }
/** * @test */ public function addDataSetsParentPageRowOnParentIfCommandIsEdit() { $input = ['tableName' => 'tt_content', 'command' => 'edit', 'vanillaUid' => 123, 'databaseRow' => ['uid' => 123, 'pid' => 321]]; $parentPageRow = ['uid' => 321, 'pid' => 456]; $this->dbProphecy->quoteStr(Argument::cetera())->willReturnArgument(0); $this->dbProphecy->exec_SELECTgetSingleRow('*', 'pages', 'uid=321')->willReturn($parentPageRow); $result = $this->subject->addData($input); $this->assertSame($parentPageRow, $result['parentPageRow']); }
/** * @test */ public function truncate_multiple_tables_when_configured() { $configuration = ['truncate' => ['test', 'test2', 'test3']]; $processor = $this->getMockBuilder(Configuration::class)->disableOriginalConstructor()->getMock(); $this->connection->expects($this->exactly(3))->method('exec_TRUNCATEquery')->withConsecutive(['test'], ['test2'], ['test3']); $this->fixture->execute($processor, $configuration); }