sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
protected function addToDummyFileList($uniqueFileName)
{
$relativeFileName = $this->getPathRelativeToUploadDirectory($uniqueFileName);
$this->dummyFiles[$relativeFileName] = $relativeFileName;
} | Adds a file name to $this->dummyFiles.
@param string $uniqueFileName
file name to add, must be the unique name of a dummy file, must
not be empty
@return void | entailment |
public function deleteDummyFile($fileName)
{
$absolutePathToFile = $this->getUploadFolderPath() . $fileName;
$fileExists = file_exists($absolutePathToFile);
if (!isset($this->dummyFiles[$fileName])) {
throw new \InvalidArgumentException(
'The file "' . $absolutePathToFile . '" which you are trying to delete ' .
(!$fileExists ? 'does not exist and has never been ' : 'was not ') .
'created by this instance of the testing framework.',
1334439315
);
}
if ($fileExists && !unlink($absolutePathToFile)) {
throw new Exception('The file "' . $absolutePathToFile . '" could not be deleted.', 1334439327);
}
unset($this->dummyFiles[$fileName]);
} | Deletes the dummy file specified by the first parameter $fileName.
@param string $fileName
the path to the file to delete relative to
$this->uploadFolderPath, must not be empty
@return void
@throws \InvalidArgumentException
@throws Exception | entailment |
public function createDummyFolder($folderName)
{
$this->createDummyUploadFolder();
$uniqueFolderName = $this->getUniqueFileOrFolderPath($folderName);
if (!GeneralUtility::mkdir($uniqueFolderName)) {
throw new Exception('The folder ' . $uniqueFolderName . ' could not be created.', 1334439333);
}
$relativeUniqueFolderName = $this->getPathRelativeToUploadDirectory($uniqueFolderName);
// Adds the created dummy folder to the top of $this->dummyFolders so
// it gets deleted before previously created folders through
// $this->cleanUpFolders(). This is needed for nested dummy folders.
$this->dummyFolders = [$relativeUniqueFolderName => $relativeUniqueFolderName] + $this->dummyFolders;
return $uniqueFolderName;
} | Creates a dummy folder with a unique folder name in the calling
extension's upload directory.
@param string $folderName
name of the dummy folder to create relative to
$this->uploadFolderPath, must not be empty
@return string
the absolute path of the created dummy folder, will not be empty
@throws Exception | entailment |
public function deleteDummyFolder($folderName)
{
$absolutePathToFolder = $this->getUploadFolderPath() . $folderName;
if (!is_dir($absolutePathToFolder)) {
throw new \InvalidArgumentException(
'The folder "' . $absolutePathToFolder . '" which you are trying to delete does not exist.',
1334439343
);
}
if (!isset($this->dummyFolders[$folderName])) {
throw new \InvalidArgumentException(
'The folder "' . $absolutePathToFolder
. '" which you are trying to delete was not created by this instance of ' .
'the testing framework.',
1334439387
);
}
if (!GeneralUtility::rmdir($absolutePathToFolder)) {
throw new Exception('The folder "' . $absolutePathToFolder . '" could not be deleted.', 1334439393);
}
unset($this->dummyFolders[$folderName]);
} | Deletes the dummy folder specified in the first parameter $folderName.
The folder must be empty (no files or subfolders).
@param string $folderName
the path to the folder to delete relative to
$this->uploadFolderPath, must not be empty
@return void
@throws \InvalidArgumentException
@throws Exception | entailment |
protected function createDummyUploadFolder()
{
$uploadFolderPath = $this->getUploadFolderPath();
if (is_dir($uploadFolderPath)) {
return;
}
$creationSuccessful = GeneralUtility::mkdir($uploadFolderPath);
if (!$creationSuccessful) {
throw new \RuntimeException(
'The upload folder ' . $uploadFolderPath . ' could not be created.',
1334439408
);
}
$this->dummyFolders['uploadFolder'] = $uploadFolderPath;
} | Creates the upload folder if it does not exist yet.
@return void
@throws \RuntimeException | entailment |
public function setUploadFolderPath($absolutePath)
{
if (!empty($this->dummyFiles) || !empty($this->dummyFolders)) {
throw new Exception(
'The upload folder path must not be changed if there are already dummy files or folders.',
1334439424
);
}
$this->uploadFolderPath = $absolutePath;
} | Sets the upload folder path.
@param string $absolutePath
absolute path to the folder where to work on during the tests, can
be either an existing folder which will be cleaned up after the
tests or a path of a folder to be created as soon as it is needed
and deleted during cleanUp, must end with a trailing slash
@return void
@throws Exception
if there are dummy files within the current upload folder as
these files could not be deleted if the upload folder path has
changed | entailment |
public function getPathRelativeToUploadDirectory($absolutePath)
{
if (!preg_match(
'/^' . str_replace('/', '\\/', $this->getUploadFolderPath()) . '.*$/',
$absolutePath
)
) {
throw new \InvalidArgumentException(
'The first parameter $absolutePath is not within the calling extension\'s upload directory.',
1334439445
);
}
$encoding = mb_detect_encoding($this->getUploadFolderPath());
$uploadFolderPathLength = mb_strlen($this->getUploadFolderPath(), $encoding);
$absolutePathLength = mb_strlen($absolutePath, $encoding);
return mb_substr($absolutePath, $uploadFolderPathLength, $absolutePathLength, $encoding);
} | Returns the path relative to the calling extension's upload directory for
a path given in the first parameter $absolutePath.
throws \InvalidArgumentException if the first parameter $absolutePath is not within
the calling extension's upload directory
@param string $absolutePath
the absolute path to process, must be within the calling extension's upload directory, must not be empty
@return string the path relative to the calling extension's upload directory
@throws \InvalidArgumentException | entailment |
public function getUniqueFileOrFolderPath($path)
{
if ($path === '') {
throw new \InvalidArgumentException('The first parameter $path must not be empty.', 1476054696353);
}
$pathInformation = pathinfo($path);
$fileNameWithoutExtension = $pathInformation['filename'];
if ($pathInformation['dirname'] !== '.') {
$absoluteDirectoryWithTrailingSlash = $this->getUploadFolderPath() . $pathInformation['dirname'] . '/';
} else {
$absoluteDirectoryWithTrailingSlash = $this->getUploadFolderPath();
}
$extension = isset($pathInformation['extension']) ? ('.' . $pathInformation['extension']) : '';
$suffixCounter = 0;
do {
$suffix = ($suffixCounter > 0) ? ('-' . $suffixCounter) : '';
$newPath = $absoluteDirectoryWithTrailingSlash . $fileNameWithoutExtension . $suffix . $extension;
$suffixCounter++;
} while (is_file($newPath));
return $newPath;
} | Returns a unique absolute path of a file or folder.
@param string $path the path of a file or folder relative to the calling extension's upload directory,
must not be empty
@return string the unique absolute path of a file or folder
@throws \InvalidArgumentException | entailment |
public function createFakeFrontEnd($pageUid = 0)
{
if ($pageUid < 0) {
throw new \InvalidArgumentException('$pageUid must be >= 0.', 1334439467);
}
$this->suppressFrontEndCookies();
$this->discardFakeFrontEnd();
$this->registerNullPageCache();
if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) <= 8000000) {
$GLOBALS['TT'] = GeneralUtility::makeInstance(NullTimeTracker::class);
} else {
$GLOBALS['TT'] = GeneralUtility::makeInstance(TimeTracker::class, false);
}
/** @var TypoScriptFrontendController $frontEnd */
$frontEnd =
GeneralUtility::makeInstance(TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], $pageUid, 0);
$GLOBALS['TSFE'] = $frontEnd;
// simulates a normal FE without any logged-in FE or BE user
$frontEnd->beUserLogin = false;
$frontEnd->workspacePreview = '';
$frontEnd->initFEuser();
$frontEnd->determineId();
$frontEnd->initTemplate();
$frontEnd->config = [];
if (($pageUid > 0) && in_array('sys_template', $this->dirtySystemTables, true)) {
$frontEnd->tmpl->runThroughTemplates($frontEnd->sys_page->getRootLine($pageUid));
$frontEnd->tmpl->generateConfig();
$frontEnd->tmpl->loaded = 1;
$frontEnd->settingLanguage();
$frontEnd->settingLocale();
}
$frontEnd->newCObj();
$this->hasFakeFrontEnd = true;
$this->logoutFrontEndUser();
return $frontEnd->id;
} | Fakes a TYPO3 front end, using $pageUid as front-end page ID if provided.
If $pageUid is zero, the UID of the start page of the current domain
will be used as page UID.
This function creates $GLOBALS['TSFE'] and $GLOBALS['TT'].
Note: This function does not set TYPO3_MODE to "FE" (because the value of
a constant cannot be changed after it has once been set).
@param int $pageUid
UID of a page record to use, must be >= 0
@return int the UID of the used front-end page, will be > 0
@throws \InvalidArgumentException | entailment |
public function discardFakeFrontEnd()
{
if (!$this->hasFakeFrontEnd()) {
return;
}
$this->logoutFrontEndUser();
$GLOBALS['TSFE'] = null;
$GLOBALS['TT'] = null;
unset(
$GLOBALS['TYPO3_CONF_VARS']['FE']['dontSetCookie'],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FrontendUserAuthentication::class]
);
$this->hasFakeFrontEnd = false;
} | Discards the fake front end.
This function nulls out $GLOBALS['TSFE'] and $GLOBALS['TT']. In addition,
any logged-in front-end user will be logged out.
The page record for the current front end will _not_ be deleted by this
function, though.
If no fake front end has been created, this function does nothing.
@return void | entailment |
public function loginFrontEndUser($userId)
{
if ((int)$userId === 0) {
throw new \InvalidArgumentException('The user ID must be > 0.', 1334439475);
}
if (!$this->hasFakeFrontEnd()) {
throw new Exception('Please create a front end before calling loginFrontEndUser.', 1334439483);
}
if ($this->isLoggedIn()) {
$this->logoutFrontEndUser();
}
$this->suppressFrontEndCookies();
// With current TYPO3 versions we have to ensure an user id
$tempUser = [
$GLOBALS['TSFE']->fe_user->userid_column => $userId,
];
$GLOBALS['TSFE']->fe_user->createUserSession($tempUser);
$GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->getRawUserByUid($userId);
$GLOBALS['TSFE']->fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;
} | Fakes that a front-end user has logged in.
If a front-end user currently is logged in, he/she will be logged out
first.
Note: To set the logged-in users group data properly, the front-end user
and his groups must actually exist in the database.
@param int $userId
UID of the FE user, must not necessarily exist in the database,
must be > 0
@return void
@throws Exception if no front end has been created
@throws \InvalidArgumentException | entailment |
public function logoutFrontEndUser()
{
if (!$this->hasFakeFrontEnd()) {
throw new Exception('Please create a front end before calling logoutFrontEndUser.', 1334439488);
}
if (!$this->isLoggedIn()) {
return;
}
$this->suppressFrontEndCookies();
$GLOBALS['TSFE']->fe_user->logoff();
$GLOBALS['TSFE']->loginUser = 0;
} | Logs out the current front-end user.
If no front-end user is logged in, this function does nothing.
@throws Exception if no front end has been created
@return void | entailment |
public function isLoggedIn()
{
if (!$this->hasFakeFrontEnd()) {
throw new Exception('Please create a front end before calling isLoggedIn.', 1334439494);
}
return isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE'])
&& is_array($GLOBALS['TSFE']->fe_user->user);
} | Checks whether a FE user is logged in.
@throws Exception if no front end has been created
@return bool TRUE if a FE user is logged in, FALSE otherwise | entailment |
protected function createListOfOwnAllowedTables()
{
$this->ownAllowedTables = [];
$allTables = \Tx_Phpunit_Service_Database::getAllTableNames();
$length = strlen($this->tablePrefix);
foreach ($allTables as $currentTable) {
if (substr_compare($this->tablePrefix, $currentTable, 0, $length) === 0) {
$this->ownAllowedTables[] = $currentTable;
}
}
} | Generates a list of allowed tables to which this instance of the testing
framework has access to create/remove test records.
The generated list is based on the list of all tables that TYPO3 can
access (which will be all tables in this database), filtered by prefix of
the extension to test.
The array with the allowed table names is written directly to
$this->ownAllowedTables.
@return void | entailment |
protected function createListOfAdditionalAllowedTables()
{
$allTables = implode(',', \Tx_Phpunit_Service_Database::getAllTableNames());
$additionalTablePrefixes = implode('|', $this->additionalTablePrefixes);
$matches = [];
preg_match_all(
'/((' . $additionalTablePrefixes . ')_[a-z0-9]+[a-z0-9_]*)(,|$)/',
$allTables,
$matches
);
if (isset($matches[1])) {
$this->additionalAllowedTables = $matches[1];
}
} | Generates a list of additional allowed tables to which this instance of
the testing framework has access to create/remove test records.
The generated list is based on the list of all tables that TYPO3 can
access (which will be all tables in this database), filtered by the
prefixes of additional extensions.
The array with the allowed table names is written directly to
$this->additionalAllowedTables.
@return void | entailment |
public function getDummyColumnName($tableName)
{
$result = 'is_dummy_record';
if ($this->isSystemTableNameAllowed($tableName)) {
$result = 'tx_phpunit_' . $result;
} elseif ($this->isAdditionalTableNameAllowed($tableName)) {
$result = $this->tablePrefix . '_' . $result;
}
return $result;
} | Returns the name of the column that marks a record as a dummy record.
On most tables this is "is_dummy_record", but on system tables like
"pages" or "fe_users", the column is called "tx_phpunit_dummy_record".
On additional tables, the column is built using $this->tablePrefix as
prefix e.g. "tx_seminars_is_dummy_record" if $this->tablePrefix =
"tx_seminars".
@param string $tableName
the table name to look up, must not be empty
@return string the name of the column that marks a record as dummy record | entailment |
public function countRecords($tableName, $whereClause = '')
{
if (!$this->isTableNameAllowed($tableName)) {
throw new \InvalidArgumentException(
'The given table name is invalid. This means it is either empty or not in the list of allowed tables.',
1334439501
);
}
$whereForDummyColumn = $this->getDummyColumnName($tableName) . ' = 1';
$compoundWhereClause = ($whereClause !== '')
? '(' . $whereClause . ') AND ' . $whereForDummyColumn : $whereForDummyColumn;
return \Tx_Phpunit_Service_Database::count($tableName, $compoundWhereClause);
} | Counts the dummy records in the table given by the first parameter $tableName
that match a given WHERE clause.
@param string $tableName
the name of the table to query, must not be empty
@param string $whereClause
the WHERE part of the query, may be empty (all records will be
counted in that case)
@return int the number of records that have been found, will be >= 0
@throws \InvalidArgumentException | entailment |
public function resetAutoIncrement($tableName)
{
if (!$this->isTableNameAllowed($tableName)) {
throw new \InvalidArgumentException(
'The given table name is invalid. This means it is either empty or not in the list of allowed tables.',
1334439521
);
}
// Checks whether the current table qualifies for this method. If there
// is no column "uid" that has the "auto_increment" flag set, we should
// not try to reset this inexistent auto increment index to avoid DB
// errors.
if (!Tx_Phpunit_Service_Database::tableHasColumnUid($tableName)) {
return;
}
$newAutoIncrementValue = $this->getMaximumUidFromTable($tableName) + 1;
\Tx_Phpunit_Service_Database::enableQueryLogging();
// Updates the auto increment index for this table. The index will be
// set to one UID above the highest existing UID.
$dbResult = \Tx_Phpunit_Service_Database::getDatabaseConnection()->sql_query(
'ALTER TABLE ' . $tableName . ' AUTO_INCREMENT=' . $newAutoIncrementValue . ';'
);
if ($dbResult === false) {
throw new \Tx_Phpunit_Exception_Database(1334439540);
}
} | Eagerly resets the auto increment value for a given table to the highest
existing UID + 1.
@param string $tableName
the name of the table on which we're going to reset the auto
increment entry, must not be empty
@see resetAutoIncrementLazily
@return void
@throws \InvalidArgumentException
@throws \Tx_Phpunit_Exception_Database | entailment |
public function resetAutoIncrementLazily($tableName)
{
if (!$this->isTableNameAllowed($tableName)) {
throw new \InvalidArgumentException(
'The given table name is invalid. This means it is either empty or not in the list of allowed tables.',
1334439548
);
}
// Checks whether the current table qualifies for this method. If there
// is no column "uid" that has the "auto_increment" flag set, we should
// not try to reset this inexistent auto increment index to avoid
// database errors.
if (!Tx_Phpunit_Service_Database::tableHasColumnUid($tableName)) {
return;
}
if ($this->getAutoIncrement($tableName) > ($this->getMaximumUidFromTable($tableName)
+ $this->resetAutoIncrementThreshold)) {
$this->resetAutoIncrement($tableName);
}
} | Resets the auto increment value for a given table to the highest existing
UID + 1 if the current auto increment value is higher than a certain
threshold over the current maximum UID.
The threshold is 100 by default and can be set using
setResetAutoIncrementThreshold.
@param string $tableName
the name of the table on which we're going to reset the auto
increment entry, must not be empty
@see resetAutoIncrement
@return void
@throws \InvalidArgumentException | entailment |
public function getAutoIncrement($tableName)
{
if (!$this->isTableNameAllowed($tableName)) {
throw new \InvalidArgumentException(
'The given table name is invalid. This means it is either empty or not in the list of allowed tables.',
1334439567
);
}
\Tx_Phpunit_Service_Database::enableQueryLogging();
$dbResult = \Tx_Phpunit_Service_Database::getDatabaseConnection()->sql_query(
'SHOW TABLE STATUS WHERE Name = \'' . $tableName . '\';'
);
if (!$dbResult) {
throw new \Tx_Phpunit_Exception_Database(1334439578);
}
/** @var array $row */
$row = \Tx_Phpunit_Service_Database::getDatabaseConnection()->sql_fetch_assoc($dbResult);
\Tx_Phpunit_Service_Database::getDatabaseConnection()->sql_free_result($dbResult);
$autoIncrement = $row['Auto_increment'];
if ($autoIncrement === null) {
throw new \InvalidArgumentException(
'The given table name is invalid. This means it is either empty or not in the list of allowed tables.',
1334439584
);
}
return (int)$autoIncrement;
} | Reads the current auto increment value for a given table.
This function is only valid for tables that actually have an auto
increment value.
@param string $tableName
the name of the table for which the auto increment value should be
retrieved, must not be empty
@return int
the current auto_increment value of table $tableName, will be > 0
@throws \InvalidArgumentException
@throws \Tx_Phpunit_Exception_Database | entailment |
public function markTableAsDirty($tableNames)
{
foreach (GeneralUtility::trimExplode(',', $tableNames) as $currentTable) {
if ($this->isNoneSystemTableNameAllowed($currentTable)) {
$this->dirtyTables[$currentTable] = $currentTable;
} elseif ($this->isSystemTableNameAllowed($currentTable)) {
$this->dirtySystemTables[$currentTable] = $currentTable;
} else {
throw new \InvalidArgumentException(
'The table name "' . $currentTable . '" is not allowed for markTableAsDirty.',
1334439595
);
}
}
} | Puts one or multiple table names on the list of dirty tables (which
represents a list of tables that were used for testing and contain dummy
records and thus are called "dirty" until the next clean up).
@param string $tableNames
the table name or a comma-separated list of table names to put on
the list of dirty tables, must not be empty
@return void
@throws \InvalidArgumentException | entailment |
public function getRelationSorting($tableName, $uidLocal)
{
if (!$this->relationSorting[$tableName][$uidLocal]) {
$this->relationSorting[$tableName][$uidLocal] = 0;
}
$this->relationSorting[$tableName][$uidLocal]++;
return $this->relationSorting[$tableName][$uidLocal];
} | Returns the next sorting value of the relation table which should be used.
Note: This function does not take already existing relations in the
database (which were created without using the testing framework) into
account. So you always should create new dummy records and create a
relation between these two dummy records, so you're sure there are not
already relations for a local UID in the database.
@param string $tableName
the relation table, must not be empty
@param int $uidLocal
UID of the local table, must be > 0
@return int the next sorting value to use (> 0)
@see https://bugs.oliverklee.com/show_bug.cgi?id=1423 | entailment |
public function increaseRelationCounter($tableName, $uid, $fieldName)
{
if (!$this->isTableNameAllowed($tableName)) {
throw new \InvalidArgumentException(
'The table name "' . $tableName .
'" is invalid. This means it is either empty or not in the list of allowed tables.',
1334439601
);
}
if (!\Tx_Phpunit_Service_Database::tableHasColumn($tableName, $fieldName)) {
throw new \InvalidArgumentException(
'The table ' . $tableName . ' has no column ' . $fieldName . '.',
1334439616
);
}
\Tx_Phpunit_Service_Database::enableQueryLogging();
$dbResult = \Tx_Phpunit_Service_Database::getDatabaseConnection()->sql_query(
'UPDATE ' . $tableName . ' SET ' . $fieldName . '=' . $fieldName . '+1 WHERE uid=' . $uid
);
if (!$dbResult) {
throw new \Tx_Phpunit_Exception_Database(1334439623);
}
if (\Tx_Phpunit_Service_Database::getDatabaseConnection()->sql_affected_rows() === 0) {
throw new \Tx_Phpunit_Exception_Database(1334439632);
}
$this->markTableAsDirty($tableName);
} | Updates an int field of a database table by one. This is mainly needed
for counting up the relation counter when creating a database relation.
The field to update must be of type int.
@param string $tableName
name of the table, must not be empty
@param int $uid
the UID of the record to modify, must be > 0
@param string $fieldName
the field name of the field to modify, must not be empty
@return void
@throws \InvalidArgumentException
@throws \Tx_Phpunit_Exception_Database | entailment |
protected function getHooks()
{
if (!self::$hooksHaveBeenRetrieved) {
$hookClasses = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['phpunit']['FrameworkCleanUp'];
if (is_array($hookClasses)) {
foreach ($hookClasses as $hookClass) {
self::$hooks[] = GeneralUtility::getUserObj($hookClass);
}
}
self::$hooksHaveBeenRetrieved = true;
}
return self::$hooks;
} | Gets all hooks for this class.
@return \Tx_Phpunit_Interface_FrameworkCleanupHook[] the hook objects, will be empty if no hooks have been set | entailment |
public function validate($value, Constraint $constraint)
{
/**@var $constraint CodeUnit */
if (!in_array($value, $this->codes)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $value)
->addViolation();
}
} | Checks if the passed value is valid.
@param mixed $value The value that should be validated
@param Constraint $constraint The constraint for the validation | entailment |
private static function retrievePageForEnableFields()
{
if (!is_object(self::$pageForEnableFields)) {
if (isset($GLOBALS['TSFE'])
&& is_object($GLOBALS['TSFE']->sys_page)
) {
self::$pageForEnableFields = $GLOBALS['TSFE']->sys_page;
} else {
self::$pageForEnableFields = GeneralUtility::makeInstance(PageRepository::class);
}
}
} | Makes sure that self::$pageForEnableFields is a page object.
@return void | entailment |
public static function createRecursivePageList($startPages, $recursionDepth = 0)
{
if ($recursionDepth < 0) {
throw new \InvalidArgumentException('$recursionDepth must be >= 0.', 1331315492);
}
if ($recursionDepth === 0) {
return (string)$startPages;
}
if ($startPages === '') {
return '';
}
$dbResult = self::select(
'uid',
'pages',
'pid IN (' . $startPages . ')' . self::enableFields('pages')
);
$subPages = [];
$databaseConnection = self::getDatabaseConnection();
while (($row = $databaseConnection->sql_fetch_assoc($dbResult))) {
/** @var array $row */
$subPages[] = $row['uid'];
}
$databaseConnection->sql_free_result($dbResult);
if (empty($subPages)) {
$result = $startPages;
} else {
$result = $startPages . ',' . self::createRecursivePageList(implode(',', $subPages), $recursionDepth - 1);
}
return $result;
} | Recursively creates a comma-separated list of subpage UIDs from
a list of pages. The result also includes the original pages.
The maximum level of recursion can be limited:
0 = no recursion (the default value, will return $startPages),
1 = only direct child pages,
...,
250 = all descendants for all sane cases
Note: The returned page list is _not_ sorted.
@param string $startPages
comma-separated list of page UIDs to start from, must only contain
numbers and commas, may be empty
@param int $recursionDepth
maximum depth of recursion, must be >= 0
@return string
comma-separated list of subpage UIDs including the UIDs provided
in $startPages, will be empty if $startPages is empty
@throws \InvalidArgumentException | entailment |
public static function delete($tableName, $whereClause)
{
if ($tableName === '') {
throw new \InvalidArgumentException('The table name must not be empty.', 1331315508);
}
self::enableQueryLogging();
$dbResult = self::getDatabaseConnection()->exec_DELETEquery(
$tableName,
$whereClause
);
if (!$dbResult) {
throw new \Tx_Phpunit_Exception_Database(1334439746);
}
return self::getDatabaseConnection()->sql_affected_rows();
} | Executes a DELETE query.
@param string $tableName
the name of the table from which to delete, must not be empty
@param string $whereClause
the WHERE clause to select the records, may be empty
@return int the number of affected rows, might be 0
@throws \InvalidArgumentException
@throws \Tx_Phpunit_Exception_Database if an error has occurred | entailment |
public static function update($tableName, $whereClause, array $fields)
{
if ($tableName === '') {
throw new \InvalidArgumentException('The table name must not be empty.', 1331315523);
}
self::enableQueryLogging();
$dbResult = self::getDatabaseConnection()->exec_UPDATEquery(
$tableName,
$whereClause,
$fields
);
if (!$dbResult) {
throw new \Tx_Phpunit_Exception_Database(1334439755);
}
return self::getDatabaseConnection()->sql_affected_rows();
} | Executes an UPDATE query.
@param string $tableName
the name of the table to change, must not be empty
@param string $whereClause
the WHERE clause to select the records, may be empty
@param array $fields
key/value pairs of the fields to change, may be empty
@return int the number of affected rows, might be 0
@throws \InvalidArgumentException
@throws \Tx_Phpunit_Exception_Database if an error has occurred | entailment |
public static function insert($tableName, array $recordData)
{
if ($tableName === '') {
throw new \InvalidArgumentException('The table name must not be empty.', 1331315544);
}
if (empty($recordData)) {
throw new \InvalidArgumentException('$recordData must not be empty.', 1331315553);
}
self::enableQueryLogging();
$dbResult = self::getDatabaseConnection()->exec_INSERTquery(
$tableName,
$recordData
);
if (!$dbResult) {
throw new \Tx_Phpunit_Exception_Database(1334439765);
}
return self::getDatabaseConnection()->sql_insert_id();
} | Executes an INSERT query.
@param string $tableName
the name of the table in which the record should be created,
must not be empty
@param array $recordData
key/value pairs of the record to insert, must not be empty
@return int
the UID of the created record, will be 0 if the table has no UID column
@throws \InvalidArgumentException
@throws \Tx_Phpunit_Exception_Database if an error has occurred | entailment |
public static function selectColumnForMultiple(
$fieldName,
$tableNames,
$whereClause = '',
$groupBy = '',
$orderBy = '',
$limit = ''
) {
$rows = self::selectMultiple(
$fieldName,
$tableNames,
$whereClause,
$groupBy,
$orderBy,
$limit
);
$result = [];
foreach ($rows as $row) {
$result[] = $row[$fieldName];
}
return $result;
} | Executes a SELECT query and returns one column from the result rows as a
one-dimensional numeric array.
If there is more than one matching record, only one will be returned.
@param string $fieldName
name of the field to select, must not be empty
@param string $tableNames
comma-separated list of tables from which to select, must not be empty
@param string $whereClause
WHERE clause, may be empty
@param string $groupBy
GROUP BY field(s), may be empty
@param string $orderBy
ORDER BY field(s), may be empty
@param string $limit
LIMIT value ([begin,]max), may be empty
@return string[]
one column from the the query result rows, will be empty if there
are no matching records
@throws \Tx_Phpunit_Exception_Database if an error has occurred | entailment |
public static function count($tableNames, $whereClause = '')
{
$isOnlyOneTable = ((strpos($tableNames, ',') === false)
&& (stripos(trim($tableNames), ' JOIN ') === false));
if ($isOnlyOneTable && self::tableHasColumnUid($tableNames)) {
// Counting only the "uid" column is faster than counting *.
$columns = 'uid';
} else {
$columns = '*';
}
$result = self::selectSingle(
'COUNT(' . $columns . ') AS phpunit_counter',
$tableNames,
$whereClause
);
return (int)$result['phpunit_counter'];
} | Counts the number of matching records in the database for a particular
WHERE clause.
@param string $tableNames
comma-separated list of existing tables from which to count, can
also be a JOIN, must not be empty
@param string $whereClause
WHERE clause, may be empty
@return int the number of matching records, will be >= 0
@throws \Tx_Phpunit_Exception_Database if an error has occurred | entailment |
public static function existsRecordWithUid(
$tableName,
$uid,
$additionalWhereClause = ''
) {
if ($uid <= 0) {
throw new \InvalidArgumentException('$uid must be > 0.', 1331315624);
}
return self::count($tableName, 'uid = ' . $uid . $additionalWhereClause) > 0;
} | Checks whether there is a record in the table given by the first
parameter $tableName that has the given UID.
Important: This function also returns TRUE if there is a deleted or
hidden record with that particular UID.
@param string $tableName
the name of the table to query, must not be empty
@param int $uid
the UID of the record to look up, must be > 0
@param string $additionalWhereClause
additional WHERE clause to append, must either start with " AND"
or be completely empty
@return bool TRUE if there is a matching record, FALSE otherwise
@throws \InvalidArgumentException | entailment |
public static function existsTable($tableName)
{
if ($tableName === '') {
throw new \InvalidArgumentException('The table name must not be empty.', 1331315636);
}
self::retrieveTableNames();
return isset(self::$tableNameCache[$tableName]);
} | Checks whether a database table exists.
@param string $tableName
the name of the table to check for, must not be empty
@return bool TRUE if the table $tableName exists, FALSE otherwise
@throws \InvalidArgumentException | entailment |
public static function getColumnDefinition($tableName, $column)
{
self::retrieveColumnsForTable($tableName);
return self::$tableColumnCache[$tableName][$column];
} | Gets the column definition for a field in $tableName.
@param string $tableName
the name of the table for which the column names should be
retrieved, must not be empty
@param string $column
the name of the field of which to retrieve the definition,
must not be empty
@return array
the field definition for the field in $tableName, will not be empty | entailment |
private static function retrieveColumnsForTable($tableName)
{
if (!isset(self::$tableColumnCache[$tableName])) {
if (!self::existsTable($tableName)) {
throw new \BadMethodCallException('The table "' . $tableName . '" does not exist.', 1331315659);
}
self::$tableColumnCache[$tableName] = self::getDatabaseConnection()->admin_get_fields($tableName);
}
} | Retrieves and caches the column data for the table $tableName.
If the column data for that table already is cached, this function does
nothing.
@param string $tableName
the name of the table for which the column names should be
retrieved, must not be empty
@return void
@throws \BadMethodCallException | entailment |
public static function tableHasColumn($tableName, $column)
{
if ($column === '') {
return false;
}
self::retrieveColumnsForTable($tableName);
return isset(self::$tableColumnCache[$tableName][$column]);
} | Checks whether a table has a column with a particular name.
To get a boolean TRUE as result, the table must contain a column with the
given name.
@param string $tableName
the name of the table to check, must not be empty
@param string $column
the column name to check, must not be empty
@return bool
TRUE if the column with the provided name exists, FALSE otherwise | entailment |
public static function getTcaForTable($tableName)
{
if (isset(self::$tcaCache[$tableName])) {
return self::$tcaCache[$tableName];
}
if (!self::existsTable($tableName)) {
throw new \BadMethodCallException('The table "' . $tableName . '" does not exist.', 1331315679);
}
if (!isset($GLOBALS['TCA'][$tableName])) {
throw new \BadMethodCallException('The table "' . $tableName . '" has no TCA.', 1331315694);
}
self::$tcaCache[$tableName] = $GLOBALS['TCA'][$tableName];
return self::$tcaCache[$tableName];
} | Returns the TCA for a certain table.
@param string $tableName
the table name to look up, must not be empty
@return array[] associative array with the TCA description for this table
@throws \BadMethodCallException | entailment |
public function getGroupMembers($groupId, array $filters = [])
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('groups/%d/members', $groupId), [
'query' => $filters
])
);
} | getGroupMembers - Gets members associated for a specific group
@param int $groupId - The ID of the group to get information on
@param array $filters - Available filters: page, per_page
@return @see Client::sendRequest | entailment |
public function getGroupMember($groupId, $memberId)
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('groups/%d/members/%d', $groupId, $memberId))
);
} | getGroupMembers - Gets a specific member information for a specific group
@param int $groupId - The ID of the group to get information on
@param int $memberId - The ID of the member in the group to get information on
@return @see Client::sendRequest | entailment |
public function render()
{
$content = $this->renderForm($this->renderSelect());
$this->outputService->output($content);
} | Renders the content of the view helper and pushes it to the output service.
@return void | entailment |
protected function renderForm($formContent)
{
$formContentWithAdditionalElements = $formContent .
$this->renderHiddenFields() . $this->renderSubmitButton($this->translate('run_all_tests'));
$formContentWithinParagraph = $this->renderTag('p', [], $formContentWithAdditionalElements);
return $this->renderTag(
'form',
[
'action' => $this->action,
'method' => 'post',
],
$formContentWithinParagraph
);
} | Renders the form with submit button around some content.
@param string $formContent
@return string the final form | entailment |
protected function renderSelect()
{
$options = $this->getOptions();
$selectedExtensionStyle = '';
$renderedOptionTags = [];
foreach ($options as $option) {
if (isset($option['selected']) && $option['selected'] === 'selected') {
$selectedExtensionStyle = $option['style'];
}
if ($option['value'] === \Tx_Phpunit_Testable::ALL_EXTENSIONS) {
$optionValue = $this->translate('all_extensions');
} else {
$optionValue = $option['value'];
}
$renderedOptionTags[] = $this->renderTag('option', $option, $optionValue);
}
return $this->renderTag(
'select',
[
'name' => \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
'[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']',
'onchange' => 'document.location = \'' . $this->action . '&' .
\Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
'[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']=' .
'\'+this.options[this.selectedIndex].value;',
'style' => $selectedExtensionStyle,
],
implode(LF, $renderedOptionTags)
);
} | Renders the select box as HTML.
@return string the rendered select tag | entailment |
protected function getOptions()
{
$options = [];
$allExtensionOption = [
'class' => 'alltests',
'value' => \Tx_Phpunit_Testable::ALL_EXTENSIONS,
];
if ($this->isOptionSelected(\Tx_Phpunit_Testable::ALL_EXTENSIONS)) {
$allExtensionOption['selected'] = 'selected';
}
$options[] = $allExtensionOption;
/** @var \Tx_Phpunit_Testable $testable */
foreach ($this->testFinder->getTestablesForEverything() as $testable) {
$extensionOption = [
'style' => $this->createIconStyle($testable->getKey()),
'value' => $testable->getKey(),
];
if ($this->isOptionSelected($testable->getKey())) {
$extensionOption['selected'] = 'selected';
}
$options[] = $extensionOption;
}
return $options;
} | Gets all options rendered as an array
@return array[] all options, will not be empty | entailment |
public function cache($key, callable $cachedCallable, $ttl, callable $onNoStaleCacheCallable = null)
{
$value = $this->getValue($key);
if ($value->hasResult() && !$value->isStale()) {
return $value->getResult();
}
if (!($ttl instanceof Ttl)) {
$ttl = new Ttl($ttl);
}
$lock_acquired = $this->lockManager->acquire($key, $ttl->getLockTtl());
if (!$lock_acquired) {
if ($value->hasResult()) { // serve stale if present
return $value->getResult();
}
if (!$onNoStaleCacheCallable) {
$onNoStaleCacheCallable = $this->onNoStaleCacheCallable;
}
if ($onNoStaleCacheCallable !== null) {
$event = new NoStaleCacheEvent($this, $key, $cachedCallable, $ttl);
call_user_func($onNoStaleCacheCallable, $event);
if ($event->hasResult()) {
return $event->getResult();
}
}
}
$result = call_user_func($cachedCallable);
$this->setResult($key, $result, $ttl);
if ($lock_acquired) {
$this->lockManager->release($key);
}
return $result;
} | Caches specified closure/method/function for specified time.
As a third argument - instead of integer - you can pass Ttt object to
define grace tll and lock ttl (both optional).
@param string
@param callable
@param int|\Metaphore\Ttl
@param callable | entailment |
public function setResult($key, $result, $ttl)
{
if (!($ttl instanceof Ttl)) {
$ttl = new Ttl($ttl);
}
$expirationTimestamp = time() + $ttl->getTtl();
$value = new Value($result, $expirationTimestamp);
$this->valueStore->set($key, $value, $ttl->getRealTtl());
} | Sets result. Does not use anti-dogpile-effect mechanism. Use cache() instead for this.
@param string
@param mixed
@param int|\Metaphore\Ttl | entailment |
public function getCollectorsForSurvey($surveyId, array $filters = [])
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('surveys/%s/collectors', $surveyId), [
'query' => $filters
])
);
} | getCollectorsForSurvey
@param int $surveyId
@param array $filters - Available filters: page, per_page, sort_by, sort_order, name, start_date, end_date, include
@return @see Client::sendRequest | entailment |
public function createCollectorForSurvey($surveyId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('POST', sprintf('surveys/%s/collectors', $surveyId), [], $data)
);
} | createCollectorForSurvey
@param int $surveyId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function updateCollector($collectorId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('PATCH', sprintf('collectors/%s', $collectorId), [], $data)
);
} | updateCollector
@param int $collectorId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function replaceCollector($collectorId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('PUT', sprintf('collectors/%s', $collectorId), [], $data)
);
} | replaceCollector
@param int $collectorId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function getCollectorMessages($collectorId, array $filters = [])
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('collectors/%s/messages', $collectorId), [
'query' => $filters
])
);
} | getCollectorMessages
@param int $collectorId
@param array $filters - Available filters: page, per_page
@return @see Client::sendRequest | entailment |
public function createCollectorMessage($collectorId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('POST', sprintf('collectors/%s/messages', $collectorId), [], $data)
);
} | createCollectorMessage
@param int $collectorId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function copyCollectorMessage($collectorId, $fromCollectorId, $fromMessageId, $includeRecipients = false)
{
return $this->sendRequest(
$this->createRequest('POST', sprintf('collectors/%s/messages', $collectorId), [
'query' => [
'from_collector_id' => $fromCollectorId,
'from_message_id' => $fromMessageId,
'include_recipients' => (bool)$includeRecipients,
]
])
);
} | copyCollectorMessage
@param int $fromCollectorId
@param int $fromMessageId
@param bool $includeRecipients
@return @see Client::sendRequest | entailment |
public function getCollectorMessage($collectorId, $messageId)
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('collectors/%s/messages/%s', $collectorId, $messageId))
);
} | getCollectorMessage
@param int $collectorId
@param int $messageId
@return @see Client::sendRequest | entailment |
public function updateCollectorMessage($collectorId, $messageId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('PATCH', sprintf('collectors/%s/messages/%s', $collectorId, $messageId), [], $data)
);
} | updateCollectorMessage
@param int $collectorId
@param int $messageId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function replaceCollectorMessage($collectorId, $messageId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('PUT', sprintf('collectors/%s/messages/%s', $collectorId, $messageId), [], $data)
);
} | replaceCollectorMessage
@param int $collectorId
@param int $messageId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function deleteCollectorMessage($collectorId, $messageId)
{
return $this->sendRequest(
$this->createRequest('DELETE', sprintf('collectors/%s/messages/%s', $collectorId, $messageId))
);
} | deleteCollectorMessage
@param int $collectorId
@param int $messageId
@return @see Client::sendRequest | entailment |
public function sendCollectorMessage($collectorId, $messageId, \DateTime $scheduledDate = null)
{
$data = $scheduledDate ? [ 'scheduled_date' => $scheduledDate->format(DATE_ATOM) ] : [];
return $this->sendRequest(
$this->createRequest('POST', sprintf('collectors/%s/messages/%s/send', $collectorId, $messageId), [], $data)
);
} | sendCollectorMessage
@param int $collectorId
@param int $messageId
@param DateTime|null $scheduledDate
@return @see Client::sendRequest | entailment |
public function getCollectorMessageRecipients($collectorId, $messageId, array $filters = [])
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('collectors/%s/messages/%s/recipients', $collectorId, $messageId), [
'query' => $filters
])
);
} | getCollectorMessageRecipients
@param int $collectorId
@param int $messageId
@param array $filters - Available filters: page, per_page
@return @see Client::sendRequest | entailment |
public function createCollectorMessageRecipient($collectorId, $messageId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('POST', sprintf('collectors/%s/messages/%s/recipients', $collectorId, $messageId), [], $data)
);
} | createCollectorMessageRecipient
@param int $collectorId
@param int $messageId
@param array $data - See API docs for available fields
@link https://developer.surveymonkey.com/api/v3/#collectors-id-messages-id-recipients Documentation for creating recipient
@return @see Client::sendRequest | entailment |
public function createCollectorMessageRecipientBulk($collectorId, $messageId, $data = [])
{
return $this->sendRequest(
$this->createRequest('POST', sprintf('collectors/%s/messages/%s/recipients/bulk', $collectorId, $messageId), [], $data)
);
} | createCollectorMessageRecipientBulk
@param int $collectorId
@param int $messageId
@param array $data - See API docs for available fields
@link https://developer.surveymonkey.net/api/v3/#collectors-id-messages-id-recipients-bulk Documentation for creating recipients in bulk
@return @see Client::sendRequest | entailment |
public function getCollectorRecipients($collectorId, array $filters = [])
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('collectors/%s/recipients', $collectorId), [
'query' => $filters
])
);
} | getCollectorRecipients
@param int $collectorId
@param array $filters - Available filters: page, per_page
@return @see Client::sendRequest | entailment |
public function getCollectorRecipient($collectorId, $recipientId)
{
return $this->sendRequest(
$this->createRequest('GET', sprintf('collectors/%s/recipients/%s', $collectorId, $recipientId))
);
} | getCollectorRecipient
@param int $collectorId
@param int $recipientId
@return @see Client::sendRequest | entailment |
public function deleteCollectorRecipient($collectorId, $recipientId)
{
return $this->sendRequest(
$this->createRequest('DELETE', sprintf('collectors/%s/recipients/%s', $collectorId, $recipientId))
);
} | deleteCollectorRecipient
@param int $collectorId
@param int $recipientId
@return @see Client::sendRequest | entailment |
protected function getField($key)
{
return !empty($this->response[$key]) ? $this->response[$key] : null;
} | Helper for getting user data
@param string $key
@return mixed|null | entailment |
public function setObject(WeavedInterface $object, \ReflectionMethod $method)
{
$this->object = $object;
$this->method = $method->name;
} | Set dependencies | entailment |
public function getAnnotations() : array
{
/** @var AbstractWeave $object */
$object = $this->object;
$annotations = unserialize($object->methodAnnotations);
if (array_key_exists($this->method, $annotations)) {
return $annotations[$this->method];
}
return [];
} | {@inheritdoc} | entailment |
public function getAnnotation(string $annotationName)
{
$annotations = $this->getAnnotations();
foreach ($annotations as $annotation) {
if ($annotation instanceof $annotationName) {
return $annotation;
}
}
} | {@inheritdoc} | entailment |
public function matchesClass(\ReflectionClass $class, array $arguments) : bool
{
list($startsWith) = $arguments;
return strpos($class->name, $startsWith) === 0;
} | {@inheritdoc} | entailment |
public function matchesMethod(\ReflectionMethod $method, array $arguments) : bool
{
list($startsWith) = $arguments;
return strpos($method->name, $startsWith) === 0;
} | {@inheritdoc} | entailment |
public function render()
{
$attributes = array_merge(
$this->additionalAttributes,
[
'type' => $this->type,
'value' => $this->value,
]
);
return $this->renderTag(
$this->tagName,
$attributes
);
} | Renders the input field with the set attributes and value
@return string | entailment |
public function annotatedWith($annotationName) : AbstractMatcher
{
if (! class_exists($annotationName)) {
throw new InvalidAnnotationException($annotationName);
}
return new AnnotatedMatcher(__FUNCTION__, [$annotationName]);
} | {@inheritdoc}
@throws \ReflectionException | entailment |
public function subclassesOf($superClass) : AbstractMatcher
{
if (! class_exists($superClass)) {
throw new InvalidArgumentException($superClass);
}
return new BuiltinMatcher(__FUNCTION__, [$superClass]);
} | {@inheritdoc}
@throws \ReflectionException | entailment |
public function matchesMethod(\ReflectionMethod $method, array $arguments) : bool
{
return $this->matcher->matchesMethod($method, $arguments);
} | {@inheritdoc} | entailment |
public function ajaxBroker(array $unused, AjaxRequestHandler $ajax)
{
$state = (bool)GeneralUtility::_POST('state');
$checkbox = GeneralUtility::_POST('checkbox');
if (in_array($checkbox, $this->validCheckboxKeys, true)) {
$ajax->setContentFormat('json');
$this->userSettingsService->set($checkbox, $state);
$ajax->addContent('success', true);
} else {
$ajax->setContentFormat('plain');
$ajax->setError('Illegal input parameters.');
}
} | Used to broker incoming requests to other calls.
Called by typo3/ajax.php
@param array $unused additional parameters (not used)
@param AjaxRequestHandler $ajax the AJAX object for this request
@return void | entailment |
public function matchesMethod(\ReflectionMethod $method, array $arguments) : bool
{
unset($arguments);
return ! ($this->isMagicMethod($method->name) || $this->isBuiltinMethod($method->name));
} | {@inheritdoc} | entailment |
public function set($key, $value, $ttl)
{
$fileName = $this->getFileName($key);
$data = $this->prepareTtl($ttl).'|'.serialize($value);
return file_put_contents($fileName, $data);
} | {@inheritdoc} | entailment |
public function get($key)
{
$fileName = $this->getFileName($key);
if (!file_exists($fileName)) {
return false;
}
$data = file_get_contents($fileName);
list($ttl, $serializedValue) = explode('|', $data, 2);
if ($ttl < time()) {
return false;
}
return unserialize($serializedValue);
} | {@inheritdoc} | entailment |
public function add($key, $value, $ttl)
{
if ($this->get($key) !== false) {
return false;
}
return $this->set($key, $value, $ttl);
} | {@inheritdoc} | entailment |
public function getMidSummerDay($year, $timezone)
{
$date = new \DateTime($year.'-06-20', $timezone);
for ($i = 0; $i < 7; $i++) {
if ($date->format('w') == 6) {
break;
}
$date->add(new \DateInterval('P1D'));
}
return $date;
} | the Swedish midsummer day is the saturday between 20 and 26:th of June | entailment |
public function dump(string $string): void
{
if ($this->handle === null) {
$this->openFile();
}
fwrite($this->handle, $string);
} | {@inheritdoc} | entailment |
private function clearHandle(): void
{
if ($this->handle !== null) {
fclose($this->handle);
$this->handle = null;
}
} | {@inheritdoc} | entailment |
public function main()
{
LibraryLoader::includeAll();
$this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
$this->doc->backPath = $GLOBALS['BACK_PATH'];
if ($GLOBALS['BE_USER']->user['admin']) {
$this->doc->bodyTagAdditions = 'id="doc3"';
$this->addAdditionalHeaderData();
$this->cleanOutputBuffers();
$this->outputService->output(
$this->doc->startPage($this->translate('title')) .
$this->doc->header(\PHPUnit_Runner_Version::getVersionString())
);
$this->renderRunTests();
$this->outputService->output(
$this->doc->section(
$this->translate('shortcuts.title'),
'<p>' . $this->translate('shortcuts.text') . '</p>
<p>' . $this->translate('shortcuts.browser_dependency') . '</p>
<ul>
<li>' . $this->translate('shortcuts.browser_safari_ie') . '</li>
<li>' . $this->translate('shortcuts.browser_firefox') . '</li>
</ul>'
)
);
} else {
$this->outputService->output(
$this->doc->startPage($this->translate('title')) .
$this->doc->header($this->translate('title')) .
$this->translate('admin_rights_needed')
);
}
$this->outputService->output($this->doc->endPage());
} | Main function of the module. Outputs all content directly instead of collecting it and doing the output later.
@return void | entailment |
protected function addAdditionalHeaderData()
{
/** @var PageRenderer $pageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadJquery();
$publicResourcesPath = $this->extensionPath . 'Resources/Public/';
$pageRenderer->addJsFile($publicResourcesPath . 'JavaScript/BackEnd.js', 'text/javascript', false);
$pageRenderer->addCssFile($publicResourcesPath . 'CSS/BackEnd.css', 'stylesheet', 'all', '', false);
} | Adds some JavaScript and CSS stuff to header data.
@return void | entailment |
protected function createExtensionSelector()
{
$this->getAndSaveSelectedTestableKey();
/** @var \Tx_Phpunit_ViewHelpers_ExtensionSelectorViewHelper $extensionSelectorViewHelper */
$extensionSelectorViewHelper =
GeneralUtility::makeInstance(\Tx_Phpunit_ViewHelpers_ExtensionSelectorViewHelper::class);
$extensionSelectorViewHelper->injectOutputService($this->outputService);
$extensionSelectorViewHelper->injectUserSettingService($this->userSettingsService);
$extensionSelectorViewHelper->injectTestFinder($this->testFinder);
$extensionSelectorViewHelper->setAction(BackendUtility::getModuleUrl('tools_txphpunitbeM1'));
$extensionSelectorViewHelper->render();
} | Creates the extension drop-down.
@return void | entailment |
protected function createCheckboxes()
{
$output =
'<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tools_txphpunitbeM1'))
. '" method="post">';
$output .= '<div class="phpunit-controls">';
$failureState = $this->userSettingsService->getAsBoolean('failure') ? 'checked="checked"' : '';
$errorState = $this->userSettingsService->getAsBoolean('error') ? 'checked="checked"' : '';
$skippedState = $this->userSettingsService->getAsBoolean('skipped') ? 'checked="checked"' : '';
$successState = $this->userSettingsService->getAsBoolean('success') ? 'checked="checked"' : '';
$incompleteState = $this->userSettingsService->getAsBoolean('incomplete') ? 'checked="checked"' : '';
$showTime = $this->userSettingsService->getAsBoolean('showTime') ? 'checked="checked"' : '';
$testdoxState = $this->userSettingsService->getAsBoolean('testdox') ? 'checked="checked"' : '';
$output .= '<input type="checkbox" id="SET_success" ' . $successState . ' /><label for="SET_success">'
. $this->translate('success') . '</label>';
$output .= ' <input type="checkbox" id="SET_failure" ' . $failureState . ' /><label for="SET_failure">'
. $this->translate('failure') . '</label>';
$output .= ' <input type="checkbox" id="SET_skipped" ' . $skippedState . ' /><label for="SET_skipped">'
. $this->translate('skipped') . '</label>';
$output .= ' <input type="checkbox" id="SET_error" ' . $errorState . ' /><label for="SET_error">'
. $this->translate('error') . '</label>';
$output .= ' <input type="checkbox" id="SET_testdox" ' . $testdoxState .
' /><label for="SET_testdox">' . $this->translate('show_as_human_readable') . '</label>';
$output .= ' <input type="checkbox" id="SET_incomplete" ' . $incompleteState .
' /><label for="SET_incomplete">' . $this->translate('incomplete') . '</label>';
$output .= ' <input type="checkbox" id="SET_showTime" ' . $showTime .
'/><label for="SET_showTime">' . $this->translate('show_time') . '</label>';
$codecoverageDisable = '';
$codecoverageForLabelWhenDisabled = '';
if (!extension_loaded('xdebug')) {
$codecoverageDisable = ' disabled="disabled"';
$codecoverageForLabelWhenDisabled = ' title="' . $this->translate('code_coverage_requires_xdebug') . '"';
}
$codeCoverageState = $this->userSettingsService->getAsBoolean('codeCoverage') ? 'checked="checked"' : '';
$output .= ' <input type="checkbox" id="SET_codeCoverage" ' . $codecoverageDisable . ' ' . $codeCoverageState .
' /><label for="SET_codeCoverage"' . $codecoverageForLabelWhenDisabled .
'>' . $this->translate('collect_code_coverage_data') . '</label>';
$runSeleniumTests = $this->userSettingsService->getAsBoolean('runSeleniumTests') ? 'checked="checked"' : '';
$output .= ' <input type="checkbox" id="SET_runSeleniumTests" ' . $runSeleniumTests
. '/><label for="SET_runSeleniumTests">' . $this->translate('run_selenium_tests') . '</label>';
$output .= '</div>';
$output .= '</form>';
return $output;
} | Renders the checkboxes for hiding or showing various test results.
@return string
HTML code with checkboxes and a surrounding form | entailment |
protected function renderReRunButton()
{
$this->outputService->output(
'<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tools_txphpunitbeM1')) . '" method="post">
<p>
<button type="submit" name="' . \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE . ' [' .
\Tx_Phpunit_Interface_Request::PARAMETER_KEY_EXECUTE . ']" value="run" accesskey="r">' .
$this->translate('run_again') . '</button>
<input name="' . \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE . '[' .
\Tx_Phpunit_Interface_Request::PARAMETER_KEY_COMMAND . ']" type="hidden" value="' .
htmlspecialchars($this->request->getAsString(\Tx_Phpunit_Interface_Request::PARAMETER_KEY_COMMAND)) . '" />
<input name="' . \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE . '[' .
\Tx_Phpunit_Interface_Request::PARAMETER_KEY_TEST . ']" type="hidden" value="' .
htmlspecialchars($this->request->getAsString(\Tx_Phpunit_Interface_Request::PARAMETER_KEY_TEST)) . '" />
<input name="' . \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE . '[' .
\Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTCASE . ']" type="hidden" value="' .
htmlspecialchars($this->request->getAsString(\Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTCASE)) . '" />
</p>
</form>'
);
} | Renders and output the re-run button.
@return void | entailment |
protected function renderCodeCoverage()
{
$this->coverage->stop();
$codeCoverageDirectory = PATH_site . 'typo3temp/codecoverage/';
if (!is_readable($codeCoverageDirectory) && !is_dir($codeCoverageDirectory)) {
GeneralUtility::mkdir($codeCoverageDirectory);
}
$coverageReport = new PHP_CodeCoverage_Report_HTML();
$coverageReport->process($this->coverage, $codeCoverageDirectory);
$this->outputService->output(
'<p><a target="_blank" href="../typo3temp/codecoverage/index.html">' .
'Click here to access the Code Coverage report</a></p>' .
'<p>Memory peak usage: ' . GeneralUtility::formatSize(memory_get_peak_usage()) . 'B</p>'
);
} | Renders and outputs the code coverage report.
@return void | entailment |
protected function renderProgressbar()
{
/** @var \Tx_Phpunit_ViewHelpers_ProgressBarViewHelper $progressBarViewHelper */
$progressBarViewHelper = GeneralUtility::makeInstance(\Tx_Phpunit_ViewHelpers_ProgressBarViewHelper::class);
$progressBarViewHelper->injectOutputService($this->outputService);
$progressBarViewHelper->render();
} | Renders DIVs which contain information and a progressbar to visualize
the running tests.
The actual information will be written via JS during
the test runs.
@return void | entailment |
protected function createIconStyle($extensionKey)
{
if ($extensionKey === '') {
throw new \Tx_Phpunit_Exception_NoTestsDirectory('$extensionKey must not be empty.', 1303503647);
}
if (!$this->testFinder->existsTestableForKey($extensionKey)) {
throw new \Tx_Phpunit_Exception_NoTestsDirectory(
'The extension ' . $extensionKey . ' is not loaded.',
1303503664
);
}
$testable = $this->testFinder->getTestableForKey($extensionKey);
return 'background: url(' . $testable->getIconPath() . ') 3px 50% white no-repeat; padding: 1px 1px 1px 24px;';
} | Creates the CSS style attribute content for an icon for the extension
$extensionKey.
@param string $extensionKey
the key of a loaded extension, may also be "typo3"
@return string the content for the "style" attribute, will not be empty
@throws \Tx_Phpunit_Exception_NoTestsDirectory
if there is not extension with tests with the given key | entailment |
protected function get($key)
{
$this->checkForNonEmptyKey($key);
if (!$this->requestDataHasBeenRetrieved) {
$this->retrieveRequestData();
}
if (!isset($this->cachedRequestData[$key])) {
return null;
}
return $this->cachedRequestData[$key];
} | Returns the value stored for the key $key.
@param string $key the key of the value to retrieve, must not be empty
@return mixed the value for the given key, will be NULL if there is no value for the given key | entailment |
protected function retrieveRequestData()
{
$this->cachedRequestData = GeneralUtility::_GP(\Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE);
$this->requestDataHasBeenRetrieved = true;
} | Retrieves the EM configuration for the PHPUnit extension.
@return void | entailment |
public function updateWebhook($webhookId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('PATCH', sprintf('webhooks/%d', $webhookId), [], $data)
);
} | updateWebhook
@param int $webhookId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
public function replaceWebhook($webhookId, array $data = [])
{
return $this->sendRequest(
$this->createRequest('PUT', sprintf('webhooks/%d', $webhookId), [], $data)
);
} | replaceWebhook
@param int $webhookId
@param array $data - See API docs for available fields
@return @see Client::sendRequest | entailment |
protected function getHolidays($year)
{
$christmas = new DateTime($year.'-12-25', $this->timezone);
$thanksgiving = new DateTime('fourth Thursday of November '.$year, $this->timezone);
$holidays = array(
new Holiday(clone $christmas, 'Christmas', $this->timezone),
new Holiday(clone $thanksgiving, 'Thanksgiving Day', $this->timezone),
new Holiday(new DateTime($year.'-1-1', $this->timezone), "New Year's Day", $this->timezone),
new Holiday(new DateTime($year.'-7-4', $this->timezone), 'Independence Day', $this->timezone),
new Holiday(new DateTime($year.'-11-11', $this->timezone), 'Veterans Day', $this->timezone),
new Holiday(new DateTime('second Monday of October '.$year, $this->timezone), 'Columbus Day', $this->timezone),
new Holiday(new DateTime('first Monday of September '.$year, $this->timezone), 'Labor Day', $this->timezone),
new Holiday(new DateTime('last Monday of May '.$year, $this->timezone), 'Memorial Day', $this->timezone),
new Holiday(new DateTime('third Monday of February '.$year, $this->timezone), "President's Day", $this->timezone),
new Holiday(new DateTime('third Monday of January '.$year, $this->timezone), 'Martin Luther King, Jr. Day', $this->timezone),
);
$holidays[] = new Holiday($christmas->modify('-1 day'), 'Christmas Eve', $this->timezone);
$holidays[] = new Holiday($thanksgiving->modify('+1 day'), 'Thanksgiving Adam', $this->timezone);
return $holidays;
} | The template method to be used in the between calculation.
Returns an array of Holidays.
@see between()
@param int $year The year to get the holidays for.
@return array | entailment |
public function matchesClass(\ReflectionClass $class, array $arguments) : bool
{
list($superClass) = $arguments;
return $class->isSubclassOf($superClass) || ($class->name === $superClass);
} | {@inheritdoc} | entailment |
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
{
return $this->getValue($id);
} | Translates the given message.
@param string $id The message id (may also be an object that can be cast to string)
@param array $parameters An array of parameters for the message
@param string|null $domain The domain for the message or null to use the default
@param string|null $locale The locale or null to use the default
@return string The translated string
@throws InvalidArgumentException If the locale contains invalid characters | entailment |
public function matchesClass(\ReflectionClass $class, array $arguments) : bool
{
list($contains) = $arguments;
return strpos($class->name, $contains) !== false;
} | {@inheritdoc} | entailment |
public function matchesMethod(\ReflectionMethod $method, array $arguments) : bool
{
list($contains) = $arguments;
return strpos($method->name, $contains) !== false;
} | {@inheritdoc} | entailment |
public function addAlternateUrl(string $locale, string $url): void
{
$this->alternateUrl[$locale] = $url;
} | Add an alternate url to the current one.
If you have multiple language versions of a URL, each language page in
the set must use rel="alternate" hreflang="x" to identify all language
versions including itself. For example, if your site provides content
in French, English, and Spanish, the Spanish version must include a
rel="alternate" hreflang="x" link for itself in addition to links to the
French and English versions. Similarly the English and French versions
must each include the same references to the French, English, and
Spanish versions.
@param string $locale The url's language (and optionnaly region. Ex: en, en-us). | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.