code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
private function getCsvWriterMock(array $keys, array $values): array
{
$entity = M::mock(Entity::class);
$entity->shouldReceive('getAttributes')->andReturn($keys);
$entity->shouldReceive('getAssociations')->andReturn([]);
$entry = M::mock(Entry::class);
$entry->shouldReceive('getResultsNodeID')->andReturn(1122);
$created = Carbon::now()->subDays(mt_rand(1, 10000));
$userInfo = M::mock(UserInfo::class);
$userInfo->shouldReceive('getUserDisplayName')->andReturn('author name');
$author = M::mock(User::class);
$author->shouldReceive('getUserInfoObject')->andReturn($userInfo);
$entry->shouldReceive('getDateCreated')->andReturn($created);
$entry->shouldReceive('getDateModified')->andReturn($created->copy()->addDays(20));
$entry->shouldReceive('getAuthor')->andReturn($author);
$entry->shouldReceive('getAttributes')->andReturn($values);
$entry->shouldReceive('getPublicIdentifier')->andReturn('abc');
$entry->shouldReceive('getAssociations')->andReturn([]);
$list = M::mock(TestEntryList::class);
$list->shouldReceive('deliverQueryObject')->andReturnSelf();
$list->shouldReceive('execute')->andReturn([$entry]);
$list->shouldReceive('getEntity')->andReturn($entity);
$list->shouldReceive('getResult')->andReturnUsing(function ($arg) {
return $arg;
});
$writer = M::mock(TestWriter::class);
$writer->shouldReceive('insertOne')->passthru();
$writer->shouldReceive('insertAll')->passthru();
$dateFormatter = M::mock(Date::class);
$dateFormatter->shouldReceive('formatCustom')->andReturn('not now');
$entityManager = M::mock(EntityManager::class);
$siteService = M::mock(Service::class);
$site = M::mock(Site::class);
$siteService->shouldReceive('getSiteByExpressResultsNodeID')->withArgs([1122])->andReturn($site);
$site->shouldReceive('getSiteHandle')->andReturn('foo');
$csvWriter = new CsvWriter($writer, $dateFormatter, $entityManager);
// Mock the site service
$csvWriter->setSiteService($siteService);
return array($entity, $list, $writer, $csvWriter);
}
|
@param array $entityKeys
@param array $entryKeys
@return array
|
getCsvWriterMock
|
php
|
concretecms/concretecms
|
tests/tests/Express/Export/EntryList/CsvWriterTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Express/Export/EntryList/CsvWriterTest.php
|
MIT
|
public function testSanitizeWithDefaultSettings($input, $expectedOutput)
{
$sanitized = self::$sanitizer->sanitizeData($input, self::$sanitizerOptions);
$lines = explode("\n", $sanitized);
static::assertRegExp('/^<\?xml\b[^>]*\?>$/', array_shift($lines));
$xml = trim(implode('', $lines));
static::assertSame($expectedOutput, $xml);
}
|
@param string $input
@param string $expectedOutput
@dataProvider provideSanitizeWithDefaultSettings
|
testSanitizeWithDefaultSettings
|
php
|
concretecms/concretecms
|
tests/tests/File/Image/Svg/SanitizerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/File/Image/Svg/SanitizerTest.php
|
MIT
|
public function testTypeShouldExistFor($imageWidth, $imageHeight, $thumbnailWidth, $thumbnailHeight, $sizingMode, $upscalingEnabled, $expectedResult)
{
$version = new ThumbnailTypeVersion(
null, // $directoryName
null, // $handle
null, // $name
$thumbnailWidth, // $width
$thumbnailHeight, // $height
false, // $isDoubledVersion = false
$sizingMode, // $sizingMode
false, // $limitedToFileSets
[], // $associatedFileSetIDs
$upscalingEnabled // $upscalingEnabled
);
$this->assertSame($expectedResult, $version->shouldExistFor($imageWidth, $imageHeight));
}
|
@dataProvider typeShouldExistForProvider
@param int|null $thumbnailWidth
@param int|null $thumbnailHeight
@param int|null $imageWidth
@param int|null $imageHeight
@param string $sizingMode
@param bool $expectedResult
|
testTypeShouldExistFor
|
php
|
concretecms/concretecms
|
tests/tests/File/Image/Thumbnail/ThumbnailTypeTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/File/Image/Thumbnail/ThumbnailTypeTest.php
|
MIT
|
public function testSplitFilename($full, $splitted)
{
$this->assertSame($splitted, $this->fileHelper->splitFilename($full));
}
|
@dataProvider splitFilenameDataProvider
@param mixed $full
@param mixed $splitted
|
testSplitFilename
|
php
|
concretecms/concretecms
|
tests/tests/File/Service/FileTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/File/Service/FileTest.php
|
MIT
|
public function testLegacyImageCreate($expectedWidth, $expectedHeight, $path, $width, $height, $fit = false)
{
$sl = $this->storageLocation;
$fsl = $sl->getFileSystemObject();
$service = new \Concrete\Core\File\Image\BasicThumbnailer($sl);
$service->setApplication(Application::getFacadeApplication());
$service->setJpegCompression(80);
$service->setPngCompression(9);
foreach (['auto', 'png', 'jpeg'] as $format) {
$service->setThumbnailsFormat($format);
if ($format === 'auto') {
$expectedFormat = preg_match('/\.p?jpe?g$/i', $path) ? 'jpeg' : 'png';
} else {
$expectedFormat = $format;
}
switch ($expectedFormat) {
case 'jpeg':
$expectedType = IMAGETYPE_JPEG;
break;
case 'png':
$expectedType = IMAGETYPE_PNG;
break;
default:
$expectedType = '???';
break;
}
foreach ($this->output as $output) {
$this->assertFalse($fsl->has($output), "{$output} should not exist");
}
$service->create($path, $this->output[$expectedFormat], $width, $height, $fit);
$this->assertTrue($fsl->has($this->output[$expectedFormat], "{$this->output[$expectedFormat]} should exist"));
list($width, $height, $type) = getimagesize(sys_get_temp_dir() . $this->output[$expectedFormat]);
$fsl->delete($this->output[$expectedFormat]);
$this->assertEquals($expectedWidth, $width, 'Invalid width');
$this->assertEquals($expectedHeight, $height, 'Invalid height');
$this->assertSame($expectedType, $type, "Wrong format for {$format}");
}
}
|
@dataProvider legacyImageCreateDataProvider
@param mixed $expectedWidth
@param mixed $expectedHeight
@param mixed $path
@param mixed $width
@param mixed $height
@param mixed $fit
|
testLegacyImageCreate
|
php
|
concretecms/concretecms
|
tests/tests/File/Service/ImageTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/File/Service/ImageTest.php
|
MIT
|
public function testZip($useNativeCommands, $includeDotFiles)
{
if ($this->fileSystemProblem !== null) {
$this->markTestIncomplete('Error setting up files and directories');
return;
}
$zh = $this->zipHelper;
if ($useNativeCommands) {
if (!$zh->isNativeCommandAvailable('zip') || !$zh->isNativeCommandAvailable('unzip')) {
$this->markTestIncomplete('Native zip/unzip commands are not available');
return;
}
$zh->enableNativeCommands();
} else {
$zh->disableNativeCommands();
}
$zh->zip($this->workDir . '/source', $this->workDir . '/file.zip', compact('includeDotFiles'));
$zh->zip(str_replace(DIRECTORY_SEPARATOR, '/', __DIR__), $this->workDir . '/file.zip', ['append' => true]);
$contents = $zh->listContents($this->workDir . '/file.zip');
$zh->unzip($this->workDir . '/file.zip', $this->workDir . '/destination');
foreach ($this->getDirectories() as $rel => $hidden) {
$abs = $this->workDir . '/destination/' . $rel;
if ($hidden && !$includeDotFiles) {
$this->assertFileNotExists($abs);
$this->assertArrayNotHasKey($rel, $contents);
} else {
$this->assertFileExists($abs);
$this->assertTrue(is_dir($abs));
$this->assertArrayHasKey($rel, $contents);
$this->assertArrayHasKey('type', $contents[$rel]);
$this->assertSame('D', $contents[$rel]['type']);
$this->assertArrayNotHasKey('originalSize', $contents[$rel]);
$this->assertArrayNotHasKey('compressedSize', $contents[$rel]);
}
}
foreach ($this->getFiles() as $rel => $hidden) {
$abs = $this->workDir . '/destination/' . $rel;
if ($hidden && !$includeDotFiles) {
$this->assertFileNotExists($abs);
$this->assertArrayNotHasKey($rel, $contents);
} else {
$this->assertFileExists($abs);
$this->assertTrue(is_file($abs));
$this->assertSame("This is the content of $rel", file_get_contents($abs));
$this->assertArrayHasKey($rel, $contents);
$this->assertArrayHasKey('type', $contents[$rel]);
$this->assertSame('F', $contents[$rel]['type']);
$this->assertArrayHasKey('originalSize', $contents[$rel]);
$this->assertArrayHasKey('compressedSize', $contents[$rel]);
}
}
$abs = $this->workDir . '/destination/' . str_replace(DIRECTORY_SEPARATOR, '/', basename(__FILE__));
$this->assertFileExists($abs);
$this->assertTrue(is_file($abs));
$this->assertSame(file_get_contents(__FILE__), file_get_contents($abs));
}
|
@dataProvider providerTestZip
@param mixed $useNativeCommands
@param mixed $includeDotFiles
|
testZip
|
php
|
concretecms/concretecms
|
tests/tests/File/Service/ZipTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/File/Service/ZipTest.php
|
MIT
|
public function testBasicStoreFile()
{
mkdir($this->getStorageDirectory());
$location = $this->getStorageLocation();
$filesystem = $location->getFileSystemObject();
$filesystem->write('foo.txt', 'This is a text file.');
$this->assertTrue($filesystem->has('foo.txt'));
$contents = $filesystem->get('foo.txt');
$this->assertEquals('This is a text file.', $contents->read());
}
|
This handles storing a file in the filesystem without any
fancy concrete5 prefixing.
|
testBasicStoreFile
|
php
|
concretecms/concretecms
|
tests/tests/File/StorageLocation/StorageLocationTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/File/StorageLocation/StorageLocationTest.php
|
MIT
|
public function testCreateElements($method, array $args, $expected, array $post = [])
{
if (empty($post)) {
self::$request->initialize();
} else {
self::$request->initialize([], $post, [], [], [], ['REQUEST_METHOD' => 'POST']);
}
$calculated = call_user_func_array([static::$formHelper, $method], $args);
if (strpos($expected, '**UNIQUENUMBER**') === false) {
$this->assertSame($expected, $calculated);
} else {
$chunks = explode('**UNIQUENUMBER**', $expected);
array_walk($chunks, function (&$chunk, $index) {
$chunk = preg_quote($chunk, '/');
});
$rx = '/^' . implode('\d+', $chunks) . '$/';
$this->assertRegExp($rx, $calculated);
}
}
|
@dataProvider providerTestCreateElements
@param mixed $method
@param array $args
@param mixed $expected
@param array $post
|
testCreateElements
|
php
|
concretecms/concretecms
|
tests/tests/Form/Service/FormTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Form/Service/FormTest.php
|
MIT
|
public function testClassAliases($a, $b)
{
// We still need to enable class loaders here otherwise the aliases won't work
$loader = ClassLoader::getInstance();
$loader->enable();
$class1 = new $a();
$class2 = new $b();
$this->assertEquals($class1, $class2);
}
|
@dataProvider aliasesClassesDataProvider
@param mixed $a
@param mixed $b
|
testClassAliases
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testApplicationCoreOverrideAutoloader($file, $destination, $class, $exists = true)
{
$destination = trim($destination, '/');
$destinationDirectory = DIR_APPLICATION . '/' . $destination;
$this->putFileIntoPlace($file, $destinationDirectory);
$classExists = $this->classExists($class);
$this->cleanUpFile(DIR_APPLICATION, $destination);
if ($exists) {
$this->assertTrue($classExists, sprintf('Class %s failed to load', $class));
} else {
$this->assertFalse($classExists, sprintf('Class %s loaded', $class));
}
}
|
@dataProvider applicationClassesDataProvider
@param mixed $file
@param mixed $destination
@param mixed $class
@param mixed $exists
|
testApplicationCoreOverrideAutoloader
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testApplicationLegacyAutoloader($file, $destination, $class, $exists = true)
{
$destination = trim($destination, '/');
$destinationDirectory = DIR_APPLICATION . '/' . $destination;
$this->putFileIntoPlace($file, $destinationDirectory);
$loader = ClassLoader::getInstance();
$loader->enableLegacyNamespace();
$loader->enable();
$classExists = $this->classExists($class);
$this->cleanUpFile(DIR_APPLICATION, $destination);
if ($exists) {
$this->assertTrue($classExists, sprintf('Class %s failed to load', $class));
} else {
$this->assertFalse($classExists, sprintf('Class %s loaded', $class));
}
}
|
@dataProvider applicationClassesLegacyDataProvider
@param mixed $file
@param mixed $destination
@param mixed $class
@param mixed $exists
|
testApplicationLegacyAutoloader
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testApplicationLegacyCustomNamespaceAutoloader($namespace, $file, $destination, $class)
{
$destination = trim($destination, '/');
$destinationDirectory = DIR_APPLICATION . '/' . $destination;
$this->putFileIntoPlace($file, $destinationDirectory);
$loader = ClassLoader::getInstance();
$loader->enableLegacyNamespace();
$loader->setApplicationNamespace($namespace);
$loader->enable();
$classExists = $this->classExists($class);
$this->cleanUpFile(DIR_APPLICATION, $destination);
$this->assertTrue($classExists, sprintf('Class %s failed to load', $class));
}
|
@dataProvider applicationClassesLegacyCustomNamespaceDataProvider
@param mixed $namespace
@param mixed $file
@param mixed $destination
@param mixed $class
|
testApplicationLegacyCustomNamespaceAutoloader
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testPackageAutoloader($pkgHandle, $file, $destination, $class, $exists = true)
{
$destination = trim($destination, '/');
$destinationDirectory = DIR_PACKAGES . '/' . $destination;
$this->putFileIntoPlace($file, $destinationDirectory);
$loader = ClassLoader::getInstance();
$loader->enable();
$package = $this->getMockBuilder('Concrete\Core\Package\Package')
->disableOriginalConstructor()
->getMock();
$package->expects($this->any())
->method('shouldEnableLegacyNamespace')
->will($this->returnValue(false));
$package->expects($this->any())
->method('getPackageHandle')
->will($this->returnValue($pkgHandle));
$loader->registerPackage($package);
$classExists = $this->classExists($class);
$this->cleanUpFile(DIR_PACKAGES, $destination);
if ($exists) {
$this->assertTrue($classExists, sprintf('Class %s failed to load', $class));
} else {
$this->assertFalse($classExists, sprintf('Class %s loaded', $class));
}
}
|
@dataProvider packageClassesDataProvider
@param mixed $pkgHandle
@param mixed $file
@param mixed $destination
@param mixed $class
@param mixed $exists
|
testPackageAutoloader
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testPackageLegacyAutoloader($pkgHandle, $file, $destination, $class, $exists = true)
{
$destination = trim($destination, '/');
$destinationDirectory = DIR_PACKAGES . '/' . $destination;
$this->putFileIntoPlace($file, $destinationDirectory);
$loader = ClassLoader::getInstance();
$loader->enable();
$package = $this->getMockBuilder('Concrete\Core\Package\Package')
->disableOriginalConstructor()
->getMock();
$package->expects($this->any())
->method('shouldEnableLegacyNamespace')
->will($this->returnValue(true));
$package->expects($this->any())
->method('getPackageHandle')
->will($this->returnValue($pkgHandle));
$loader->registerPackage($package);
$classExists = $this->classExists($class);
$this->cleanUpFile(DIR_PACKAGES, $destination);
if ($exists) {
$this->assertTrue($classExists, sprintf('Class %s failed to load', $class));
} else {
$this->assertFalse($classExists, sprintf('Class %s loaded', $class));
}
}
|
@dataProvider packageClassesLegacyDataProvider
@param mixed $pkgHandle
@param mixed $file
@param mixed $destination
@param mixed $class
@param mixed $exists
|
testPackageLegacyAutoloader
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testPackageCustomAutoloaders($package, $file, $destination, $classes, $exists = true)
{
$destination = trim($destination, '/');
$destinationDirectory = DIR_PACKAGES . '/' . $destination;
$this->putFileIntoPlace($file, $destinationDirectory);
$loader = ClassLoader::getInstance();
$loader->enable();
$loader->registerPackage($package);
$classExists = [];
foreach ($classes as $class) {
$classExists[] = $this->classExists($class);
}
$this->cleanUpFile(DIR_PACKAGES, $destination);
foreach ($classExists as $return) {
if ($exists) {
$this->assertTrue($return, sprintf('Class %s failed to load', $class));
} else {
$this->assertFalse($return, sprintf('Class %s loaded', $class));
}
}
}
|
@dataProvider packageCustomAutoloadersDataProvider
@param mixed $package
@param mixed $file
@param mixed $destination
@param mixed $classes
@param mixed $exists
|
testPackageCustomAutoloaders
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/ClassloaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/ClassloaderTest.php
|
MIT
|
public function testCoreClassCore($fragment, $class)
{
$this->assertEquals($class, core_class($fragment, false));
$this->assertTrue(class_exists($class), sprintf('Class %s does not exist', $class));
}
|
@dataProvider coreClassCoreDataProvider()
@param mixed $fragment
@param mixed $class
|
testCoreClassCore
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/OverrideableCoreClassTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/OverrideableCoreClassTest.php
|
MIT
|
public function testCoreClassPackage($fragment, $prefix, $legacyClass, $class)
{
$legacyPackage = $this->getMockBuilder('Concrete\Core\Package\Package')
->disableOriginalConstructor()
->getMock();
$legacyPackage->expects($this->any())
->method('shouldEnableLegacyNamespace')
->will($this->returnValue(true));
$package = $this->getMockBuilder('Concrete\Core\Package\Package')
->disableOriginalConstructor()
->getMock();
$package->expects($this->any())
->method('shouldEnableLegacyNamespace')
->will($this->returnValue(false));
$legacyService = $this->getMockBuilder('Concrete\Core\Package\PackageService')
->disableOriginalConstructor()
->getMock();
$legacyService->expects($this->any())
->method('getClass')
->will($this->returnValueMap([
[$prefix, $legacyPackage],
])
);
$service = $this->getMockBuilder('Concrete\Core\Package\PackageService')
->disableOriginalConstructor()
->getMock();
$service->expects($this->any())
->method('getClass')
->will($this->returnValueMap([
[$prefix, $package],
])
);
$app = Facade::getFacadeApplication();
$origService = $app->make('Concrete\Core\Package\PackageService');
$app['Concrete\Core\Package\PackageService'] = $legacyService;
$this->assertEquals($legacyClass, core_class($fragment, $prefix));
$app['Concrete\Core\Package\PackageService'] = $service;
$this->assertEquals($class, core_class($fragment, $prefix));
$app['Concrete\Core\Package\PackageService'] = $origService;
}
|
Tests both legacy and non-legacy class generation.
@dataProvider coreClassPackageDataProvider()
@param mixed $fragment
@param mixed $prefix
@param mixed $legacyClass
@param mixed $class
|
testCoreClassPackage
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/OverrideableCoreClassTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/OverrideableCoreClassTest.php
|
MIT
|
public function testCoreClassApplication($fragment, $legacyClass, $class)
{
\Config::save('app.enable_legacy_src_namespace', false);
$this->assertEquals($class, core_class($fragment, true));
\Config::save('app.enable_legacy_src_namespace', true);
$this->assertEquals($legacyClass, core_class($fragment, true));
\Config::save('app.enable_legacy_src_namespace', false);
}
|
@dataProvider coreClassApplicationDataProvider()
@param mixed $fragment
@param mixed $legacyClass
@param mixed $class
|
testCoreClassApplication
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/OverrideableCoreClassTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/OverrideableCoreClassTest.php
|
MIT
|
public function testOverrideableCoreClassCore($fragment, $path, $class)
{
$this->assertEquals($class, overrideable_core_class($fragment, $path, false));
}
|
@dataProvider overrideableCoreClassCoreDataProvider()
@param mixed $fragment
@param mixed $path
@param mixed $class
|
testOverrideableCoreClassCore
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/OverrideableCoreClassTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/OverrideableCoreClassTest.php
|
MIT
|
public function testOverrideableCoreClassPackage($pkgHandle, $fragment, $path, $legacyClass, $class)
{
$legacyPackage = $this->getMockBuilder('Concrete\Core\Package\Package')
->disableOriginalConstructor()
->getMock();
$legacyPackage->expects($this->any())
->method('shouldEnableLegacyNamespace')
->will($this->returnValue(true));
$package = $this->getMockBuilder('Concrete\Core\Package\Package')
->disableOriginalConstructor()
->getMock();
$package->expects($this->any())
->method('shouldEnableLegacyNamespace')
->will($this->returnValue(false));
$legacyService = $this->getMockBuilder('Concrete\Core\Package\PackageService')
->disableOriginalConstructor()
->getMock();
$legacyService->expects($this->any())
->method('getClass')
->will($this->returnValueMap([
[$pkgHandle, $legacyPackage],
])
);
$service = $this->getMockBuilder('Concrete\Core\Package\PackageService')
->disableOriginalConstructor()
->getMock();
$service->expects($this->any())
->method('getClass')
->will($this->returnValueMap([
[$pkgHandle, $package],
])
);
$app = Facade::getFacadeApplication();
$origService = $app->make('Concrete\Core\Package\PackageService');
$app['Concrete\Core\Package\PackageService'] = $legacyService;
$this->assertEquals($legacyClass, overrideable_core_class($fragment, $path, $pkgHandle));
$app['Concrete\Core\Package\PackageService'] = $service;
$this->assertEquals($class, overrideable_core_class($fragment, $path, $pkgHandle));
$app['Concrete\Core\Package\PackageService'] = $origService;
}
|
Tests both legacy and non-legacy class generation.
@dataProvider overrideableCoreClassPackageDataProvider()
@param mixed $pkgHandle
@param mixed $fragment
@param mixed $path
@param mixed $legacyClass
@param mixed $class
|
testOverrideableCoreClassPackage
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/OverrideableCoreClassTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/OverrideableCoreClassTest.php
|
MIT
|
public function testOverrideableCoreClassApplicationOverride($fragment, $path, $legacyClass, $class)
{
$path = trim($path, '/');
$env = Environment::get();
$env->clearOverrideCache();
$destinationDirectory = DIR_APPLICATION . '/' . dirname($path);
$this->putFileIntoPlace($path, $destinationDirectory);
\Config::save('app.enable_legacy_src_namespace', false);
$this->assertEquals($class, core_class($fragment, true));
\Config::save('app.enable_legacy_src_namespace', true);
$this->assertEquals($legacyClass, core_class($fragment, true));
\Config::save('app.enable_legacy_src_namespace', false);
$this->cleanUpFile(DIR_APPLICATION, $path);
}
|
@dataProvider overrideableCoreClassApplicationOverrideDataProvider()
@param mixed $fragment
@param mixed $path
@param mixed $legacyClass
@param mixed $class
|
testOverrideableCoreClassApplicationOverride
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/OverrideableCoreClassTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/OverrideableCoreClassTest.php
|
MIT
|
public function testFunctionAvailable($disabledFunctions, $functionName, $expected)
{
self::$functionInspector->setDisabledFunctions($disabledFunctions);
$this->assertSame($expected, self::$functionInspector->functionAvailable($functionName));
}
|
@dataProvider functionAvailableProvider
@param mixed $disabledFunctions
@param mixed $functionName
@param mixed $expected
|
testFunctionAvailable
|
php
|
concretecms/concretecms
|
tests/tests/Foundation/Environment/FunctionInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Foundation/Environment/FunctionInspectorTest.php
|
MIT
|
public function testMediaTypeMap($acceptValue, array $expectedMap)
{
$mediaTypeParser = $this->getMediaTypeParser($acceptValue);
$actualMap = $mediaTypeParser->getRequestAcceptMap();
$this->assertSame($expectedMap, $actualMap);
}
|
@dataProvider provideMediaTypeMap
@param string|mixed $acceptValue
@param array $expectedMap
|
testMediaTypeMap
|
php
|
concretecms/concretecms
|
tests/tests/Http/RequestMediaTypeParserTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Http/RequestMediaTypeParserTest.php
|
MIT
|
public function testAcceptMediaType($acceptValue, $mediaType, $minWeight, $expectedResult)
{
$mediaTypeParser = $this->getMediaTypeParser($acceptValue);
$actualResult = $mediaTypeParser->isMediaTypeSupported($mediaType, $minWeight);
$this->assertSame($expectedResult, $actualResult);
}
|
@dataProvider provideAcceptMediaType
@param string|mixed $acceptValue
@param string|string[] $mediaType
@param float|null $minWeight
@param bool $expectedResult
|
testAcceptMediaType
|
php
|
concretecms/concretecms
|
tests/tests/Http/RequestMediaTypeParserTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Http/RequestMediaTypeParserTest.php
|
MIT
|
protected function getMediaTypeParser($acceptValue)
{
$headers = Mockery::mock(HeaderBag::class);
$headers->shouldReceive('get')->withArgs(['accept'])->andReturn($acceptValue);
$request = Mockery::mock(Request::class);
$request->headers = $headers;
return new RequestMediaTypeParser($request);
}
|
@param string|mixed $acceptValue
@return \Concrete\Core\Http\RequestMediaTypeParser
|
getMediaTypeParser
|
php
|
concretecms/concretecms
|
tests/tests/Http/RequestMediaTypeParserTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Http/RequestMediaTypeParserTest.php
|
MIT
|
public function testGetActiveTranslateObject()
{
$this->loc->setActiveContext('test');
// The plain translator adapter does not have a translator object
// associated with it, so it should be returning null.
$this->assertNull($this->loc->getActiveTranslateObject());
}
|
Note: The tested method is deprecated so this test can be removed if
the method is removed in the future.
@deprecated
|
testGetActiveTranslateObject
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Localization2Test.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Localization2Test.php
|
MIT
|
public function testStaticGetTranslate()
{
$this->loc->setActiveContext('test');
$this->setupStaticTest();
// The plain translator adapter does not have a translator object
// associated with it, so it should be returning null.
$this->assertNull(Localization::getTranslate());
}
|
Note: The tested method is deprecated so this test can be removed if
the method is removed in the future.
@deprecated
|
testStaticGetTranslate
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Localization2Test.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Localization2Test.php
|
MIT
|
public function testStaticSetupSiteLocalization()
{
$this->markTestSkipped('Skipped');
// Move translation files
$langDir = DIR_TESTS . '/assets/Localization/Adapter/Laminas/Translation/Loader/Gettext/languages/site';
$appLangDir = static::getTranslationsFolder() . '/site';
$filesystem = new Filesystem();
if ($filesystem->exists($appLangDir)) {
static::markTestSkipped('The site languages directory already exists in the application folder. It should not exist for the testing purposes.');
}
$filesystem->copyDirectory($langDir, $appLangDir);
// Custom Localization instance for these tests
$loc = new Localization();
$translatorAdapterFactory = new LaminasTranslatorAdapterFactory();
$repository = new TranslatorAdapterRepository($translatorAdapterFactory);
$loc->setTranslatorAdapterRepository($repository);
$app = Facade::getFacadeApplication();
$app->bind('Concrete\Core\Localization\Localization', function () use ($loc) {
return $loc;
});
$app->bind('multilingual/detector', function () {
return new MultilingualDetector();
});
$loc->setContextLocale(Localization::CONTEXT_SITE, 'fi_FI');
$loc->setActiveContext(Localization::CONTEXT_SITE);
// Test setting setup site localization for the active translator
Localization::setupSiteLocalization();
$translator = $loc->getActiveTranslatorAdapter();
$this->assertEquals('Tervehdys sivustolta!', $translator->translate('Hello from site!'));
// Test setting setup site localization for custom translator
$translator = new LaminasTranslator();
$translator->setLocale('fi_FI');
Localization::setupSiteLocalization($translator);
$this->assertEquals('Tervehdys sivustolta!', $translator->translate('Hello from site!'));
// Remove the added languages directory
$filesystem->deleteDirectory($appLangDir);
}
|
These tests should already be tested when testing the site translation
loader but this assures that the deprecated wrapper method within the
Localization class also works properly.
Note: The tested method is deprecated so this test can be removed if
the method is removed in the future.
@deprecated
|
testStaticSetupSiteLocalization
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Localization2Test.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Localization2Test.php
|
MIT
|
public static function setUpBeforeClass():void
{
parent::setUpBeforeClass();
$filesystem = new Filesystem();
if (!$filesystem->isWritable(DIR_PACKAGES)) {
throw new Exception('Cannot write to the packages directory for the testing purposes. Please check permissions!');
}
$packages = self::getTestPackages();
// First make sure that none of the packages already exist
foreach ($packages as $pkg => $dir) {
if ($filesystem->exists(DIR_PACKAGES . '/' . $pkg)) {
throw new Exception("A package directory for a package named ${pkg} already exists. It cannot exist prior to running these tests.");
}
}
// Then, move the package folders to the package folder
foreach ($packages as $pkg => $dir) {
$target = DIR_PACKAGES . '/' . $pkg;
$filesystem->copyDirectory($dir, $target);
}
}
|
Move a couple of test packages to the packages folder to be used by
these tests.
|
setUpBeforeClass
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Adapter/Laminas/Translation/Loader/Gettext/PackagesTranslationLoaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Adapter/Laminas/Translation/Loader/Gettext/PackagesTranslationLoaderTest.php
|
MIT
|
public static function TearDownAfterClass():void
{
$installPackages = self::getTestPackages();
$filesystem = new Filesystem();
foreach ($installPackages as $pkg => $dir) {
$target = DIR_PACKAGES . '/' . $pkg;
$filesystem->deleteDirectory($target);
}
parent::tearDownAfterClass();
}
|
Delete all the temporary package folders from the packages directory
after all tests have run.
|
TearDownAfterClass
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Adapter/Laminas/Translation/Loader/Gettext/PackagesTranslationLoaderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Adapter/Laminas/Translation/Loader/Gettext/PackagesTranslationLoaderTest.php
|
MIT
|
public function testFormatUnknownIsoCompatibleAdministrativeAreaInEnglish()
{
$address = new Address();
// The address locale sets the order of the address fields in the print
// out and defines in which language the administrative area is printed
$address = $address->withLocale('en');
$address = $address->withCountryCode('JP');
$address = $address->withAddressLine1('1 Chome - 13');
$address = $address->withAdministrativeArea('13');
$address = $address->withLocality('Chiyoda');
$address = $address->withPostalCode('101-0054');
$this->assertEquals(
'1 Chome - 13' . "\n" .
'Chiyoda, Tokyo' . "\n" .
'101-0054' . "\n" .
'Japan',
$this->formatTextAddressFor($address)
);
}
|
Same as above but address is written in English and printed out in
English.
|
testFormatUnknownIsoCompatibleAdministrativeAreaInEnglish
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Address/FormatterTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Address/FormatterTest.php
|
MIT
|
public function testFormatUnknownAdministrativeAreaKnownToCms()
{
$address = new Address();
// The address locale sets the order of the address fields in the print
// out and defines in which language the administrative area is printed
$address = $address->withLocale('en');
$address = $address->withCountryCode('IE');
$address = $address->withAddressLine1('Baldoyle Ind Est, 13');
$address = $address->withAdministrativeArea('CO DUBLIN');
$address = $address->withLocality('Dublin');
$address = $address->withPostalCode('WN7 4TN');
$this->assertEquals(
'Baldoyle Ind Est, 13' . "\n" .
'Dublin' . "\n" .
'County Dublin'. "\n" .
'WN7 4TN' . "\n" .
'Ireland',
$this->formatTextAddressFor($address)
);
}
|
The CMS has subdivisions defined for some countries that do not have any
known subdivisions in commerceguys/addressing. This tests that for this
kind of country subdivision that cannot be found from
commerceguys/addressing is correctly fetched through the CMS's own
country/province list.
|
testFormatUnknownAdministrativeAreaKnownToCms
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Address/FormatterTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Address/FormatterTest.php
|
MIT
|
private function formatTextAddressFor(
Address $address,
$locale = 'en'
) {
$options = [
'locale' => $locale, // the locale in which the country is printed
'html' => false,
];
return $this->formatter->format($address, $options);
}
|
Formats the address for the given address object.
@param Address $address the address object to be formatted
@param string $locale the locale code in which to format the address,
affects the country name
@return string the formatted address text
|
formatTextAddressFor
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Address/FormatterTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Address/FormatterTest.php
|
MIT
|
public function testFormatText()
{
foreach ($this->testLocales as $locale) {
foreach ($this->testAddresses as $data) {
$expected = $this->getExpectedFormatWithLocale(
$data,
'text',
$locale
);
$formatted = $this->addressFormat->format(
$data['source'],
'text',
$locale
);
$this->assertEquals($expected, $formatted);
}
}
}
|
Tests the text formatting of addresses.
|
testFormatText
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Service/AddressFormatTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Service/AddressFormatTest.php
|
MIT
|
public function testFormatHtml()
{
foreach ($this->testLocales as $locale) {
foreach ($this->testAddresses as $data) {
$expected = '<div class="ccm-address-text">' . "\n";
$expected .= $this->getExpectedFormatWithLocale(
$data,
'html',
$locale
);
$expected .= "\n" . '</div>';
$formatted = $this->addressFormat->format(
$data['source'],
'html',
$locale
);
$this->assertEquals($expected, $formatted);
}
}
}
|
Tests the HTML formatting of addresses.
|
testFormatHtml
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Service/AddressFormatTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Service/AddressFormatTest.php
|
MIT
|
public function testSystemLocalization()
{
foreach ($this->testLocales as $locale) {
Localization::changeLocale($locale);
foreach ($this->testAddresses as $data) {
$country = $this->getCountryNameWithLocale(
$data['source']['country'],
$locale
);
$expected = $this->getExpectedFormatWithLocale(
$data,
'text',
$locale
);
$formatted = $this->addressFormat->format(
$data['source'],
'text'
);
$this->assertEquals($expected, $formatted);
}
}
Localization::changeLocale(Localization::BASE_LOCALE);
}
|
Tests the text formatting of addresses in case the locale is not
specifically defined for the `AddressFormat::format()` method.
|
testSystemLocalization
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Service/AddressFormatTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Service/AddressFormatTest.php
|
MIT
|
public function testFormatWithoutRequiredFields()
{
$address = [
'address1' => '877 S Figueroa St',
'country' => 'US',
'postal_code' => '90017',
];
$expected = (
'877 S Figueroa St' . "\n" .
'90017' . "\n" .
'United States'
);
$formatted = $this->addressFormat->format($address, 'text');
$this->assertEquals($expected, $formatted);
}
|
Tests the address formatting when not all required fields are provided
for the country.
|
testFormatWithoutRequiredFields
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Service/AddressFormatTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Service/AddressFormatTest.php
|
MIT
|
public function testFormatWithoutCountry()
{
$address = [
'address1' => '877 S Figueroa St',
'city' => 'Los Angeles',
'state_province' => 'CA',
'postal_code' => '90017',
];
$expected = (
'877 S Figueroa St' . "\n" .
'Los Angeles, CA 90017'
);
$formatted = $this->addressFormat->format($address, 'text');
$this->assertEquals($expected, $formatted);
}
|
Tests the address formatting when a country is not provided.
|
testFormatWithoutCountry
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Service/AddressFormatTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Service/AddressFormatTest.php
|
MIT
|
protected function getTranslatorAdapterDirectly($context, $locale)
{
$adapters = $this->getRegisteredAdapters();
$reflection = new ReflectionObject($this->repository);
$method = $reflection->getMethod('getKey');
$method->setAccessible(true);
$key = $method->invoke($this->repository, $context, $locale);
$method->setAccessible(false);
return array_key_exists($key, $adapters) ? $adapters[$key] : null;
}
|
Gets a translator adapter from the repository directly from the
protected array within the repository. This can be used e.g. for testing
that the adapters are actually removed/added to the repository's array
because for instace the `getTranslatorAdapter()` method in the class
would create a new instance if it does not already exist for the fetched
key.
@param string $context
@param string $locale
@return \Concrete\Core\Localization\Translator\TranslatorAdapterInterface
|
getTranslatorAdapterDirectly
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Translator/TranslatorAdapterRepositoryTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Translator/TranslatorAdapterRepositoryTest.php
|
MIT
|
protected function getRegisteredAdapters()
{
$reflection = new ReflectionObject($this->repository);
$property = $reflection->getProperty('adapters');
$property->setAccessible(true);
$adapters = $property->getValue($this->repository);
$property->setAccessible(false);
return $adapters;
}
|
Gets the registered translator adapters array directly from the
protected property within the repository. This can be used in tests that
need information about this protected property.
@return array
|
getRegisteredAdapters
|
php
|
concretecms/concretecms
|
tests/tests/Localization/Translator/TranslatorAdapterRepositoryTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Localization/Translator/TranslatorAdapterRepositoryTest.php
|
MIT
|
protected function getNoopProcessorApplication()
{
$noop = function($data) { return $data; };
$app = M::mock(Application::class);
$app->shouldReceive('make')->withArgs([ConcreteUserProcessor::class])->andReturn($noop);
$app->shouldReceive('make')->withArgs([PsrLogMessageProcessor::class])->andReturn($noop);
$app->shouldReceive('make')->withArgs([ConcretePageProcessor::class])->andReturn($noop);
return $app;
}
|
Build an application mock that returns noop processors
@return M\MockInterface|Application
|
getNoopProcessorApplication
|
php
|
concretecms/concretecms
|
tests/tests/Logging/LogTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Logging/LogTest.php
|
MIT
|
public function testRegisterDuplicate()
{
$default = Section::getDefaultSection();
$second = Section::getByLocale('de_CH');
// Create two pages in the same language section
$oldPage = self::createPage('Old Page', $default);
$newPage = $oldPage->duplicate($default);
// When duplicating a page within the same language tree, a new mpRelationID should created for a new page.
$this->assertNotEquals(
Section::getMultilingualPageRelationID($oldPage->getCollectionID()),
Section::getMultilingualPageRelationID($newPage->getCollectionID()),
'A page duplicated in the same locale, but did not created new mpRelationID.'
);
// Create a page in the second locale
$newPageInSecondLocale = $oldPage->duplicate($second);
// If you duplicate a page into a different language tree, it should get the same mpRelationID.
$this->assertEquals(
Section::getMultilingualPageRelationID($oldPage->getCollectionID()),
Section::getMultilingualPageRelationID($newPageInSecondLocale->getCollectionID()),
'Two pages are related between two locales, but we could not get same mpRelationID.'
);
$oldPage->delete();
$newPage->delete();
$newPageInSecondLocale->delete();
}
|
This test will check if c5 can duplicate a page on the multilingual site correctly.
@see https://github.com/concrete5/concrete5/issues/7430
|
testRegisterDuplicate
|
php
|
concretecms/concretecms
|
tests/tests/Multilingual/SectionTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Multilingual/SectionTest.php
|
MIT
|
public function testTableUpdates()
{
// The easiest way to test that the DB is updated properly is to make
// two consecutive calls to Package::installDB(). This is actually what
// the package also internally does during the install() and upgrade()
// calls and also what the block types do when the refresh() method is
// called on them. So, this should cover the actual scenarios we want
// to cover here.
$db = Database::get();
// Make sure the DB is in the initial state
$schema = $db->getSchemaManager()->createSchema();
$this->assertFalse($schema->hasTable('TestPackageTable'));
// Create the table initially.
Package::installDB(DIR_TESTS . '/assets/Package/db-1.xml', ContentImporter::IMPORT_MODE_INSTALL);
// Make sure the table was properly created and it contains the column
// we are about to remove does NOT contain the column we are about to
// add.
$schema = $db->getSchemaManager()->createSchema();
$this->assertTrue($schema->hasTable('TestPackageTable'));
$tbl = $schema->getTable('TestPackageTable');
$this->assertFalse($tbl->hasColumn('newColumn'));
$this->assertTrue($tbl->hasColumn('testColumn'));
// db-2.xml modifies the already existing table.
Package::installDB(DIR_TESTS . '/assets/Package/db-2.xml');
// Make sure the column exists in the updated database that is added in
// db-2.xml. Also make sure that the column we drop in db-2.xml no
// longer exists in the table. This is what we actually want to test
// here.
$schema = $db->getSchemaManager()->createSchema();
$tbl = $schema->getTable('TestPackageTable');
$this->assertTrue($tbl->hasColumn('newColumn'));
$this->assertFalse($tbl->hasColumn('testColumn'));
}
|
Tests that the table is properly updated according to the updated
database schema XML file when the database table already exists.
|
testTableUpdates
|
php
|
concretecms/concretecms
|
tests/tests/Package/DbXmlTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/DbXmlTest.php
|
MIT
|
public function testTestForInstall(Package $package, array $installedPackages, array $expectedErrors = [])
{
self::$checker->setInstalledPackages($installedPackages);
$errors = self::$checker->testForInstall($package)->getList();
$this->assertEquals($expectedErrors, $errors);
}
|
@dataProvider installProvider
@param Package $package
@param array $installedPackages
@param array $expectedErrors
|
testTestForInstall
|
php
|
concretecms/concretecms
|
tests/tests/Package/DependencyCheckerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/DependencyCheckerTest.php
|
MIT
|
public function testTestForUninstall(Package $package, array $otherInstalledPackages, array $expectedErrors = [])
{
self::$checker->setInstalledPackages(array_merge([$package], $otherInstalledPackages));
$errors = self::$checker->testForUninstall($package)->getList();
$this->assertEquals($expectedErrors, $errors);
}
|
@dataProvider uninstallProvider
@param Package $package
@param array $otherInstalledPackages
@param array $expectedErrors
|
testTestForUninstall
|
php
|
concretecms/concretecms
|
tests/tests/Package/DependencyCheckerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/DependencyCheckerTest.php
|
MIT
|
private function createPackage($handle, $version, $name, array $packageDependencies)
{
$package = $this->getMockForAbstractClass(Package::class, [], '', false);
$reflectionClass = new ReflectionClass($package);
foreach ([
'pkgHandle' => $handle,
'pkgVersion' => $version,
'pkgName' => $name,
'packageDependencies' => $packageDependencies,
] as $propertyName => $propertyValue) {
try {
$reflectionProperty = $reflectionClass->getProperty($propertyName);
} catch (ReflectionException $x) {
$reflectionProperty = null;
}
if ($reflectionProperty === null) {
$package->$propertyName = $propertyValue;
} else {
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($package, $propertyValue);
}
}
return $package;
}
|
@param string $handle
@param string $version
@param string $name
@param array $packageDependencies
@return Package
|
createPackage
|
php
|
concretecms/concretecms
|
tests/tests/Package/DependencyCheckerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/DependencyCheckerTest.php
|
MIT
|
public function testExtractHandle($filename, array $expectedInfo)
{
$info = self::$inspector->inspectControllerFile(DIR_TESTS . '/assets/Package/offline/' . $filename);
$this->assertInstanceOf(PackageInfo::class, $info);
$this->assertSame($expectedInfo['handle'], $info->getHandle());
}
|
@dataProvider validPackagesProvider
@param string $filename
@param array $expectedInfo
|
testExtractHandle
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
public function testExtractVersion($filename, array $expectedInfo)
{
$info = self::$inspector->inspectControllerFile(DIR_TESTS . '/assets/Package/offline/' . $filename);
$this->assertInstanceOf(PackageInfo::class, $info);
$this->assertSame($expectedInfo['version'], $info->getVersion());
}
|
@dataProvider validPackagesProvider
@param string $filename
@param array $expectedInfo
|
testExtractVersion
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
public function testExtractName($filename, array $expectedInfo)
{
$info = self::$inspector->inspectControllerFile(DIR_TESTS . '/assets/Package/offline/' . $filename);
$this->assertInstanceOf(PackageInfo::class, $info);
$this->assertSame($expectedInfo['name'], $info->getName());
}
|
@dataProvider validPackagesProvider
@param string $filename
@param array $expectedInfo
|
testExtractName
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
public function testExtractDescription($filename, array $expectedInfo)
{
$info = self::$inspector->inspectControllerFile(DIR_TESTS . '/assets/Package/offline/' . $filename);
$this->assertInstanceOf(PackageInfo::class, $info);
$this->assertSame($expectedInfo['description'], $info->getDescription());
}
|
@dataProvider validPackagesProvider
@param string $filename
@param array $expectedInfo
|
testExtractDescription
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
public function testExtractMinimumCoreVersion($filename, array $expectedInfo)
{
$info = self::$inspector->inspectControllerFile(DIR_TESTS . '/assets/Package/offline/' . $filename);
$this->assertInstanceOf(PackageInfo::class, $info);
$this->assertSame($expectedInfo['minimumCoreVersion'], $info->getMinimumCoreVersion());
}
|
@dataProvider validPackagesProvider
@param string $filename
@param array $expectedInfo
|
testExtractMinimumCoreVersion
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
public function testInvalidPackagesByFile($filename, $expectedExceptionCode)
{
try {
self::$inspector->inspectControllerFile(DIR_TESTS . '/assets/Package/offline/' . $filename);
$exception = null;
} catch (Exception $x) {
$exception = $x;
}
$this->assertNotNull($exception);
$this->assertSame($expectedExceptionCode, $exception->getCode());
}
|
@dataProvider invalidPackagesByFileProvider
@param string $filename
@param int $expectedExceptionCode
|
testInvalidPackagesByFile
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
public function testInvalidPackagesByContent($content, $expectedExceptionCode)
{
try {
self::$inspector->inspectControllerContent($content);
$exception = null;
} catch (Exception $x) {
$exception = $x;
}
$this->assertNotNull($exception);
$this->assertSame($expectedExceptionCode, $exception->getCode());
}
|
@dataProvider invalidPackagesByContentProvider
@param string $content
@param int $expectedExceptionCode
|
testInvalidPackagesByContent
|
php
|
concretecms/concretecms
|
tests/tests/Package/OfflineInspectorTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Package/OfflineInspectorTest.php
|
MIT
|
protected function getTables()
{
foreach(['Blocks', 'CollectionVersionBlocksOutputCache'] as $t) {
if (!in_array($t, $this->tables, true)) {
$this->tables[] = $t;
}
}
return parent::getTables();
}
|
{@inheritDoc}
@see \Concrete\TestHelpers\Database\ConcreteDatabaseTestCase::getTables()
|
getTables
|
php
|
concretecms/concretecms
|
tests/tests/Page/ClonerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Page/ClonerTest.php
|
MIT
|
protected function getMetadatas()
{
if (!in_array(BlockTypeEntity::class, $this->metadatas, true)) {
$this->metadatas[] = BlockTypeEntity::class;
}
return parent::getMetadatas();
}
|
{@inheritdoc}
@see \Concrete\TestHelpers\Database\ConcreteDatabaseTestCase::getMetadatas()
|
getMetadatas
|
php
|
concretecms/concretecms
|
tests/tests/Page/ClonerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Page/ClonerTest.php
|
MIT
|
public function testCanonicalPagePaths()
{
$home = Page::getByID(Page::getHomePageID());
$pt = Type::getByID(1);
$template = Template::getByID(1);
$page = $home->add($pt, [
'uID' => 1,
'cName' => 'Test page',
'pTemplateID' => $template->getPageTemplateID(),
]);
$path = $page->getCollectionPathObject();
$this->assertInstanceOf('\Concrete\Core\Entity\Page\PagePath', $path);
$this->assertEquals('/test-page', $path->getPagePath());
$this->assertEquals($path->isPagePathCanonical(), true);
$newpage = $page->add($pt, [
'uID' => 1,
'cName' => 'Another page for testing!',
'pTemplateID' => $template->getPageTemplateID(),
]);
$path = $newpage->getCollectionPathObject();
$this->assertEquals('/test-page/another-page-testing', $path->getPagePath());
$this->assertEquals($path->isPagePathCanonical(), true);
}
|
Add a page and check its canonical path.
|
testCanonicalPagePaths
|
php
|
concretecms/concretecms
|
tests/tests/Page/PagePathTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Page/PagePathTest.php
|
MIT
|
public function testPageNames($name, $special)
{
$page = self::createPage($name);
$parentID = $page->getCollectionParentID();
$this->assertSame($page->getCollectionName(), $name);
$th = Loader::helper('text');
if (!$special) {
$this->assertSame($page->getCollectionPath(), '/' . $th->urlify($name));
$this->assertSame($page->getCollectionHandle(), $th->urlify($name));
} else {
$this->assertSame($page->getCollectionPath(), '/' . (string) $page->getCollectionID());
$this->assertSame($page->getCollectionHandle(), '');
}
$page->delete();
}
|
@dataProvider pageNames
@param mixed $name
@param mixed $special
|
testPageNames
|
php
|
concretecms/concretecms
|
tests/tests/Page/PageTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Page/PageTest.php
|
MIT
|
public function testPageDisplayOrderUpdateFiresEvent()
{
$parent = self::createPage('Parent page to test display order of sub pages');
$page1 = self::createPage('Page1', $parent);
$page2 = self::createPage('Page2', $parent);
$page3 = self::createPage('Page3', $parent);
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $director */
$director = $this->app->make('director');
$map = [];
$listener = function ($event) use (&$map) {
$map[$event->getPageObject()->getCollectionName()]['old'] = $event->getOldDisplayOrder();
$map[$event->getPageObject()->getCollectionName()]['new'] = $event->getNewDisplayOrder();
};
$director->addListener('on_page_display_order_update', $listener);
$page1->updateDisplayOrder(10);
$this->assertEquals(0, $map[$page1->getCollectionName()]['old'], 'First page should always be index 0.');
$this->assertEquals(10, $map[$page1->getCollectionName()]['new']);
$page2->updateDisplayOrder(5);
$this->assertEquals(1, $map[$page2->getCollectionName()]['old'], 'Second page should always be index 1.');
$this->assertEquals(5, $map[$page2->getCollectionName()]['new']);
$page1->updateDisplayOrder(99, $page3->getCollectionID());
$this->assertEquals(2, $map[$page3->getCollectionName()]['old'], 'Third page should always be index 2.');
$this->assertEquals(99, $map[$page3->getCollectionName()]['new']);
$director->removeListener('on_page_display_order_update', $listener);
}
|
Test if the on_page_display_order_update event works OK.
|
testPageDisplayOrderUpdateFiresEvent
|
php
|
concretecms/concretecms
|
tests/tests/Page/PageTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Page/PageTest.php
|
MIT
|
protected function getVersion($index)
{
$this->page->loadVersionObject($this->cvIDs[$index]);
return $this->page->getVersionObject();
}
|
@param int $index
@return \Concrete\Core\Page\Collection\Version\Version
|
getVersion
|
php
|
concretecms/concretecms
|
tests/tests/Page/Collection/Version/ApproveTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Page/Collection/Version/ApproveTest.php
|
MIT
|
public function testRouteDestination(Application $app, $path, $callable)
{
$checked = false;
if (preg_match('/^([^:]+)::([^:]+)$/', $callable, $m)) {
$class = $m[1];
$method = $m[2];
if ($method === '__construct') {
$this->assertTrue(class_exists($m[1], true), "No class! Invalid route for path {$path} : {$callable}");
$checked = true;
} elseif (interface_exists($class, true)) {
$this->assertTrue(method_exists($class, $method), "No Method! Invalid route for path {$path} : {$callable}");
$checked = true;
} elseif ($app->isAlias($class)) {
$this->assertTrue(method_exists($class, $method), "Alias but no method! Invalid route for path {$path} : {$callable}");
}
}
if ($checked === false) {
if (PHP_MAJOR_VERSION < 8) {
$this->assertTrue(is_callable($callable), "Not callable! Invalid route for path {$path} : {$callable}");
} else {
// PHP 8 is_callable only works on static methods
// get_class_methods only returns public methods so its similar to the old behaviour
$this->assertTrue(class_exists($class) && in_array($method, get_class_methods($class)), "Not callable! Invalid route for path {$path} : {$callable}");
}
}
}
|
@dataProvider routeDestinationProvider
@param $app Application
@param $path string
@param $callable mixed
|
testRouteDestination
|
php
|
concretecms/concretecms
|
tests/tests/Routing/CheckRoutesTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Routing/CheckRoutesTest.php
|
MIT
|
public function setUp():void
{
$locale = new \Concrete\Core\Entity\Site\Locale();
$locale->setCountry('US');
$locale->setLanguage('en');
$siteTree = new \Concrete\Core\Entity\Site\SiteTree();
$siteTree->setLocale($locale);
$service = Core::make('helper/navigation');
$page = new Page();
self::setNonPublicPropertyValues($page, [
'siteTree' => $siteTree,
'cPath' => '/path/to/my/page',
'error' => false,
'siteTree' => $siteTree,
]);
$dashboard = new Page();
self::setNonPublicPropertyValues($dashboard, [
'cPath' => '/dashboard/my/awesome/page',
'error' => false,
'siteTree' => $siteTree,
]);
$this->page = $page;
$this->dashboard = $dashboard;
$this->service = $service;
$app = \Concrete\Core\Support\Facade\Facade::getFacadeApplication();
$app->bind('\Psr\Log\LoggerInterface', function () {
return new \Psr\Log\NullLogger();
});
Config::set('concrete.seo.url_rewriting', false);
Config::set('concrete.seo.url_rewriting_all', false);
$siteConfig = Core::make('site')->getSite()->getConfigRepository();
$this->oldUrl = $siteConfig->get('seo.canonical_url');
$siteConfig->set('seo.canonical_url', 'http://dummyurl.com');
parent::setUp();
}
|
Here's the expected behavior.
All URLs generated should have index.php in front of them if
concrete.seo.url_rewriting is false.
If concrete.seo.url_rewriting is true, then all URLs should have
no index.php, unless they're in the Dashboard.
If concrete.seo.url_rewriting_all is true, then all URLs (including Dashboard)
should be free of index.php.
This should be the case whether something is being called via URL::to, URL::page,
or Page::getCollectionLink or \Concrete\Core\Html\Service\Navigation::getLinkToCollection
|
setUp
|
php
|
concretecms/concretecms
|
tests/tests/Routing/URLTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Routing/URLTest.php
|
MIT
|
public function testDetectPrettyUrl($found, $htaccess)
{
$this->assertSame($found, self::$configurator->hasRule($htaccess, self::$prettyUrlRule));
}
|
@dataProvider detectPrettyUrlProvider
@param mixed $found
@param mixed $htaccess
|
testDetectPrettyUrl
|
php
|
concretecms/concretecms
|
tests/tests/Service/ApacheRulesTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Service/ApacheRulesTest.php
|
MIT
|
public function testAddPrettyUrl($before, $after)
{
$resulting = self::$configurator->addRule($before, self::$prettyUrlRule);
$this->assertSame($after, $resulting);
}
|
@dataProvider addPrettyUrlProvider
@param mixed $before
@param mixed $after
|
testAddPrettyUrl
|
php
|
concretecms/concretecms
|
tests/tests/Service/ApacheRulesTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Service/ApacheRulesTest.php
|
MIT
|
public function testRemovePrettyUrl($before, $after)
{
$resulting = self::$configurator->removeRule($before, self::$prettyUrlRule);
$this->assertSame($after, $resulting);
}
|
@dataProvider removePrettyUrlProvider
@param mixed $before
@param mixed $after
|
testRemovePrettyUrl
|
php
|
concretecms/concretecms
|
tests/tests/Service/ApacheRulesTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Service/ApacheRulesTest.php
|
MIT
|
public function testAddedToRequest()
{
$this->app[Request::class] = $this->request;
$session = $this->factory->createSession();
$this->assertEquals($session, $this->request->getSession());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\SessionInterface', $this->request->getSession());
}
|
This should be removed and moved into a request middleware layer, lets just make sure it happens here for now.
|
testAddedToRequest
|
php
|
concretecms/concretecms
|
tests/tests/Session/SessionFactoryTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Session/SessionFactoryTest.php
|
MIT
|
private function getFileTrackableMock($usedFiles, $collectionID, $collectionVersionID)
{
$collectionClass = $this->getMockClass(Collection::class);
$collection = new $collectionClass();
$collection->method('getCollectionID')->willReturn($collectionID);
$collection->method('getVersionID')->willReturn($collectionVersionID);
$trackable = $this->getMockForAbstractClass(FileTrackableInterface::class);
$trackable->method('getUsedFiles')->willReturn($usedFiles);
return [$collection, $trackable];
}
|
@param $usedFiles
@param $collectionID
@param $collectionVersionID
@return array
|
getFileTrackableMock
|
php
|
concretecms/concretecms
|
tests/tests/Statistics/UsageTracker/FileUsageTrackerTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Statistics/UsageTracker/FileUsageTrackerTest.php
|
MIT
|
private function returnCallable($tracker)
{
return function () use ($tracker) {
return $tracker;
};
}
|
Method to make it easy to bind an existing object to the IoC.
@param $tracker
@return \Closure
|
returnCallable
|
php
|
concretecms/concretecms
|
tests/tests/Statistics/UsageTracker/ServiceProviderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Statistics/UsageTracker/ServiceProviderTest.php
|
MIT
|
private function createApplication()
{
$app = new Application();
// This service provider requires a config repository be registered
$loader = $this->createMockFromClass(LoaderInterface::class);
$saver = $this->createMockFromClass(SaverInterface::class);
$repository = new Repository($loader, $saver, 'test');
$app->bind('config', $this->returnCallable($repository));
$app->bind(Application::class, $this->returnCallable($app));
return $app;
}
|
Create an application object to test with.
@return \Concrete\Core\Application\Application
|
createApplication
|
php
|
concretecms/concretecms
|
tests/tests/Statistics/UsageTracker/ServiceProviderTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Statistics/UsageTracker/ServiceProviderTest.php
|
MIT
|
public function testMutex(Application $app, $mutexClass)
{
$isSupported = $mutexClass . '::isSupported';
if (call_user_func($isSupported, $app) !== true) {
$this->markTestSkipped($mutexClass . ' mutex is not supported');
}
$mutex = $app->make($mutexClass);
/* @var \Concrete\Core\System\Mutex\MutexInterface $mutex */
$key1 = 'ccm-test-mutex-1-' . mt_rand(0, mt_getrandmax());
$key2 = 'ccm-test-mutex-2-' . mt_rand(0, mt_getrandmax());
try {
// Let's check that the mutex works when there's no concurrency.
$executed = false;
$mutex->execute($key1, function () use (&$executed) { $executed = true; });
$this->assertTrue($executed);
// Let's acquire two mutexes
$mutex->acquire($key1);
$mutex->acquire($key2);
// Let's be sure that acquiring again these mutex fails
$error = null;
try {
$mutex->acquire($key1);
} catch (MutexBusyException $x) {
$error = $x;
}
$this->assertInstanceOf(MutexBusyException::class, $error);
$error = null;
try {
$mutex->execute($key2, function () {});
} catch (MutexBusyException $x) {
$error = $x;
}
$this->assertInstanceOf(MutexBusyException::class, $error);
// Let's launch another process, so that we can check that the mutex system works across different processes
$mutex->release($key2);
foreach ([$key1 => 'Mutex busy', $key2 => 'Mutex acquired'] as $key => $result) {
$cmd = escapeshellarg(PHP_BINARY);
if (PHP_SAPI === 'phpdbg') {
$cmd .= ' -qrr';
}
$cmd .= ' ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, DIR_BASE_CORE . '/bin/concrete5'));
$cmd .= ' c5:exec';
$cmd .= ' --no-interaction --ansi';
$cmd .= ' ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, DIR_TESTS . '/assets/System/acquire-mutex.php'));
$cmd .= ' ' . escapeshellarg(get_class($mutex));
$cmd .= ' ' . escapeshellarg($key);
$cmd .= ' 2>&1';
$rc = -1;
$output = [];
@exec($cmd, $output, $rc);
if ($rc !== 0) {
$this->markTestSkipped('Failed to launch PHP to check mutex (' . implode("\n", $output) . ')');
}
$this->assertSame($result, $output[0]);
}
} finally {
$mutex->release($key2);
$mutex->release($key1);
}
}
|
@dataProvider mutexProvider
@param string $mutexClass
@param Application $app
|
testMutex
|
php
|
concretecms/concretecms
|
tests/tests/System/MutexTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/System/MutexTest.php
|
MIT
|
public function testMutexConfiguration(Application $app, array $mutexConfig, $expectedClassName)
{
$config = $app->make('config');
$app->forgetInstance(MutexInterface::class);
try {
$result = null;
$config->withKey('concrete.mutex', $mutexConfig, function () use ($app, &$result) {
$result = $app->make(MutexInterface::class);
});
} catch (Exception $x) {
$result = $x;
} catch (Throwable $x) {
$result = $x;
}
$this->assertInstanceOf($expectedClassName, $result);
}
|
@dataProvider mutexConfigurationProvider
@param \Concrete\Core\Application\Application $app
@param array $mutexConfig
@param string $expectedClassName
|
testMutexConfiguration
|
php
|
concretecms/concretecms
|
tests/tests/System/MutexTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/System/MutexTest.php
|
MIT
|
public function testNoNameInUseErrorException()
{
$this->markTestSkipped('This test is not currently working in my local environment for some reason.');
$this->loadFiles('');
}
|
Let's load all the php-code only files, to be sure that we don't have errors like this:
Cannot use FillyQualifiedClassName as ClassAliasName because the name is already in use.
@doesNotPerformAssertions
|
testNoNameInUseErrorException
|
php
|
concretecms/concretecms
|
tests/tests/System/NameAlreadyInUseTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/System/NameAlreadyInUseTest.php
|
MIT
|
private function shouldLoadFile($fileRelativePath)
{
if (!preg_match('/.\.php$/', $fileRelativePath)) {
// Let's just load PHP files
return false;
}
if (strpos($fileRelativePath, 'concrete/') !== 0) {
// Let's just load PHP files in the concrete directory
return false;
}
if (preg_match('%^concrete/(attributes|authentication|blocks|geolocation)/\w+/%', $fileRelativePath)) {
// For attributes, blocks, ...: let's just load their controllers
return (bool) preg_match('%^concrete/(attributes|authentication|blocks|geolocation)/\w+/controller\.php%', $fileRelativePath);
}
if (preg_match('%^concrete/themes/\w+/%', $fileRelativePath)) {
// For themes: let's just load their controllers
return (bool) preg_match('%^concrete/themes/\w+/page_theme\.php%', $fileRelativePath);
}
switch ($fileRelativePath) {
case 'concrete/dispatcher.php':
case 'concrete/src/Support/.phpstorm.meta.php':
case 'concrete/src/Support/__IDE_SYMBOLS__.php':
return false;
default:
return true;
}
}
|
@param string $relpath
@param mixed $fileRelativePath
@return bool
|
shouldLoadFile
|
php
|
concretecms/concretecms
|
tests/tests/System/NameAlreadyInUseTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/System/NameAlreadyInUseTest.php
|
MIT
|
protected function listPullRequestMigrationIDs(PullRequest $state): array
{
$rc = -1;
$output = [];
exec('git -C ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, DIR_BASE)) . " diff --name-status {$state->getBaseSha1()}..{$state->getMergeSha1()} 2>&1", $output, $rc);
if ($rc !== 0) {
$this->markTestSkipped("Failed to list the git changes (maybe the fetched git history is too short?):\n" . trim(implode("\n", $output)));
}
$result = [];
$matches = null;
foreach ($output as $line) {
if (preg_match('%^[AR].*\sconcrete/src/Updater/Migrations/Migrations/Version(\d+)\.php\s*$%', $line, $matches)) {
$result[] = $matches[1];
}
}
return $result;
}
|
@throws \PHPUnit\Framework\SkippedTestError
@return string[]
|
listPullRequestMigrationIDs
|
php
|
concretecms/concretecms
|
tests/tests/Update/NewMigrationsTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Update/NewMigrationsTest.php
|
MIT
|
public function testRoute()
{
$path = '/named/route/path';
$name = 'named_route';
$route = new \Concrete\Core\Routing\Route($path);
$route->setPath($path);
$this->routeList->add($name, $route);
$url = $this->canonicalUrlWithPath($path);
$this->assertEquals((string) $url, (string) $this->urlResolver->resolve(["route/{$name}"]));
}
|
Make sure that we can actually resolve a basic route.
|
testRoute
|
php
|
concretecms/concretecms
|
tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
MIT
|
public function testRouteWithParameters()
{
$path = '/named/{parameter}/route';
$name = 'named_route';
$value = uniqid();
$route = new \Concrete\Core\Routing\Route($path);
$route->setPath($path);
$this->routeList->add($name, $route);
$url = $this->canonicalUrlWithPath(str_replace('{parameter}', $value, $path));
$this->assertEquals((string) $url, (string) $this->urlResolver->resolve(["route/{$name}", [
'parameter' => $value,
]]));
}
|
Test routes that have inline parameters.
|
testRouteWithParameters
|
php
|
concretecms/concretecms
|
tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
MIT
|
public function testRouteMiss()
{
$resolved = uniqid();
$this->assertEquals($this->urlResolver->resolve(['route/miss'], $resolved), $resolved);
}
|
Test not finding a named route in the list.
|
testRouteMiss
|
php
|
concretecms/concretecms
|
tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
MIT
|
public function testNoMatch()
{
$resolved = uniqid();
$this->assertEquals($this->urlResolver->resolve(['no match'], $resolved), $resolved);
}
|
Test not matching the expected syntax.
|
testNoMatch
|
php
|
concretecms/concretecms
|
tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Url/Resolver/RouteUrlResolverTest.php
|
MIT
|
protected function getMetadatas()
{
$this->metadatas = array_values(array_unique(array_merge($this->metadatas, [
Entity\User\GroupCreate::class,
Entity\User\GroupSignup::class,
Entity\User\GroupSignupRequest::class,
])));
return parent::getMetadatas();
}
|
{@inheritdoc}
@see \Concrete\TestHelpers\Database\ConcreteDatabaseTestCase::getMetadatas()
|
getMetadatas
|
php
|
concretecms/concretecms
|
tests/tests/User/GroupTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/User/GroupTest.php
|
MIT
|
protected function getTables()
{
$this->tables = array_values(array_unique(array_merge($this->tables, [
'GroupSelectedRoles',
'TreeGroupFolderNodes',
'TreeGroupFolderNodeSelectedGroupTypes',
])));
return parent::getTables();
}
|
{@inheritdoc}
@see \Concrete\TestHelpers\Database\ConcreteDatabaseTestCase::getTables()
|
getTables
|
php
|
concretecms/concretecms
|
tests/tests/User/GroupTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/User/GroupTest.php
|
MIT
|
public function setUp():void
{
$this->object = new \Concrete\Core\Utility\IPAddress();
}
|
Sets up the fixture, for example, opens a network connection.
This method is called before a test is executed.
|
setUp
|
php
|
concretecms/concretecms
|
tests/tests/Utility/IPAddressTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/IPAddressTest.php
|
MIT
|
public function TearDown():void
{
unset($this->object);
parent::tearDown();
}
|
Tears down the fixture, for example, closes a network connection.
This method is called after a test is executed.
|
TearDown
|
php
|
concretecms/concretecms
|
tests/tests/Utility/IPAddressTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/IPAddressTest.php
|
MIT
|
public function testLoopback($ip, $expected)
{
$this->assertEquals($expected, $this->object->setIp($ip)->isLoopback());
}
|
@dataProvider loopbackDataProvider
@param mixed $ip
@param mixed $expected
|
testLoopback
|
php
|
concretecms/concretecms
|
tests/tests/Utility/IPAddressTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/IPAddressTest.php
|
MIT
|
public function testPrivate($ip, $expected)
{
$this->assertEquals($expected, $this->object->setIp($ip)->isPrivate());
}
|
@dataProvider privateDataProvider
@param mixed $ip
@param mixed $expected
|
testPrivate
|
php
|
concretecms/concretecms
|
tests/tests/Utility/IPAddressTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/IPAddressTest.php
|
MIT
|
public function testLinkedLocal($ip, $expected)
{
$this->assertEquals($expected, $this->object->setIp($ip)->isLinkLocal());
}
|
@dataProvider linkedLocalDataProvider
@param mixed $ip
@param mixed $expected
|
testLinkedLocal
|
php
|
concretecms/concretecms
|
tests/tests/Utility/IPAddressTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/IPAddressTest.php
|
MIT
|
public function testIpType($ip, $expected)
{
$this->object->setIp($ip);
$this->assertEquals($expected, ($this->object->isIPv4()) ? (4) : ($this->object->isIPv6() ? 6 : 0));
}
|
@dataProvider ipTypeDataProvider
@param mixed $ip
@param mixed $expected
|
testIpType
|
php
|
concretecms/concretecms
|
tests/tests/Utility/IPAddressTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/IPAddressTest.php
|
MIT
|
public function testFlexRound($test, $value)
{
$numberService = new Number();
$this->assertEquals($value, $numberService->flexround($test));
}
|
@dataProvider flexRoundDataProvider
@param mixed $test
@param mixed $value
|
testFlexRound
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/NumberTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/NumberTest.php
|
MIT
|
public function testTrim($test, $expected)
{
$numberService = new Number();
$this->assertSame($expected, $numberService->trim($test));
}
|
@dataProvider trimDataProvider
@param mixed $test
@param mixed $expected
|
testTrim
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/NumberTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/NumberTest.php
|
MIT
|
public function testFormatSize($expected, $size, string $forceUnit = '')
{
$numberService = new Number();
$this->assertSame($expected, $numberService->formatSize($size, $forceUnit));
}
|
@dataProvider formatSizeDataProvider
@param string $test
@param int|float|string $expected
|
testFormatSize
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/NumberTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/NumberTest.php
|
MIT
|
public function setUp(): void
{
$this->object = new \Concrete\Core\Utility\Service\Text();
}
|
Sets up the fixture, for example, opens a network connection.
This method is called before a test is executed.
|
setUp
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function tearDown(): void
{
unset($this->object);
parent::tearDown();
}
|
Tears down the fixture, for example, closes a network connection.
This method is called after a test is executed.
|
tearDown
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function testAsciify($expected, $input1, $input2)
{
//$this->markTestSkipped('The asciify provider does not recognise Japanese at the moment, treats it as Chinese');
$this->assertEquals($expected, $this->object->asciify($input1, $input2));
}
|
@dataProvider asciifyDataProvider
@param mixed $expected
@param mixed $input1
@param mixed $input2
|
testAsciify
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function testUrlify($expected, $input)
{
$this->assertEquals($expected, $this->object->urlify($input));
}
|
@dataProvider urlifyDataProvider
@param mixed $expected
@param mixed $input
|
testUrlify
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function testShortenTextWord($expected, $input1, $input2, $input3)
{
$this->assertEquals($expected, $this->object->shortenTextWord($input1, $input2, $input3));
}
|
@dataProvider shortenDataProvider
@param mixed $expected
@param mixed $input1
@param mixed $input2
@param mixed $input3
|
testShortenTextWord
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function testWordSafeShortText($expected, $input1, $input2, $input3)
{
$this->assertEquals($expected, $this->object->wordSafeShortText($input1, $input2, $input3));
}
|
@dataProvider shortenDataProvider
@param mixed $expected
@param mixed $input1
@param mixed $input2
@param mixed $input3
|
testWordSafeShortText
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function testAutolink($expected, $input, $newWindow = false, $defaultProtocol = 'http://')
{
$this->assertSame($expected, $this->object->autolink($input, $newWindow, $defaultProtocol));
}
|
@dataProvider autolinkDataProvider
@param mixed $expected
@param mixed $input
@param mixed $newWindow
@param mixed $defaultProtocol
|
testAutolink
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/TextTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/TextTest.php
|
MIT
|
public function setUp():void {
$this->object = new \Concrete\Core\Utility\Service\Validation\Numbers();
}
|
Sets up the fixture, for example, opens a network connection.
This method is called before a test is executed.
|
setUp
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/Validation/NumbersTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/Validation/NumbersTest.php
|
MIT
|
public function TearDown():void
{
unset($this->object);
parent::tearDown();
}
|
Tears down the fixture, for example, closes a network connection.
This method is called after a test is executed.
|
TearDown
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/Validation/NumbersTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/Validation/NumbersTest.php
|
MIT
|
public function testInteger($expected, $input1, $min = null, $max = null)
{
$this->assertEquals($expected, $this->object->integer($input1, $min, $max));
}
|
@dataProvider integerDataProvider
@param mixed $expected
@param mixed $input1
@param null|mixed $min
@param null|mixed $max
|
testInteger
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/Validation/NumbersTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/Validation/NumbersTest.php
|
MIT
|
public function testNumber($expected, $input1, $min = null, $max = null)
{
$this->assertEquals($expected, $this->object->number($input1, $min, $max));
}
|
@dataProvider numberDataProvider
@param mixed $expected
@param mixed $input1
@param null|mixed $min
@param null|mixed $max
|
testNumber
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/Validation/NumbersTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/Validation/NumbersTest.php
|
MIT
|
public function setUp():void
{
$this->object = \Core::make(\Concrete\Core\Utility\Service\Validation\Strings::class);
}
|
Sets up the fixture, for example, opens a network connection.
This method is called before a test is executed.
|
setUp
|
php
|
concretecms/concretecms
|
tests/tests/Utility/Service/Validation/StringsTest.php
|
https://github.com/concretecms/concretecms/blob/master/tests/tests/Utility/Service/Validation/StringsTest.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.