_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q258200 | ShopPackageInstaller.copySetupFiles | test | private function copySetupFiles($packagePath)
{
$packageDirectoryOfShopSource = $this->getPackageDirectoryOfShopSource($packagePath);
$installationDirectoryOfShopSource = $this->getTargetDirectoryOfShopSource();
$shopConfigFileName = Path::join($installationDirectoryOfShopSource, self::SHOP_SOURCE_CONFIGURATION_FILE);
if ($this->isConfigFileNotConfiguredOrMissing($shopConfigFileName)) {
CopyGlobFilteredFileManager::copy(
Path::join($packageDirectoryOfShopSource, self::SHOP_SOURCE_SETUP_DIRECTORY),
Path::join($installationDirectoryOfShopSource, self::SHOP_SOURCE_SETUP_DIRECTORY)
);
}
} | php | {
"resource": ""
} |
q258201 | ShopPackageInstaller.isConfigFileNotConfiguredOrMissing | test | private function isConfigFileNotConfiguredOrMissing($shopConfigFileName)
{
if (!file_exists($shopConfigFileName)) {
return true;
}
$shopConfigFileContents = file_get_contents($shopConfigFileName);
$wordsIndicatingNotConfigured = [
'<dbHost>',
'<dbName>',
'<dbUser>',
'<dbPwd>',
'<sShopURL>',
'<sShopDir>',
'<sCompileDir>',
];
foreach ($wordsIndicatingNotConfigured as $word) {
if (strpos($shopConfigFileContents, $word) !== false) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q258202 | ShopPackageInstaller.copyFilesFromSourceToInstallationByFilter | test | private function copyFilesFromSourceToInstallationByFilter($packagePath, $filter)
{
$sourceDirectory = $this->getPackageDirectoryOfShopSource($packagePath);
$filteredFiles = $this->getFilteredFiles($sourceDirectory, $filter);
foreach ($filteredFiles as $packageFilePath) {
$installationFilePath = $this->getAbsoluteFilePathFromInstallation(
$sourceDirectory,
$packageFilePath
);
$this->copyFileIfIsMissing($packageFilePath, $installationFilePath);
}
} | php | {
"resource": ""
} |
q258203 | ShopPackageInstaller.getFilteredFiles | test | private function getFilteredFiles($directory, $filter)
{
$glob = Path::join($directory, $filter);
return new GlobIterator($glob);
} | php | {
"resource": ""
} |
q258204 | ShopPackageInstaller.getAbsoluteFilePathFromInstallation | test | private function getAbsoluteFilePathFromInstallation(
$sourcePackageDirectory,
$absolutePathToFileFromPackage
) {
$installationDirectoryOfShopSource = $this->getTargetDirectoryOfShopSource();
$relativePathOfSourceFromPackage = Path::makeRelative(
$absolutePathToFileFromPackage,
$sourcePackageDirectory
);
$absolutePathToFileFromInstallation = Path::join(
$installationDirectoryOfShopSource,
$relativePathOfSourceFromPackage
);
return $absolutePathToFileFromInstallation;
} | php | {
"resource": ""
} |
q258205 | ThemePackageInstaller.update | test | public function update($packagePath)
{
$this->writeUpdatingMessage($this->getPackageTypeDescription());
$question = 'All files in the following directories will be overwritten:' . PHP_EOL .
'- ' . $this->formThemeTargetPath() . PHP_EOL .
'- ' . Path::join($this->getRootDirectory(), $this->formAssetsDirectoryName()) . PHP_EOL .
'Do you want to overwrite them? (y/N) ';
if ($this->askQuestionIfNotInstalled($question)) {
$this->writeCopyingMessage();
$this->copyPackage($packagePath);
$this->writeDoneMessage();
} else {
$this->writeSkippedMessage();
}
} | php | {
"resource": ""
} |
q258206 | ModulePackageInstaller.copyPackage | test | protected function copyPackage($packagePath)
{
$filtersToApply = [
$this->getBlacklistFilterValue(),
$this->getVCSFilter(),
];
CopyGlobFilteredFileManager::copy(
$this->formSourcePath($packagePath),
$this->formTargetPath(),
$this->getCombinedFilters($filtersToApply)
);
} | php | {
"resource": ""
} |
q258207 | ModulePackageInstaller.formSourcePath | test | protected function formSourcePath($packagePath)
{
$sourceDirectory = $this->getExtraParameterValueByKey(static::EXTRA_PARAMETER_KEY_SOURCE);
return !empty($sourceDirectory)?
Path::join($packagePath, $sourceDirectory):
$packagePath;
} | php | {
"resource": ""
} |
q258208 | VfsFileStructureOperator.nest | test | public static function nest($flatFileSystemStructure = null)
{
if (null !== $flatFileSystemStructure && false === is_array($flatFileSystemStructure)) {
throw new \InvalidArgumentException("Given input argument must be an array.");
}
if (null === $flatFileSystemStructure) {
return [];
}
$nestedFileSystemStructure = [];
foreach ($flatFileSystemStructure as $pathEntry => $contents) {
$pathEntries = explode(DIRECTORY_SEPARATOR, $pathEntry);
$pointerToBranch = &$nestedFileSystemStructure;
foreach ($pathEntries as $singlePathEntry) {
$singlePathEntry = trim($singlePathEntry);
if ($singlePathEntry !== '') {
if (!is_array($pointerToBranch)) {
$pointerToBranch = [];
}
if (!key_exists($singlePathEntry, $pointerToBranch)) {
$pointerToBranch[$singlePathEntry] = [];
}
$pointerToBranch = &$pointerToBranch[$singlePathEntry];
}
}
if (substr($pathEntry, -1) !== DIRECTORY_SEPARATOR) {
$pointerToBranch = $contents;
}
}
return $nestedFileSystemStructure;
} | php | {
"resource": ""
} |
q258209 | CopyGlobFilteredFileManager.getFlatFileListIterator | test | private static function getFlatFileListIterator($sourcePath)
{
$recursiveFileIterator = new \RecursiveDirectoryIterator($sourcePath, \FilesystemIterator::SKIP_DOTS);
$flatFileListIterator = new \RecursiveIteratorIterator($recursiveFileIterator);
return $flatFileListIterator;
} | php | {
"resource": ""
} |
q258210 | CopyGlobFilteredFileManager.copyDirectory | test | private static function copyDirectory($sourcePath, $destinationPath, $globExpressionList)
{
$filesystem = new Filesystem();
$flatFileListIterator = self::getFlatFileListIterator($sourcePath);
$filteredFileListIterator = new BlacklistFilterIterator(
$flatFileListIterator,
$sourcePath,
$globExpressionList
);
$filesystem->mirror($sourcePath, $destinationPath, $filteredFileListIterator, ["override" => true]);
} | php | {
"resource": ""
} |
q258211 | CopyGlobFilteredFileManager.copyFile | test | private static function copyFile($sourcePathOfFile, $destinationPath, $globExpressionList)
{
$filesystem = new Filesystem();
$relativeSourcePath = self::getRelativePathForSingleFile($sourcePathOfFile);
if (!GlobMatcher::matchAny($relativeSourcePath, $globExpressionList)) {
$filesystem->copy($sourcePathOfFile, $destinationPath, ["override" => true]);
}
} | php | {
"resource": ""
} |
q258212 | Installer.generateModels | test | public static function generateModels(array $config)
{
$schemas = ArrayHelper::getValue($config, 'schemas', []);
$namespace = ArrayHelper::getValue($config, 'namespace', 'simialbi\yii2\schemaorg\models');
$folder = ArrayHelper::getValue($config, 'folder', sprintf(
'%1$s%2$ssimialbi%2$syii2-schema-org%2$ssrc%2$smodels',
$config['vendorPath'],
DIRECTORY_SEPARATOR
));
$removeOld = ArrayHelper::getValue($config, 'removeOld', true);
require_once $config['vendorPath'] . DIRECTORY_SEPARATOR . 'autoload.php';
require_once $config['vendorPath'] . DIRECTORY_SEPARATOR . 'yiisoft' . DIRECTORY_SEPARATOR . 'yii2' . DIRECTORY_SEPARATOR . 'Yii.php';
Yii::setAlias('@runtime', rtrim(str_replace(['\\', '/'], '/', sys_get_temp_dir()), '/'));
new \yii\console\Application([
'id' => 'Commmand runner',
'basePath' => __DIR__,
'vendorPath' => $config['vendorPath'],
'bootstrap' => ['schema'],
'aliases' => [],
'modules' => [
'schema' => [
'class' => 'simialbi\yii2\schemaorg\Module'
]
]
]);
$options = [
'namespace' => $namespace,
'folder' => $folder,
'removeOld' => $removeOld
];
if (!empty($schemas)) {
$options['schemas'] = implode(',', $schemas);
}
Yii::$app->runAction('schema/models/generate', $options);
Yii::$app = null;
unset($app);
} | php | {
"resource": ""
} |
q258213 | ModelsController.traverseClasses | test | private function traverseClasses(array &$classes, $allClasses = null)
{
if ($allClasses === null) {
$allClasses = $classes;
}
foreach ($classes as &$class) {
$parentClasses = ArrayHelper::remove($class, 'rdfs:subClassOf', []);
if (ArrayHelper::isAssociative($parentClasses)) {
$parentClasses = [$parentClasses];
}
foreach ($parentClasses as $k => $parentClass) {
$parentClasses[$k] = ArrayHelper::getValue($allClasses, $parentClass['@id']);
if ($parentClass === null) {
continue;
}
}
$this->traverseClasses($parentClasses, $allClasses);
foreach ($parentClasses as $parentClass) {
ArrayHelper::setValue($class, 'properties', ArrayHelper::merge(
ArrayHelper::getValue($class, 'properties', []),
ArrayHelper::getValue($parentClass, 'properties', [])
));
}
}
} | php | {
"resource": ""
} |
q258214 | Model.toJsonLDArray | test | public function toJsonLDArray($fields = [], $expand = [], $recursive = true)
{
return array_merge([
'@context' => 'http://schema.org'
], $this->toArray($fields, $expand, $recursive));
} | php | {
"resource": ""
} |
q258215 | JsonLDHelper.addBreadCrumbList | test | public static function addBreadCrumbList()
{
if (!class_exists('\simialbi\yii2\schemaorg\models\BreadcrumbList')) {
return;
}
$view = Yii::$app->view;
/* @var $breadcrumbList \simialbi\yii2\schemaorg\models\Model */
$breadcrumbs = ArrayHelper::getValue($view->params, 'breadcrumbs', []);
$breadcrumbList = Yii::createObject([
'class' => 'simialbi\yii2\schemaorg\models\BreadcrumbList'
]);
if (!empty($breadcrumbs)) {
$position = 1;
foreach ($breadcrumbs as $breadcrumb) {
$listItem = Yii::createObject([
'class' => 'simialbi\yii2\schemaorg\models\ListItem',
'position' => $position++
]);
if (is_array($breadcrumb)) {
$listItem->item = [
'@id' => Url::to(ArrayHelper::getValue($breadcrumb, 'url', ''), true),
'name' => ArrayHelper::getValue($breadcrumb, 'label', '')
];
} else {
$listItem->item = [
'@id' => Yii::$app->request->absoluteUrl,
'name' => $breadcrumb
];
}
$breadcrumbList->itemListElement[] = $listItem;
}
}
self::add($breadcrumbList);
} | php | {
"resource": ""
} |
q258216 | JsonLDHelper.render | test | public static function render()
{
if (!empty(self::$_models)) {
foreach (self::$_models as $model) {
try {
echo Html::script(Json::encode($model->toJsonLDArray()), ['type' => 'application/ld+json']) . "\n";
} catch (InvalidArgumentException $e) {
$logger = Yii::$app->log->logger;
$logger->log($e->getMessage(), $logger::LEVEL_ERROR);
}
}
}
} | php | {
"resource": ""
} |
q258217 | ToInlineStyleEmailConverter.setHTMLByView | test | public function setHTMLByView($view, array $parameters = array())
{
if (!$this->container) {
throw new MissingTemplatingEngineException("To use this function, a Container object must be passed to the constructor (@service_container service)");
}
/** @var EngineInterface $engine */
$engine = $this->container->get('templating');
$this->setHTML($engine->render($view, $parameters));
} | php | {
"resource": ""
} |
q258218 | ToInlineStyleEmailConverter.generateStyledHTML | test | public function generateStyledHTML()
{
if (is_null($this->html)) {
throw new MissingParamException("The HTML must be set");
}
if (!is_string($this->html)) {
throw new MissingParamException("The HTML must be a valid string");
}
if (is_null($this->css)) {
throw new MissingParamException("The CSS must be set");
}
if (!is_string($this->css)) {
throw new MissingParamException("The CSS must be a valid string");
}
return $this->cssToInlineStyles->convert($this->html, $this->css);
} | php | {
"resource": ""
} |
q258219 | InlineCssParser.resolvePath | test | private function resolvePath($path)
{
try {
return $this->locator->locate($path, $this->webRoot);
} catch (\InvalidArgumentException $e) {
// happens when path is not bundle relative
return $this->webRoot . '/' . $path;
}
} | php | {
"resource": ""
} |
q258220 | OnlySubsetsInList.expected | test | protected function expected(array $actual): bool
{
return collect($this->expected)->contains(function ($expected) use ($actual) {
return $this->compare($expected, $actual);
});
} | php | {
"resource": ""
} |
q258221 | OnlySubsetsInList.exists | test | protected function exists(array $expected, $actual): bool
{
if (!is_array($actual)) {
return false;
}
return collect($actual)->contains(function ($item) use ($expected) {
return $this->compare($expected, $item);
});
} | php | {
"resource": ""
} |
q258222 | HttpAssert.assertStatusCode | test | public static function assertStatusCode(
$status,
int $expected,
$content = null,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$status,
new HttpStatusIs($expected, $content),
$message
);
} | php | {
"resource": ""
} |
q258223 | HttpAssert.assertContent | test | public static function assertContent(
$type,
$content,
$expected = self::JSON_API_MEDIA_TYPE,
string $message = ''
): Document
{
PHPUnitAssert::assertSame($type, $expected, $message ?: "Expecting content with media type {$expected}.");
PHPUnitAssert::assertNotEmpty($content, $message ?: 'Expecting HTTP body to have content.');
return Document::cast($content);
} | php | {
"resource": ""
} |
q258224 | HttpAssert.assertJson | test | public static function assertJson(
$status,
$contentType,
$content,
int $expected = self::STATUS_OK,
string $message = ''
): Document
{
self::assertStatusCode($status, $expected, $content, $message);
return self::assertContent($contentType, $content, self::JSON_MEDIA_TYPE, $message);
} | php | {
"resource": ""
} |
q258225 | HttpAssert.assertJsonApi | test | public static function assertJsonApi(
$status,
$contentType,
$content,
int $expected = self::STATUS_OK,
string $message = ''
): Document
{
self::assertStatusCode($status, $expected, $content, $message);
return self::assertContent($contentType, $content, self::JSON_API_MEDIA_TYPE, $message);
} | php | {
"resource": ""
} |
q258226 | HttpAssert.assertFetchedOne | test | public static function assertFetchedOne(
$status,
$contentType,
$content,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
return self::assertJsonApi($status, $contentType, $content, self::STATUS_OK, $message)
->assertHash($expected, '/data', $strict, $message);
} | php | {
"resource": ""
} |
q258227 | HttpAssert.assertFetchedExact | test | public static function assertFetchedExact(
$status,
$contentType,
$content,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
return self::assertJsonApi($status, $contentType, $content, self::STATUS_OK, $message)
->assertExact($expected, '/data', $strict, $message);
} | php | {
"resource": ""
} |
q258228 | HttpAssert.assertFetchedManyInOrder | test | public static function assertFetchedManyInOrder(
$status,
$contentType,
$content,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
if (empty($expected)) {
return self::assertFetchedNone($strict, $contentType, $content, $message);
}
return self::assertJsonApi($status, $contentType, $content, self::STATUS_OK, $message)
->assertListInOrder($expected, '/data', $strict, $message);
} | php | {
"resource": ""
} |
q258229 | HttpAssert.assertFetchedToMany | test | public static function assertFetchedToMany(
$status,
$contentType,
$content,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
if (empty($expected)) {
return self::assertFetchedNone($strict, $contentType, $content, $message);
}
return self::assertJsonApi($status, $contentType, $content, self::STATUS_OK, $message)
->assertIdentifiersList($expected, '/data', $strict, $message);
} | php | {
"resource": ""
} |
q258230 | HttpAssert.assertFetchedToManyInOrder | test | public static function assertFetchedToManyInOrder(
$status,
$contentType,
$content,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
if (empty($expected)) {
return self::assertFetchedNone($strict, $contentType, $content, $message);
}
return self::assertJsonApi($status, $contentType, $content, self::STATUS_OK, $message)
->assertIdentifiersListInOrder($expected, '/data', $strict, $message);
} | php | {
"resource": ""
} |
q258231 | HttpAssert.assertCreatedWithClientId | test | public static function assertCreatedWithClientId(
$status,
$contentType,
$content,
$location,
string $expectedLocation,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
$expectedId = $expected['id'] ?? null;
if (!$expectedId) {
throw new \InvalidArgumentException('Expected resource hash must have an id.');
}
self::assertStatusCode($status, self::STATUS_CREATED, $content, $message);
PHPUnitAssert::assertSame(
"$expectedLocation/{$expectedId}",
$location,
$message ?: 'Unexpected Location header.'
);
return self::assertContent($contentType, $content, self::JSON_API_MEDIA_TYPE, $message)
->assertHash($expected, '/data', $strict, $message);
} | php | {
"resource": ""
} |
q258232 | HttpAssert.assertNoContent | test | public static function assertNoContent($status, string $content = null, string $message = ''): void
{
self::assertStatusCode($status, self::STATUS_NO_CONTENT, $content, $message);
PHPUnitAssert::assertEmpty($content, $message ?: 'Expecting HTTP body content to be empty.');
} | php | {
"resource": ""
} |
q258233 | HttpAssert.assertExactMetaWithoutData | test | public static function assertExactMetaWithoutData(
$status,
$contentType,
$content,
array $expected,
bool $strict = true,
string $message = ''
): Document
{
return self::assertJsonApi($status, $contentType, $content, self::STATUS_OK, $message)
->assertNotExists('/data', $message)
->assertExactMeta($expected, $strict, $message);
} | php | {
"resource": ""
} |
q258234 | HttpAssert.assertExactErrorStatus | test | public static function assertExactErrorStatus(
$status,
$contentType,
$content,
array $error,
bool $strict = true,
string $message = ''
): Document
{
$expectedStatus = $error['status'] ?? null;
if (!$expectedStatus) {
throw new \InvalidArgumentException('Expecting error to have a status member.');
}
return self::assertExactError(
$status,
$contentType,
$content,
(int) $expectedStatus,
$error,
$strict,
$message
);
} | php | {
"resource": ""
} |
q258235 | HttpAssert.assertHasExactError | test | public static function assertHasExactError(
$status,
$contentType,
$content,
int $expectedStatus,
array $error,
bool $strict = true,
string $message = ''
): Document
{
if (empty($error)) {
$error = ['status' => (string) $status];
}
return self::assertJsonApi($status, $contentType, $content, $expectedStatus, $message)
->assertHasExactError($error, $strict, $message);
} | php | {
"resource": ""
} |
q258236 | HttpAssert.assertErrors | test | public static function assertErrors(
$status,
$contentType,
$content,
int $expectedStatus,
array $errors,
bool $strict = true,
string $message = ''
): Document
{
return self::assertJsonApi($status, $contentType, $content, $expectedStatus, $message)
->assertErrors($errors, $strict, $message);
} | php | {
"resource": ""
} |
q258237 | HasHttpAssertions.getDocument | test | public function getDocument(): Document
{
if (!$this->document) {
$this->document = HttpAssert::assertContent(
$this->getContentType(),
$this->getContent()
);
}
return $this->document;
} | php | {
"resource": ""
} |
q258238 | HasHttpAssertions.willSeeType | test | public function willSeeType(string $type): self
{
if (empty($type)) {
throw new \InvalidArgumentException('Expected type must be a non-empty string.');
}
$this->expectedType = $type;
return $this;
} | php | {
"resource": ""
} |
q258239 | HasHttpAssertions.assertFetchedOneExact | test | public function assertFetchedOneExact($expected, bool $strict = true): self
{
$this->document = HttpAssert::assertFetchedExact(
$this->getStatusCode(),
$this->getContentType(),
$this->getContent(),
$this->identifier($expected),
$strict
);
return $this;
} | php | {
"resource": ""
} |
q258240 | HasHttpAssertions.assertUpdated | test | public function assertUpdated(array $expected = null, bool $strict = true): self
{
if (is_null($expected)) {
return $this->assertNoContent();
}
return $this->assertFetchedOne($expected, $strict);
} | php | {
"resource": ""
} |
q258241 | HasHttpAssertions.assertDeleted | test | public function assertDeleted(array $expected = null, bool $strict = true): self
{
if (is_null($expected)) {
return $this->assertNoContent();
}
return $this->assertMetaWithoutData($expected, $strict);
} | php | {
"resource": ""
} |
q258242 | HasHttpAssertions.assertIsIncluded | test | public function assertIsIncluded(string $type, $id): self
{
$identifier = $this->identifier(compact('type', 'id'));
$this->getDocument()->assertIncludedContainsResource(
$identifier['type'],
$identifier['id']
);
return $this;
} | php | {
"resource": ""
} |
q258243 | HasHttpAssertions.assertIncludes | test | public function assertIncludes($expected, bool $strict = true): self
{
$this->getDocument()->assertIncludedContainsHash(
$this->identifier($expected),
$strict
);
return $this;
} | php | {
"resource": ""
} |
q258244 | HasHttpAssertions.assertMeta | test | public function assertMeta(array $expected, bool $strict = true): self
{
$this->getDocument()->assertMeta($expected, $strict);
return $this;
} | php | {
"resource": ""
} |
q258245 | HasHttpAssertions.assertExactMeta | test | public function assertExactMeta(array $expected, bool $strict = true): self
{
$this->getDocument()->assertExactMeta($expected, $strict);
return $this;
} | php | {
"resource": ""
} |
q258246 | HasHttpAssertions.assertExactLinks | test | public function assertExactLinks(array $expected, bool $strict = true): self
{
$this->getDocument()->assertExactLinks($expected, $strict);
return $this;
} | php | {
"resource": ""
} |
q258247 | HasHttpAssertions.assertExactErrors | test | public function assertExactErrors(int $status, array $errors, bool $strict = true): self
{
$this->document = HttpAssert::assertExactErrors(
$this->getStatusCode(),
$this->getContentType(),
$this->getContent(),
$status,
$errors,
$strict
);
return $this;
} | php | {
"resource": ""
} |
q258248 | Assert.assertResource | test | public static function assertResource(
$document,
string $type,
string $id,
string $pointer = '/data',
string $message = ''
): void
{
self::assertHash($document, compact('type', 'id'), $pointer, true, $message);
} | php | {
"resource": ""
} |
q258249 | Assert.assertIdentifier | test | public static function assertIdentifier(
$document,
string $type,
string $id,
string $pointer = '/data',
string $message = ''
): void
{
$expected = compact('type', 'id');
PHPUnitAssert::assertThat(
$document,
new IdentifierInDocument($expected, $pointer, true),
$message
);
} | php | {
"resource": ""
} |
q258250 | Assert.assertExact | test | public static function assertExact(
$document,
$expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new ExactInDocument($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258251 | Assert.assertNotExact | test | public static function assertNotExact(
$document,
$expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
$constraint = new LogicalNot(
new ExactInDocument($expected, $pointer, $strict)
);
PHPUnitAssert::assertThat($document, $constraint, $message);
} | php | {
"resource": ""
} |
q258252 | Assert.assertList | test | public static function assertList(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new OnlySubsetsInList($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258253 | Assert.assertExactList | test | public static function assertExactList(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new OnlyExactInList($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258254 | Assert.assertListInOrder | test | public static function assertListInOrder(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new SubsetInDocument($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258255 | Assert.assertExactListInOrder | test | public static function assertExactListInOrder(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
self::assertExact($document, $expected, $pointer, $strict, $message);
} | php | {
"resource": ""
} |
q258256 | Assert.assertIdentifiersList | test | public static function assertIdentifiersList(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new OnlyIdentifiersInList($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258257 | Assert.assertIdentifiersListInOrder | test | public static function assertIdentifiersListInOrder(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new IdentifiersInDocument($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258258 | Assert.assertListContainsResource | test | public static function assertListContainsResource(
$document,
string $type,
string $id,
string $pointer = '/data',
string $message = ''
): void
{
$expected = compact('type', 'id');
self::assertListContainsHash($document, $expected, $pointer, true, $message);
} | php | {
"resource": ""
} |
q258259 | Assert.assertListContainsHash | test | public static function assertListContainsHash(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new SubsetInList($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258260 | Assert.assertListContainsExact | test | public static function assertListContainsExact(
$document,
array $expected,
string $pointer = '/data',
bool $strict = true,
string $message = ''
): void
{
PHPUnitAssert::assertThat(
$document,
new ExactInList($expected, $pointer, $strict),
$message
);
} | php | {
"resource": ""
} |
q258261 | Assert.assertIncludedContainsHash | test | public static function assertIncludedContainsHash(
$document,
array $expected,
bool $strict = true,
string $message = ''
): void
{
self::assertListContainsHash($document, $expected, '/included', $strict, $message);
} | php | {
"resource": ""
} |
q258262 | Assert.assertExactError | test | public static function assertExactError($document, array $error, bool $strict = true, string $message = ''): void
{
self::assertExactList($document, [$error], '/errors', $strict, $message);
} | php | {
"resource": ""
} |
q258263 | Assert.assertHasError | test | public static function assertHasError($document, array $error, bool $strict = true, string $message = ''): void
{
self::assertListContainsHash($document, $error, '/errors', $strict, $message);
} | php | {
"resource": ""
} |
q258264 | Assert.assertHasExactError | test | public static function assertHasExactError(
$document,
array $error,
bool $strict = true,
string $message = ''
): void
{
self::assertListContainsExact($document, $error, '/errors', $strict, $message);
} | php | {
"resource": ""
} |
q258265 | Document.create | test | public static function create($content): ?self
{
if (is_string($content)) {
return self::fromString($content);
}
return $content ? self::cast($content) : null;
} | php | {
"resource": ""
} |
q258266 | Document.cast | test | public static function cast($document): self
{
if ($document instanceof self) {
return $document;
}
if (is_string($document)) {
return self::decode($document);
}
return self::fromIterable($document);
} | php | {
"resource": ""
} |
q258267 | Document.fromString | test | public static function fromString(string $json): ?self
{
$document = \json_decode($json, true);
if (JSON_ERROR_NONE !== \json_last_error() || !\is_array($document)) {
return null;
}
return new self($document);
} | php | {
"resource": ""
} |
q258268 | Document.decode | test | public static function decode(string $json): self
{
if (!$document = self::fromString($json)) {
throw new \InvalidArgumentException('Invalid JSON string.');
}
return $document;
} | php | {
"resource": ""
} |
q258269 | Document.get | test | public function get(string $pointer, $default = null)
{
if (!$path = Compare::path($pointer)) {
return $this->document;
}
return Arr::get($this->document, $path, $default);
} | php | {
"resource": ""
} |
q258270 | Document.has | test | public function has(string ...$pointers): bool
{
$paths = collect($pointers)->map(function ($pointer) {
return Compare::path($pointer);
})->filter()->all();
return Arr::has($this->document, $paths);
} | php | {
"resource": ""
} |
q258271 | Document.assertExists | test | public function assertExists($pointers, string $message = ''): self
{
$missing = collect((array) $pointers)->reject(function ($pointer) {
return $this->has($pointer);
})->implode(', ');
PHPUnitAssert::assertEmpty($missing, $message ?: "Members [{$missing}] do not exist.");
return $this;
} | php | {
"resource": ""
} |
q258272 | Document.assertNotExists | test | public function assertNotExists($pointers, string $message = ''): self
{
$unexpected = collect((array) $pointers)->filter(function ($pointer) {
return $this->has($pointer);
})->implode(', ');
PHPUnitAssert::assertEmpty($unexpected, $message ?: "Members [{$unexpected}] exist.");
return $this;
} | php | {
"resource": ""
} |
q258273 | Compare.exact | test | public static function exact($expected, $actual, bool $strict = true): bool
{
$expected = self::normalize($expected);
$actual = self::normalize($actual);
if ($strict) {
return $expected === $actual;
}
return $expected == $actual;
} | php | {
"resource": ""
} |
q258274 | Compare.subset | test | public static function subset(array $expected, $actual, bool $strict = true): bool
{
if (!is_array($actual)) {
return false;
}
$patched = self::patch($actual, $expected);
return self::exact($patched, $actual, $strict);
} | php | {
"resource": ""
} |
q258275 | Compare.resourceIdentifier | test | public static function resourceIdentifier($value): bool
{
if (!is_array($value)) {
return false;
}
$members = collect($value);
return $members->has('type') &&
$members->has('id') &&
!$members->has('attributes') &&
!$members->has('relationships');
} | php | {
"resource": ""
} |
q258276 | Compare.sort | test | public static function sort(array $value): array
{
if (self::hash($value)) {
ksort($value);
}
return collect($value)->map(function ($item) {
return self::normalize($item);
})->all();
} | php | {
"resource": ""
} |
q258277 | Compare.identifiable | test | public static function identifiable($value): bool
{
return $value instanceof UrlRoutable ||
is_string($value) ||
is_int($value) ||
self::hash($value);
} | php | {
"resource": ""
} |
q258278 | ListFilesIterator.sendRequest | test | protected function sendRequest()
{
if ($this->nextToken) {
$this->command->set('page', $this->nextToken);
}
$result = $this->command->execute();
$currentToken = $result['paging']['page'];
$this->nextToken = $result['paging']['pages'] > $currentToken ? ++$currentToken : false;
return $result['files'];
} | php | {
"resource": ""
} |
q258279 | Iterocitor.tell | test | public function tell($user, $text)
{
return $this->say($this->sequencer->format('@'.$user).' '.$text);
} | php | {
"resource": ""
} |
q258280 | Iterocitor.reply | test | public function reply($user, $text)
{
if ($user instanceof CommandInterface) {
$sequence = $this->sequencer->command($user);
return $this->say($sequence['user'].' '.$text);
}
return $this->tell($user, $text);
} | php | {
"resource": ""
} |
q258281 | OptionsResolver.setTypesAllowed | test | public function setTypesAllowed($allowedTypes = null)
{
if (!$this->isLatest()) {
return $this->setAllowedTypes($allowedTypes);
}
foreach ($allowedTypes as $option => $typesAllowed) {
$this->setAllowedTypes($option, $typesAllowed);
}
return $this;
} | php | {
"resource": ""
} |
q258282 | HtmlOutput.write | test | public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
{
if (!is_array($messages))
{
$messages = array($messages);
}
foreach ($messages as $message)
{
$this->buffer .= $this->parse($message);
if ($newline)
{
$this->buffer .= "\n";
}
}
} | php | {
"resource": ""
} |
q258283 | Output.writelnIfDebug | test | public function writelnIfDebug($message)
{
if ($this->debug)
{
$this->debugMessages[] = new Message(Output::DEBUG, $message, null);
}
} | php | {
"resource": ""
} |
q258284 | Output.addMessage | test | public function addMessage($type, $message, FileInterface $file = null)
{
switch ($type)
{
case Output::FATAL:
$this->fatal++;
break;
case Output::ERROR:
$this->error++;
break;
case Output::WARNING:
$this->warning++;
break;
case Output::NOTICE:
$this->notice++;
break;
case Output::DEBUG:
break;
default:
// TODO: Decide on this?
}
$this->messages[] = new Message($type, $message, $file);
} | php | {
"resource": ""
} |
q258285 | Output.getMessageCount | test | public function getMessageCount($type)
{
switch ($type)
{
case Output::FATAL:
return $this->fatal;
case Output::ERROR:
return $this->error;
case Output::WARNING:
return $this->warning;
case Output::NOTICE:
return $this->notice;
}
} | php | {
"resource": ""
} |
q258286 | php_exporter.get_vars_from_single_line_array | test | public function get_vars_from_single_line_array($line, $throw_multiline = true)
{
$match = array();
preg_match('#^\$vars = (?:(\[)|array\()\'([a-z0-9_\' ,]+)\'(?(1)\]|\));$#i', $line, $match);
if (isset($match[2]))
{
$vars_array = explode("', '", $match[2]);
if ($throw_multiline && sizeof($vars_array) > 6)
{
throw new \LogicException('Should use multiple lines for $vars definition '
. "for event '{$this->current_event}' in file '{$this->current_clean_file}:{$this->current_event_line}'", 2);
}
return $vars_array;
}
else
{
throw new \LogicException("Can not find '\$vars = array();'-line for event '{$this->current_event}' in file '{$this->current_clean_file}:{$this->current_event_line}'. Are you using UNIX style linefeeds?", 1);
}
} | php | {
"resource": ""
} |
q258287 | php_exporter.get_vars_from_multi_line_array | test | public function get_vars_from_multi_line_array()
{
$current_vars_line = 2;
$var_lines = array();
while (!in_array(ltrim($this->file_lines[$this->current_event_line - $current_vars_line], "\t"), ['$vars = array(', '$vars = [']))
{
$var_lines[] = substr(trim($this->file_lines[$this->current_event_line - $current_vars_line]), 0, -1);
$current_vars_line++;
if ($current_vars_line > $this->current_event_line)
{
// Reached the start of the file
throw new \LogicException("Can not find end of \$vars array for event '{$this->current_event}' in file '{$this->current_clean_file}:{$this->current_event_line}'.", 2);
}
}
return $this->get_vars_from_single_line_array('$vars = array(' . implode(", ", $var_lines) . ');', false);
} | php | {
"resource": ""
} |
q258288 | php_exporter.validate_vars_docblock_array | test | public function validate_vars_docblock_array($vars_array, $vars_docblock)
{
$vars_array = array_unique($vars_array);
$vars_docblock = array_unique($vars_docblock);
$sizeof_vars_array = sizeof($vars_array);
if ($sizeof_vars_array !== sizeof($vars_docblock) || $sizeof_vars_array !== sizeof(array_intersect($vars_array, $vars_docblock)))
{
throw new \LogicException("\$vars array does not match the list of '@var' tags for event "
. "'{$this->current_event}' in file '{$this->current_clean_file}:{$this->current_event_line}'");
}
} | php | {
"resource": ""
} |
q258289 | AllTrait.all | test | public function all($strategy = null)
{
if ($this instanceof \Iterator) {
$strategy = conversions\mixed_to_value_getter($strategy);
foreach ($this as $item) {
$tempVarPhp54 = call_user_func($strategy, $item);
if (empty($tempVarPhp54)) {
return false;
}
}
return true;
}
return null;
} | php | {
"resource": ""
} |
q258290 | AccumulateTrait.accumulate | test | public function accumulate($closure = 'add')
{
if ($this instanceof \Iterator) {
return new AccumulateIterator(
$this,
$closure instanceof \Closure ? $closure : reductions\get_reduction($closure)
);
}
return null;
} | php | {
"resource": ""
} |
q258291 | SortedIterator.mergeSort | test | protected function mergeSort(array &$array, \Closure $cmp_function)
{
// Arrays of size < 2 require no action.
if (count($array) < 2) {
return;
}
// Split the array in half
$halfway = count($array) / 2;
$array1 = array_slice($array, 0, $halfway);
$array2 = array_slice($array, $halfway);
// Recurse to sort the two halves
$this->mergesort($array1, $cmp_function);
$this->mergesort($array2, $cmp_function);
// If all of $array1 is <= all of $array2, just append them.
if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
$array = array_merge($array1, $array2);
return;
}
// Merge the two sorted arrays into a single sorted array
$array = [];
$ptr1 = $ptr2 = 0;
while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
$array[] = $array1[$ptr1++];
} else {
$array[] = $array2[$ptr2++];
}
}
// Merge the remainder
while ($ptr1 < count($array1)) {
$array[] = $array1[$ptr1++];
}
while ($ptr2 < count($array2)) {
$array[] = $array2[$ptr2++];
}
return;
} | php | {
"resource": ""
} |
q258292 | ToArrayTrait.toArray | test | public function toArray()
{
if ($this instanceof \Traversable) {
$array = iterator_to_array($this);
array_walk(
$array,
function (&$value) {
if ($value instanceof FiniteIterableInterface) {
$value = $value->toArray();
}
}
);
return $array;
} else {
return [];
}
} | php | {
"resource": ""
} |
q258293 | KeysTrait.keys | test | public function keys()
{
$keys = [];
if ($this instanceof \Traversable) {
foreach ($this as $key => $value) {
$keys [] = $key;
}
}
return $keys;
} | php | {
"resource": ""
} |
q258294 | ZipTrait.zip | test | public function zip(/* $iterable, $iterable2, ... */)
{
if ($this instanceof \Iterator) {
$iterables = array_map(
'\Zicht\Itertools\conversions\mixed_to_iterator',
func_get_args()
);
$reflectorClass = new \ReflectionClass('\Zicht\Itertools\lib\ZipIterator');
return $reflectorClass->newInstanceArgs(array_merge([$this], $iterables));
}
return null;
} | php | {
"resource": ""
} |
q258295 | ValuesTrait.values | test | public function values()
{
$values = [];
if ($this instanceof \Traversable) {
foreach ($this as $key => $value) {
$values [] = $value instanceof FiniteIterableInterface ? $value->values() : $value;
}
}
return $values;
} | php | {
"resource": ""
} |
q258296 | ReduceTrait.reduce | test | public function reduce($closure = 'add', $initializer = null)
{
if ($this instanceof \Iterator) {
$closure = $closure instanceof \Closure ? $closure : Itertools\reductions\get_reduction($closure);
$this->rewind();
if (null === $initializer) {
if ($this->valid()) {
$initializer = $this->current();
$this->next();
}
}
$accumulatedValue = $initializer;
while ($this->valid()) {
$accumulatedValue = $closure($accumulatedValue, $this->current());
$this->next();
}
return $accumulatedValue;
}
return null;
} | php | {
"resource": ""
} |
q258297 | MapIterator.genericKeysToKey | test | protected function genericKeysToKey($keysAndValues)
{
$keys = array_splice($keysAndValues, 0, count($keysAndValues) / 2);
if (count($keys) == 1) {
return $keys[0];
}
$value = $keys[0];
foreach ($keys as $key) {
if ($key !== $value) {
// the keys are different, we will make a new string identifying this entry
return join(
':',
array_map(
function ($key) {
return (string)$key;
},
$keys
)
);
}
}
// all values are the same, use it
return $value;
} | php | {
"resource": ""
} |
q258298 | GroupByTrait.groupBy | test | public function groupBy($strategy, $sort = true)
{
if (!is_bool($sort)) {
throw new \InvalidArgumentException('Argument $sort must be a boolean');
}
if ($this instanceof \Iterator) {
return new GroupbyIterator(
conversions\mixed_to_value_getter($strategy),
$sort ? $this->sorted($strategy) : $this
);
}
return null;
} | php | {
"resource": ""
} |
q258299 | Extension.reduce | test | public function reduce($iterable, $closure = 'add', $initializer = null)
{
return Itertools\reduce($iterable, $closure, $initializer);
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.