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
public static function create($wpCategoryHandle, Workflow $wf, WorkflowRequest $wr) { $db = Database::connection(); $wpDateAdded = Core::make('helper/date')->getOverridableNow(); $wpCategoryID = $db->fetchColumn('select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle)); $db->executeQuery('insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)', array( $wf->getWorkflowID(), $wr->getWorkflowRequestID(), $wpDateAdded, $wpCategoryID, )); $wp = self::getByID($db->lastInsertId()); $wp->addWorkflowProgressHistoryObject($wr); if (!($wf instanceof EmptyWorkflow)) { $application = \Core::getFacadeApplication(); $type = $application->make('manager/notification/types')->driver('workflow_progress'); $notifier = $type->getNotifier(); $subscription = $type->getSubscription($wp); $notified = $notifier->getUsersToNotify($subscription, $wp); $notification = $type->createNotification($wp); $notifier->notify($notified, $notification); } return $wp; }
Creates a WorkflowProgress object (which will be assigned to a Page, File, etc... in our system. @param string $wpCategoryHandle @param Workflow $wf @param WorkflowRequest $wr @return self
create
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function start() { $wf = $this->getWorkflowObject(); if (is_object($wf)) { $r = $wf->start($this); $this->updateOnAction($wf); } return $r; }
The function that is automatically run when a workflowprogress object is started.
start
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function runTask($task, $args = array()) { $wf = $this->getWorkflowObject(); if (in_array($task, $wf->getAllowedTasks())) { $wpr = call_user_func_array(array($wf, $task), array($this, $args)); $this->updateOnAction($wf); } if (!($wpr instanceof Response)) { $wpr = new Response(); } $event = new GenericEvent(); $event->setArgument('response', $wpr); Events::dispatch('workflow_progressed', $event); return $wpr; }
Attempts to run a workflow task on the bound WorkflowRequest object first, then if that doesn't exist, attempts to run it on the current WorkflowProgress object. @return WorkflowProgressResponse
runTask
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function cancel(WorkflowProgress $wp) { $wpr = parent::cancel($wp); if ($this->isDeactivationRequest()) { $wpr->message = t("User deactivation request has been cancelled."); } else { $wpr->message = t("User activation request has been cancelled."); } return $wpr; }
after caneling activate(register activate) request, do nothing @return object
cancel
php
concretecms/concretecms
concrete/src/Workflow/Request/ActivateUserRequest.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/ActivateUserRequest.php
MIT
public function getRequestActionText() { if ($this->isDeactivationRequest()) { return t("Deactivation"); } else { return t("Activation"); } }
Gets the translated text of action of user workflow request @return string
getRequestActionText
php
concretecms/concretecms
concrete/src/Workflow/Request/ActivateUserRequest.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/ActivateUserRequest.php
MIT
public function cancel(Progress $wp) { $ui = UserInfo::getByID($this->getRequestedUserID()); $wpr = parent::cancel($wp); $wpr->message = t("User deletion request has been cancelled."); return $wpr; }
After canceling delete request, do nothing
cancel
php
concretecms/concretecms
concrete/src/Workflow/Request/DeleteUserRequest.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/DeleteUserRequest.php
MIT
public function getRequestActionText() { return t("Deletion"); }
Gets the translated text of action of user workflow request @return string
getRequestActionText
php
concretecms/concretecms
concrete/src/Workflow/Request/DeleteUserRequest.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/DeleteUserRequest.php
MIT
protected function triggerRequest(\PermissionKey $pk) { if (!$this->wrID) { $this->save(); } if (!$pk->canPermissionKeyTriggerWorkflow()) { throw new \Exception(t('This permission key cannot start a workflow.')); } $pa = $pk->getPermissionAccessObject(); $skipWorkflow = true; if (is_object($pa)) { $workflows = $pa->getWorkflows(); foreach ($workflows as $wf) { if ($wf->validateTrigger($this)) { $wp = $this->addWorkflowProgress($wf); $response = $wp->getWorkflowProgressResponseObject(); if ($response instanceof SkippedResponse) { // Since the response was skipped, we delete the workflow progress operation and keep moving. $wp->delete(); } else { $skipWorkflow = false; } $event = new GenericEvent(); $event->setArgument('progress', $wp); Events::dispatch('workflow_triggered', $event); } } } if ($skipWorkflow) { $defaultWorkflow = new EmptyWorkflow(); $wp = $this->addWorkflowProgress($defaultWorkflow); $event = new GenericEvent(); $event->setArgument('progress', $wp); Events::dispatch('workflow_triggered', $event); return $wp->getWorkflowProgressResponseObject(); } }
Triggers a workflow request, queries a permission key to see what workflows are attached to it and initiates them. @param \PermissionKey $pk @return optional WorkflowProgress
triggerRequest
php
concretecms/concretecms
concrete/src/Workflow/Request/Request.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/Request.php
MIT
public function getRequestAction() { return $this->requestAction; }
Gets the action of user workflow request. There are four actions: activate, register_activate, deactivate and delete @return string
getRequestAction
php
concretecms/concretecms
concrete/src/Workflow/Request/UserRequest.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/UserRequest.php
MIT
public function runTask($task, WorkflowProgress $wp) { $wpr = parent::runTask($task, $wp); if (!is_object($wpr) && method_exists($this, $task)) { if ($task == 'cancel') { // we check to see if any other outstanding workflowprogress requests have this id // if they don't we proceed $db = Loader::db(); $num = $db->GetOne('select count(wpID) as total from WorkflowProgress where wpID <> ? and wrID = ? and wpIsCompleted = 0', array( $wp->getWorkflowProgressID(), $this->getWorkflowRequestID() )); if ($num == 0) { $wpr = call_user_func_array(array($this, $task), array($wp)); return $wpr; } } } return $wpr; }
Override the runTask method in order to launch the cancel function correctly (to trigger user deletion for instance)
runTask
php
concretecms/concretecms
concrete/src/Workflow/Request/UserRequest.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Request/UserRequest.php
MIT
public function getDrivers() { $relPath = $this->getRelativePathFromInstallFolder() . REL_DIR_METADATA_XML; return new XmlProvider($relPath); }
Return customized metadata driver wrapped in a XMLProvider for doctrine orm Path: {package}/config/xml. @return XmlProvider
getDrivers
php
concretecms/concretecms
tests/assets/Package/packages/test_metadatadriver_xml/controller.php
https://github.com/concretecms/concretecms/blob/master/tests/assets/Package/packages/test_metadatadriver_xml/controller.php
MIT
public function getDrivers() { $relPath = $this->getRelativePathFromInstallFolder() . REL_DIR_METADATA_YAML; return new YamlProvider($relPath); }
Return customized metadata driver wrapped in a XMLProvider for doctrine orm Path: {package}/config/yaml. @return YamlProvider
getDrivers
php
concretecms/concretecms
tests/assets/Package/packages/test_metadatadriver_yaml/controller.php
https://github.com/concretecms/concretecms/blob/master/tests/assets/Package/packages/test_metadatadriver_yaml/controller.php
MIT
private function createMockFromClass($className) { if (!isset(self::$mockCreateMethod)) { $methods = ['createMock', 'createTestDouble', 'getMock']; foreach ($methods as $method) { if (method_exists($this, $method)) { static::$mockCreateMethod = $method; break; } } } if (isset(self::$mockCreateMethod)) { return $this->{self::$mockCreateMethod}($className); } throw new RuntimeException('Unable to figure out how to create mock objects.'); }
Returns a mock object for the specified class. @param string $className @return \PHPUnit\Framework\MockObject\MockObject
createMockFromClass
php
concretecms/concretecms
tests/helpers/CreateClassMockTrait.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/CreateClassMockTrait.php
MIT
public function setUp(): void { // Truncate tables $this->truncateTables(); parent::setUp(); $service = Core::make('site'); if (!$service->getDefault()) { $service->installDefault('en_US'); } $this->installAttributeCategoryAndObject(); AttributeType::add('boolean', 'Boolean'); AttributeType::add('textarea', 'Textarea'); AttributeType::add('number', 'number'); AttributeType::add('text', 'text'); foreach ($this->keys as $akHandle => $args) { $args['akHandle'] = $akHandle; $type = AttributeType::getByHandle($args['type']); $this->keys[] = call_user_func_array([$this->getAttributeKeyClass(), 'add'], [$type, $args]); } }
{@inheritdoc} @see \PHPUnit\Framework\TestCase::setUp()
setUp
php
concretecms/concretecms
tests/helpers/Attribute/AttributeTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeTestCase.php
MIT
public function testSetAttribute($handle, $first, $second, $firstStatic = null, $secondStatic = null) { $this->getAttributeObjectForSet()->setAttribute($handle, $first); $attribute = $this->getAttributeObjectForGet()->getAttribute($handle); if ($firstStatic != null) { $this->assertSame($firstStatic, $attribute); } else { $this->assertSame($first, $attribute); } }
@dataProvider attributeValues @param \Concrete\Core\Attribute\AttributeKeyInterface|string $handle @param mixed $first @param mixed $second @param null|mixed $firstStatic @param null|mixed $secondStatic
testSetAttribute
php
concretecms/concretecms
tests/helpers/Attribute/AttributeTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeTestCase.php
MIT
public function testResetAttributes($handle, $first, $second, $firstStatic = null, $secondStatic = null) { $object = $this->getAttributeObjectForSet(); $object->setAttribute($handle, $second); $object = $this->getAttributeObjectForGet(); $object->reindex(); if (method_exists($object, 'refreshCache')) { $object->refreshCache(); } $attribute = $this->getAttributeObjectForGet()->getAttribute($handle); if ($secondStatic != null) { $this->assertSame($attribute, $secondStatic); } else { $this->assertSame($attribute, $second); } }
@dataProvider attributeValues @param \Concrete\Core\Attribute\AttributeKeyInterface|string $handle @param mixed $first @param mixed $second @param null|mixed $firstStatic @param null|mixed $secondStatic
testResetAttributes
php
concretecms/concretecms
tests/helpers/Attribute/AttributeTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeTestCase.php
MIT
public function testReindexing($handle, $value, $columns) { $object = $this->getAttributeObjectForSet(); $object->setAttribute($handle, $value); $object = $this->getAttributeObjectForGet(); $object->reindex(); $db = Database::get(); $r = $db->query($this->indexQuery); $row = $r->fetch(); foreach ($columns as $column => $value) { $this->assertTrue(isset($row[$column])); $this->assertEquals($value, $row[$column]); } }
@dataProvider attributeIndexTableValues @param \Concrete\Core\Attribute\AttributeKeyInterface|string $handle @param mixed $value @param mixed $columns
testReindexing
php
concretecms/concretecms
tests/helpers/Attribute/AttributeTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeTestCase.php
MIT
public function setUp(): void { // Truncate tables $this->truncateTables(); parent::setUp(); $app = ApplicationFacade::getFacadeApplication(); $service = $app->make('site'); if (!$service->getDefault()) { $service->installDefault('en_US'); } $this->at = AttributeType::add($this->atHandle, $this->atHandle); $this->ctrl = $this->at->getController(); Category::add('collection'); $key = CollectionKey::add($this->at, ['akHandle' => 'test', 'akName' => 'Test']); $this->ctrl->setAttributeKey($key); }
{@inheritdoc} @see \PHPUnit\Framework\TestCase::setUp()
setUp
php
concretecms/concretecms
tests/helpers/Attribute/AttributeTypeTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeTypeTestCase.php
MIT
public function testBaseAttributeValueGet($input, $expectedBaseValue) { // because of stupid !@#!@ phpunit. if ($input instanceof Closure) { $input = $input(); } if ($expectedBaseValue instanceof Closure) { $expectedBaseValue = $expectedBaseValue(); } $this->object->setAttribute($this->getAttributeKeyHandle(), $input); $baseValue = $this->object->getAttribute($this->getAttributeKeyHandle()); $baseValue = $this->prepareBaseValueAfterRetrieving($baseValue); $this->assertEquals($expectedBaseValue, $baseValue); $value = $this->object->getAttributeValueObject($this->getAttributeKeyHandle()); $this->assertInstanceOf(PageAttributeValueEntity::class, $value); $this->assertInstanceOf($this->getAttributeValueClassName(), $value->getValueObject()); }
@dataProvider baseAttributeValues @param mixed $input @param mixed $expectedBaseValue
testBaseAttributeValueGet
php
concretecms/concretecms
tests/helpers/Attribute/AttributeValueTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeValueTestCase.php
MIT
public function testDisplayAttributeValues($input, $expectedDisplayValue) { // because of stupid !@#!@ phpunit. if ($input instanceof Closure) { $input = $input(); } if ($expectedDisplayValue instanceof Closure) { $expectedDisplayValue = $expectedDisplayValue(); } $this->object->setAttribute($this->getAttributeKeyHandle(), $input); $displayValue1 = $this->object->getAttribute($this->getAttributeKeyHandle(), 'display'); $displayValue2 = $this->object->getAttribute($this->getAttributeKeyHandle(), 'displaySanitized'); $value = $this->object->getAttributeValueObject($this->getAttributeKeyHandle()); $displayValue3 = $value->getDisplayValue(); $displayValue4 = $value->getDisplaySanitizedValue(); $displayValue5 = (string) $value; $this->assertEquals($displayValue1, $displayValue2); $this->assertEquals($displayValue2, $displayValue3); $this->assertEquals($displayValue3, $displayValue4); $this->assertEquals($displayValue4, $displayValue5); $this->assertEquals($expectedDisplayValue, $displayValue1); }
@dataProvider displayAttributeValues @param mixed $input @param mixed $expectedDisplayValue
testDisplayAttributeValues
php
concretecms/concretecms
tests/helpers/Attribute/AttributeValueTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeValueTestCase.php
MIT
public function testPlainTextAttributeValues($input, $expectedPlainTextOutput) { // because of stupid !@#!@ phpunit. if ($input instanceof Closure) { $input = $input(); } if ($expectedPlainTextOutput instanceof Closure) { $expectedPlainTextOutput = $expectedPlainTextOutput(); } $this->object->setAttribute($this->getAttributeKeyHandle(), $input); $value = $this->object->getAttributeValueObject($this->getAttributeKeyHandle()); $plainTextValue = $value->getPlainTextValue(); $this->assertEquals($expectedPlainTextOutput, $plainTextValue); }
@dataProvider plaintextAttributeValues @param mixed $input @param mixed $expectedPlainTextOutput
testPlainTextAttributeValues
php
concretecms/concretecms
tests/helpers/Attribute/AttributeValueTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeValueTestCase.php
MIT
public function testSearchIndexAttributeValues($input, $expectedSearchIndexValue) { // because of stupid !@#!@ phpunit. if ($input instanceof Closure) { $input = $input(); } if ($expectedSearchIndexValue instanceof Closure) { $expectedSearchIndexValue = $expectedSearchIndexValue(); } $this->object->setAttribute($this->getAttributeKeyHandle(), $input); $value = $this->object->getAttributeValueObject($this->getAttributeKeyHandle()); $searchIndexValue = $value->getSearchIndexValue(); $this->assertEquals($expectedSearchIndexValue, $searchIndexValue); }
@dataProvider searchIndexAttributeValues @param mixed $input @param mixed $expectedSearchIndexValue
testSearchIndexAttributeValues
php
concretecms/concretecms
tests/helpers/Attribute/AttributeValueTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Attribute/AttributeValueTestCase.php
MIT
public static function setUpBeforeClass():void { Cache::disableAll(); // Make sure tables are imported $testCase = new static(); $testCase->importTables(); $testCase->importMetadatas(); // Call parent setup parent::setUpBeforeClass(); }
Set up before any tests run.
setUpBeforeClass
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
public static function TearDownAfterClass():void { Cache::enableAll(); // Make sure tables are removed $testCase = new static(); $testCase->removeTables(); // Call parent teardown parent::tearDownAfterClass(); }
Tear down after class has completed.
TearDownAfterClass
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function connection() { if (!static::$connection) { static::$connection = Core::make('database')->connection('ccm_test'); } return static::$connection; }
Get the connection to use. @return \Concrete\Core\Database\Connection\Connection
connection
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function getConnection() { $connection = $this->connection()->getWrappedConnection(); if (!$connection instanceof PDOConnection) { throw new RuntimeException('Invalid connection type.'); } return $this->connection()->getWrappedConnection(); }
Returns the test database connection. @throws \RuntimeException @return PDOConnection
getConnection
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function getTables() { return $this->tables; }
Get the names of the tables to be imported from the xml files. @return string[]
getTables
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function extractTableData(array $tables) { // If there are no tables, there's no reason to scan the XML if (!count($tables)) { return null; } // Initialize an xml document $partial = new SimpleXMLElement('<schema xmlns="http://www.concrete5.org/doctrine-xml/0.5" />'); // Open the db.xml file $xml1 = simplexml_load_file(DIR_BASE_CORE . '/config/db.xml'); $importedTables = []; // Loop through tables that exist in the document foreach ($xml1->table as $table) { $name = (string) $table['name']; // If this table is being requested if (in_array($name, $tables, false)) { $this->appendXML($partial, $table); // Remove the table from our list of tables $tables = array_filter($tables, function ($name) use ($table) { return $name !== $table; }); // Track that we actually have tables to import $importedTables[] = $name; static::$existingTables[$name] = true; } if (!$tables) { break; } } // Return the partial only if there are tables to import return $importedTables ? $partial : null; }
Extract the table data from the db.xml. @param array $tables @return array|null
extractTableData
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function importTableXML(SimpleXMLElement $xml, Connection $connection) { // Convert the given partial into sql create statements $schema = Schema::loadFromXMLElement($xml, $connection); $queries = $schema->toSql($connection->getDatabasePlatform()); // Run queries foreach ($queries as $query) { $connection->query($query); } }
Import needed tables. @param SimpleXMLElement $xml @param Connection $connection @internal param $partial
importTableXML
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function getMetadatas() { $metadatas = []; $install = $this->metadatas; // If there are metadatas to import if ($this->metadatas && is_array($this->metadatas)) { /** @var EntityManagerInterface $manager */ $manager = Core::make(EntityManagerInterface::class); $factory = $manager->getMetadataFactory(); // Loop through all metadata foreach ($factory->getAllMetadata() as $meta) { if (!isset(self::$existingEntites[$meta->getName()]) && in_array($meta->getName(), $install, false)) { $metadatas[] = $meta; // Remove this from the list of entities to install $install = array_filter($install, function ($name) use ($meta) { return $name !== $meta->getName(); }); // Track that we've created this metadata self::$existingEntites[$meta->getName()] = true; } // If no more entities to install, lets break if (!$install) { break; } } } return $metadatas; }
Gets the metadatas to import. @return array
getMetadatas
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function appendXML(SimpleXMLElement $root, SimpleXMLElement $new) { $node = $root->addChild($new->getName(), (string) $new); foreach ($new->attributes() as $attr => $value) { $node->addAttribute($attr, $value); } foreach ($new->children() as $ch) { $this->appendXML($node, $ch); } }
Append an xml onto another xml. @param \SimpleXMLElement $root @param \SimpleXMLElement $new
appendXML
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
protected function truncateTables($tables = null) { $connection = $this->connection(); if ($tables === null) { // Get all existing tables $tables = $connection->query('show tables')->fetchAllAssociative(); $tables = array_map(function ($table) { return array_shift($table); }, $tables); } // Turn off foreign key checks $connection->exec('SET FOREIGN_KEY_CHECKS = 0'); foreach ($tables as $table) { // Drop tables $connection->exec("TRUNCATE TABLE `{$table}`"); } // Reset foreign key checks on $connection->exec('SET FOREIGN_KEY_CHECKS = 1'); }
Truncate all known databases. @param null|string[] $tables The tables to truncate
truncateTables
php
concretecms/concretecms
tests/helpers/Database/ConcreteDatabaseTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/ConcreteDatabaseTestCase.php
MIT
public function getDrivers() { $xmlProvider = new XmlProvider($this); return $xmlProvider->getDrivers(); }
Return customized metadata driver wrapped in a XMLProvider for doctrine orm Path: {package}/config/xml. @return XmlProvider
getDrivers
php
concretecms/concretecms
tests/helpers/Database/EntityManager/Provider/Fixtures/PackageControllerXml.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/EntityManager/Provider/Fixtures/PackageControllerXml.php
MIT
public function getDrivers() { $yamlProvider = new YamlProvider($this); return $yamlProvider->getDrivers(); }
Return customized metadata driver wrapped in a YamlProvider for doctrine orm Path: {package}/config/yaml. @return YamlProvider
getDrivers
php
concretecms/concretecms
tests/helpers/Database/EntityManager/Provider/Fixtures/PackageControllerYaml.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/EntityManager/Provider/Fixtures/PackageControllerYaml.php
MIT
private function folderPathCleaner($folderPath, $returnLastFolders = 2) { //...\htdocs\concrete5800/packages/test_metadatadriver_yaml\config\yaml $folderPathCleaned = str_replace('\\', '/', $folderPath); $linkParts = explode('/', rtrim($folderPathCleaned, '/')); $count = count($linkParts); $shortenedPath = ''; for ($i = $returnLastFolders; $i >= 1; --$i) { $shortenedPath .= $linkParts[$count - $i] . '/'; } return rtrim($shortenedPath, '/'); }
Clean up and shorten absolut folder paths, so they can be passed with assert methods. Example: ....\htdocs\concrete5800/packages/test_metadatadriver_yaml\config\yaml will be converted to config/yaml @param string $folderPath @param int $returnLastFolders @return string
folderPathCleaner
php
concretecms/concretecms
tests/helpers/Database/Traits/DirectoryHelpers.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Database/Traits/DirectoryHelpers.php
MIT
protected function getStorageLocation() { $type = Type::add('local', t('Local Storage')); $configuration = $type->getConfigurationObject(); $configuration->setRootPath($this->getStorageDirectory()); $configuration->setWebRootRelativePath('/application/files'); return StorageLocation::add($configuration, 'Default', true); }
@return \Concrete\Core\Entity\File\StorageLocation\StorageLocation
getStorageLocation
php
concretecms/concretecms
tests/helpers/File/FileStorageTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/File/FileStorageTestCase.php
MIT
public function getFileSystemObject() { $adapter = $this->getConfigurationObject()->getAdapter(); $filesystem = new \League\Flysystem\Filesystem($adapter); return $filesystem; }
Returns the proper file system object for the current storage location, by mapping it through Flysystem. @return \Concrete\Flysystem\Filesystem
getFileSystemObject
php
concretecms/concretecms
tests/helpers/File/Service/Fixtures/TestStorageLocation.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/File/Service/Fixtures/TestStorageLocation.php
MIT
public function getTranslator() { return null; }
The dummy translator does not have any translator object attached to it, so null is returned instead.
getTranslator
php
concretecms/concretecms
tests/helpers/Localization/Translator/Fixtures/DummyTranslatorAdapter.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Localization/Translator/Fixtures/DummyTranslatorAdapter.php
MIT
public function getPackagePath() { return __DIR__; }
{@inheritdoc} @see \Concrete\Core\Package\Package::getPackagePath()
getPackagePath
php
concretecms/concretecms
tests/helpers/Package/PackageForTestingPHPVersion.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Package/PackageForTestingPHPVersion.php
MIT
public function getPackageHandle() { return 'handle'; }
{@inheritdoc} @see \Concrete\Core\Package\Package::getPackageHandle()
getPackageHandle
php
concretecms/concretecms
tests/helpers/Package/PackageForTestingPHPVersion.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Package/PackageForTestingPHPVersion.php
MIT
protected static function createPage($name, $parent = false, $type = false, $template = false) { if ($parent === false) { $parent = Page::getByID(Page::getHomePageID()); } elseif (is_string($parent)) { $parent = Page::getByPath($parent); } if ($type === false) { $type = 1; } if (is_string($type)) { $pt = PageType::getByHandle($type); } else { $pt = PageType::getByID($type); } if ($template === false) { $template = 'full'; } if (is_string($template)) { $template = PageTemplate::getByHandle($template); } else { $template = PageTemplate::getByID($template); } $page = $parent->add($pt, [ 'cName' => $name, 'pTemplateID' => $template->getPageTemplateID(), ]); return $page; }
@param string $name @param \Concrete\Core\Page\Page|string|false $parent @param string|int|false $type @param string|int|false $template @return \Concrete\Core\Page\Page
createPage
php
concretecms/concretecms
tests/helpers/Page/PageTestCase.php
https://github.com/concretecms/concretecms/blob/master/tests/helpers/Page/PageTestCase.php
MIT
public function testCredentials(): void { $defaultKeyLength = 64; $defaultSecretLength = 96; $customKeyLength = 17; // Low prime number $customSecretLength = 97; // High prime number $credentials1 = $this->factory->generateCredentials(); $credentials2 = $this->factory->generateCredentials(); $credentials3 = $this->factory->generateCredentials($customKeyLength, $customSecretLength); // Make sure none of the credentials are empty self::assertNotEmpty($credentials1->getKey(), 'Credentials generated with empty key!'); self::assertNotEmpty($credentials2->getKey(), 'Credentials generated with empty key!'); self::assertNotEmpty($credentials1->getSecret(), 'Credentials generated with empty secret!'); self::assertNotEmpty($credentials2->getSecret(), 'Credentials generated with empty secret!'); // Make sure the keys aren't the same as the secrets self::assertNotSame($credentials1->getKey(), $credentials1->getSecret(), 'Credentials generated with equivalent key and secret!'); self::assertNotSame($credentials2->getKey(), $credentials2->getSecret(), 'Credentials generated with equivalent key and secret!'); // Make sure the two credentials aren't the same at all self::assertNotSame($credentials1->getKey(), $credentials2->getKey(), 'Credentials generated with the same key twice!'); self::assertNotSame($credentials1->getSecret(), $credentials2->getSecret(), 'Credentials generated with the same secret twice!'); // Make sure the size is right self::assertEquals($defaultKeyLength, strlen($credentials1->getKey()), 'Default size key is the wrong size.'); self::assertEquals($defaultSecretLength, strlen($credentials1->getSecret()), 'Custom size secret is the wrong size.'); self::assertEquals($customKeyLength, strlen($credentials3->getKey()), 'Custom size key is the wrong size.'); self::assertEquals($customSecretLength, strlen($credentials3->getSecret()), 'Custom size secret is the wrong size.'); }
@covers \Concrete\Core\Api\OAuth\Client\ClientFactory::generateCredentials
testCredentials
php
concretecms/concretecms
tests/tests/Api/OAuth/Client/ClientFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Api/OAuth/Client/ClientFactoryTest.php
MIT
public function testShortKeysException():void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('A key must have a length longer than 16'); $this->factory->generateCredentials(10, 10); }
@covers \Concrete\Core\Api\OAuth\Client\ClientFactory::generateCredentials @return void
testShortKeysException
php
concretecms/concretecms
tests/tests/Api/OAuth/Client/ClientFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Api/OAuth/Client/ClientFactoryTest.php
MIT
public function testCreateClient():void { $client = $this->factory->createClient( 'Ritas Toaster', 'http://example.com', ['test', 'scopes'], 'key', 'secret' ); self::assertSame( [ 'uu-i-d', 'Ritas Toaster', 'http://example.com', //['test', 'scopes'], 'key', 'secret', false, ], [ $client->getIdentifier(), $client->getName(), $client->getRedirectUri(), //$client->getScopes(), $client->getClientKey(), $client->getClientSecret(), $client->isDocumentationEnabled() ] ); return; }
@covers \Concrete\Core\Api\OAuth\Client\ClientFactory::createClient
testCreateClient
php
concretecms/concretecms
tests/tests/Api/OAuth/Client/ClientFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Api/OAuth/Client/ClientFactoryTest.php
MIT
public function testControllerDisplayValue() { $expected = $this->displayAttributeValues(); $ctrl = $this->getControllerWithValue(); $this->assertEquals($expected[0][1], $ctrl->getDisplayValue()); }
Tests that the the attribute value is formatted correctly when fetched through the controller.
testControllerDisplayValue
php
concretecms/concretecms
tests/tests/Attribute/Value/AddressValueTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Attribute/Value/AddressValueTest.php
MIT
public function testControllerFormValidation() { $ctrl = $this->getControllerWithValue(); // No country $this->assertFalse($ctrl->validateForm([ 'address1' => 'No country road 1', 'state_province' => 'Unexisting', 'city' => 'Atlantis', 'postal_code' => '123456', ])); // US: default $this->assertTrue($ctrl->validateForm([ 'address1' => '123 Fake St.', 'city' => 'Portland', 'state_province' => 'OR', 'country' => 'US', 'postal_code' => '90000', ])); // US: state/province missing $this->assertFalse($ctrl->validateForm([ 'address1' => '123 Fake St.', 'city' => 'Portland', 'country' => 'US', 'postal_code' => '90000', ])); // FI: default $this->assertTrue($ctrl->validateForm([ 'address1' => 'Olematon kuja 1', 'city' => 'Helsinki', 'country' => 'FI', 'postal_code' => '00001', ])); // FI: city missing $this->assertFalse($ctrl->validateForm([ 'address1' => 'Olematon kuja 1', 'country' => 'FI', 'postal_code' => '00001', ])); }
Tests address validation through the controller.
testControllerFormValidation
php
concretecms/concretecms
tests/tests/Attribute/Value/AddressValueTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Attribute/Value/AddressValueTest.php
MIT
public function testRender($value, $expectedGetValue, $expectedToString) { $avID = static::$lastID + 1; static::$lastID = $avID; $db = Database::connection(); $db->executeQuery('insert into AttributeValues (avID) values (?)', [$avID]); $avID = $db->lastInsertId(); $db->executeQuery('insert into atNumber (avID, value) values (?, ?)', [$avID, $value]); $em = ORM::entityManager(); $repo = $em->getRepository(NumberValue::class); $entity = $repo->find($avID); $this->assertInstanceOf(NumberValue::class, $entity); $this->assertSame($expectedGetValue, $entity->getValue()); $this->assertSame($expectedToString, (string) $entity); }
@dataProvider renderProvider @param mixed $value @param mixed $expectedGetValue @param mixed $expectedToString
testRender
php
concretecms/concretecms
tests/tests/Attribute/Value/NumberValue2Test.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Attribute/Value/NumberValue2Test.php
MIT
public function testMatchedSimpleValues($content, $reference, $itemClass) { $inspector = app('import/value_inspector'); $result = $inspector->inspect($content, false); $items = $result->getMatchedItems(); $this->assertEquals(1, count($items)); $item = $items[0]; $this->assertInstanceOf('\Concrete\Core\Backup\ContentImporter\ValueInspector\Item\ItemInterface', $item); $this->assertEquals($reference, $item->getReference()); $this->assertInstanceOf($itemClass, $item); }
@dataProvider providerMatchedSimpleValues @param mixed $content @param mixed $reference @param mixed $itemClass
testMatchedSimpleValues
php
concretecms/concretecms
tests/tests/Backup/ContentImporterValueInspectorTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Backup/ContentImporterValueInspectorTest.php
MIT
public function testBlockControllerActionRouting($path, $class) { $router = new Router(new RouteCollection(), new RouteActionFactory()); $list = new SystemRouteList(); $list->loadRoutes($router); $context = new RequestContext(); $context->fromRequest(Request::getInstance()); $route = $router->getRouteByPath($path, $context); $action = $router->resolveAction($route); $this->assertEquals($class, $action->getControllerCallback()); }
@dataProvider blockControllerActionRoutingDataProvider Test block routing to the add action method.
testBlockControllerActionRouting
php
concretecms/concretecms
tests/tests/Block/BlockActionTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/BlockActionTest.php
MIT
public function testFrom($from, $to) { self::createPage('Awesome'); self::createPage('All Right', '/awesome'); $translated = \Concrete\Core\Editor\LinkAbstractor::translateFrom($from); $this->assertEquals($to, $translated); }
This is taking data OUT of the database and sending it into the page. @dataProvider contentsFrom @param mixed $from @param mixed $to
testFrom
php
concretecms/concretecms
tests/tests/Block/ContentPageTranslateTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/ContentPageTranslateTest.php
MIT
public function testTo($from, $to) { $translated = LinkAbstractor::translateTo($from); $this->assertEquals($to, $translated); }
This is saving data from the content editor HTML INTO the database. @dataProvider contentsTo @param mixed $from @param mixed $to
testTo
php
concretecms/concretecms
tests/tests/Block/ContentTranslateTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/ContentTranslateTest.php
MIT
public function testFromEditMode($to, $from) { $translated = LinkAbstractor::translateFromEditMode($from); $this->assertEquals($to, $translated); }
This is taking data OUT of the database and sending it into the content editor. @dataProvider contentsFromEditMode @param mixed $to @param mixed $from
testFromEditMode
php
concretecms/concretecms
tests/tests/Block/ContentTranslateTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/ContentTranslateTest.php
MIT
public function testFrom($from, $to) { $translated = LinkAbstractor::translateFrom($from); $this->assertEquals($to, $translated); }
This is taking data OUT of the database and sending it into the page. @dataProvider contentsFrom @param mixed $from @param mixed $to
testFrom
php
concretecms/concretecms
tests/tests/Block/ContentTranslateTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/ContentTranslateTest.php
MIT
public static function provideBlocksWithDB(): array { $result = []; foreach (scandir(DIR_BASE_CORE . '/' . DIRNAME_BLOCKS) as $item) { if (is_file(DIR_BASE_CORE . '/' . DIRNAME_BLOCKS . '/' . $item . '/' . FILENAME_BLOCK_DB)) { $result[] = [$item]; } } return $result; }
Return the directory names of the blocks that have database tables. @return string[]
provideBlocksWithDB
php
concretecms/concretecms
tests/tests/Block/ControllerPropertiesTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/ControllerPropertiesTest.php
MIT
private static function getPropertiesFromController(string $controllerClassName): array { $class = new ReflectionClass($controllerClassName); $result = []; foreach ($class->getProperties() as $property) { $result[$property->getName()] = $property; } return $result; }
@return \ReflectionProperty[] array keys are the property names
getPropertiesFromController
php
concretecms/concretecms
tests/tests/Block/ControllerPropertiesTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Block/ControllerPropertiesTest.php
MIT
public function testConfiguredAliases($configKey, $alias, $classFromConfig) { $alias = ltrim($alias, '\\'); $classFromConfig = ltrim($classFromConfig, '\\'); $this->assertTrue(class_exists($alias, true)); $actualClass = (new \ReflectionClass($alias))->getName(); $this->assertSame($classFromConfig, $actualClass, "Accordingly to {$configKey}, {$alias} should resolve to {$classFromConfig}, but it resolves to {$actualClass}"); }
@dataProvider provideConfiguredAliases @param string $configKey @param string $alias @param string $classFromConfig
testConfiguredAliases
php
concretecms/concretecms
tests/tests/Config/ValuesTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Config/ValuesTest.php
MIT
protected function paginatedScan(Redis $redis, $pattern) { $scanMock = $this->scanMock; foreach ($scanMock($redis, $pattern) as $key => $value) { yield $key => $value; } }
Scan for a specific key pattern @param Redis $redis @param string $pattern The pattern to search for ex: `foo`, `*`, `foo.*` @return \Generator|string[] A list of keys that match the pattern
paginatedScan
php
concretecms/concretecms
tests/tests/Config/Driver/Redis/Fixtures/RedisPaginatedTraitValuesFixture.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Config/Driver/Redis/Fixtures/RedisPaginatedTraitValuesFixture.php
MIT
protected function getStorageLocation() { $type = Type::add('local', t('Local Storage')); $configuration = $type->getConfigurationObject(); $configuration->setRootPath($this->getStorageDirectory()); $configuration->setWebRootRelativePath('/application/files'); return StorageLocation::add($configuration, 'Default', true); }
@return \Concrete\Core\Entity\File\StorageLocation\StorageLocation
getStorageLocation
php
concretecms/concretecms
tests/tests/Controller/SinglePage/DownloadFileTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Controller/SinglePage/DownloadFileTest.php
MIT
protected function getSampleRequest(array $cookies) { return Request::create('https://www.example.com/', 'GET', [], $cookies); }
@param array $cookies @return \Concrete\Core\Http\Request
getSampleRequest
php
concretecms/concretecms
tests/tests/Cookie/CookieTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Cookie/CookieTest.php
MIT
public function testDoctrineORMSetup($ioCAlias, $expected, $message) { $doctrineConfig = $this->app->make($ioCAlias); $this->assertInstanceOf($expected, $doctrineConfig, $message); }
Test if the the classes are mapped correctly be the IoC during the bootstrap. @dataProvider dataProviderForTestDoctrineORMSetup @param string $ioCAlias @param string $expected @param string $message
testDoctrineORMSetup
php
concretecms/concretecms
tests/tests/Database/DatabaseServiceProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/DatabaseServiceProviderTest.php
MIT
public function testEntityManagerConfigFactory($ioCAlias, $expected1, $expected2) { $entityManagerConfigFactory = $this->app->make($ioCAlias); $this->assertInstanceOf($expected1, $entityManagerConfigFactory); $this->assertInstanceOf($expected2, $entityManagerConfigFactory); }
Test if the interface and the concrete EntityManagerConfigFactory are mapped correctly. @dataProvider dataProviderForTestEntityManagerConfigFactory * @param string $ioCAlias @param string $expected1 @param string $expected2
testEntityManagerConfigFactory
php
concretecms/concretecms
tests/tests/Database/DatabaseServiceProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/DatabaseServiceProviderTest.php
MIT
public function testEntityManagerFactory($ioCAlias, $expected1, $expected2) { $entityManagerFactory = $this->app->make($ioCAlias); $this->assertInstanceOf($expected1, $entityManagerFactory); $this->assertInstanceOf($expected2, $entityManagerFactory); }
Test if the interface and the concrete EntityManagerFactory are mapped correctly. @dataProvider dataProviderForTestEntityManagerFactory @param string $ioCAlias @param string $expected1 @param string $expected2
testEntityManagerFactory
php
concretecms/concretecms
tests/tests/Database/DatabaseServiceProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/DatabaseServiceProviderTest.php
MIT
public function testDatabaseAndDBALSetup($ioCAlias, $expected1) { $instance = $this->app->make($ioCAlias); $this->assertInstanceOf($expected1, $instance); }
Test if the Doctrine DBAL connect, database connection and the database managers are mapped correctly. @dataProvider dataProviderForTestDatabaseAndDBALSetup @param string $ioCAlias @param string $expected1
testDatabaseAndDBALSetup
php
concretecms/concretecms
tests/tests/Database/DatabaseServiceProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/DatabaseServiceProviderTest.php
MIT
protected function getTestFileConfig() { $defaultEnv = \Config::getEnvironment(); $fileSystem = new \Illuminate\Filesystem\Filesystem(); $fileLoader = new \Concrete\Core\Config\FileLoader($fileSystem); $directFileSaver = new \Concrete\Core\Config\FileSaver($fileSystem); $repository = new \Concrete\Core\Config\Repository\Repository($fileLoader, $directFileSaver, $defaultEnv); return $repository; }
Create new config file repository. @return \Concrete\Core\Config\Repository\Repository
getTestFileConfig
php
concretecms/concretecms
tests/tests/Database/DatabaseServiceProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/DatabaseServiceProviderTest.php
MIT
public function testPackageStandardEntityLocation() { $this->markTestIncomplete('Not implemented.'); }
packages/your_package/src/Entity, v8. 1. MAke sure to test directory 2. Make sure to test annotation paths 3. Make sure to test package version minimum 4. Make sure to test the annotation driver somehow so we can verify it's importing ORM I guess?
testPackageStandardEntityLocation
php
concretecms/concretecms
tests/tests/Database/EntityManagerClassLoaderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerClassLoaderTest.php
MIT
public function testPackageCustomEntityLocation() { $this->markTestIncomplete('Not implemented.'); }
packages/your_package/src/Something/Something/Entity, maps to \Something\Something\Entity.
testPackageCustomEntityLocation
php
concretecms/concretecms
tests/tests/Database/EntityManagerClassLoaderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerClassLoaderTest.php
MIT
public function testGetConfigurationDefaultSettingsForTheCore() { $entityManagerConfigFactory = $this->app->make('Concrete\Core\Database\EntityManagerConfigFactory'); $driverChain = $entityManagerConfigFactory->getMetadataDriverImpl(); $this->assertInstanceOf('Doctrine\Persistence\Mapping\Driver\MappingDriverChain', $driverChain, 'Is not a Doctrine ORM MappingDriverChain'); // mitgrated to Database/EntityManager/Driver/CoreDriverTest // // $drivers = $driverChain->getDrivers(); // // $this->assertArrayHasKey('Concrete\Core\Entity', $drivers); // // // Test if the correct MetadataDriver and MetadataReader are present // $defaultAnnotationDriver = $drivers['Concrete\Core\Entity']; // $defaultAnnotationReader = $defaultAnnotationDriver->getReader(); // $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', // $defaultAnnotationDriver, // 'The core metadata driver musst be an AnnotationDriver'); // $this->assertInstanceOf('Doctrine\Common\Annotations\CachedReader', // $defaultAnnotationReader, // 'AnnotationReader is not cached. For performance reasons, it should be wrapped in a CachedReader'); // // // Test if the driver contains the default lookup path // $driverPaths = $defaultAnnotationDriver->getPaths(); // $this->assertEquals(DIR_BASE_CORE . '/' . DIRNAME_CLASSES.'/'.DIRNAME_ENTITIES, // $driverPaths[0]); }
Test the default metadata implementation for the Core classes.
testGetConfigurationDefaultSettingsForTheCore
php
concretecms/concretecms
tests/tests/Database/EntityManagerConfigFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerConfigFactoryTest.php
MIT
public function testGetConfigurationDefaultSettingsForTheApplication() { $root = dirname(DIR_BASE_CORE . '../'); mkdir($root . '/application/src/Entity', 0777, true); $entityManagerConfigFactory = $this->app->make('Concrete\Core\Database\EntityManagerConfigFactory'); $driverChain = $entityManagerConfigFactory->getMetadataDriverImpl(); $this->assertInstanceOf('Doctrine\Persistence\Mapping\Driver\MappingDriverChain', $driverChain, 'Is not a Doctrine ORM MappingDriverChain'); $drivers = $driverChain->getDrivers(); $this->assertArrayHasKey('Application\Entity', $drivers); // Test if the correct MetadataDriver and MetadataReader are present $defaultAnnotationDriver = $drivers['Application\Entity']; $defaultAnnotationReader = $defaultAnnotationDriver->getReader(); // $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', // $defaultAnnotationDriver); $this->assertInstanceOf('Doctrine\Common\Annotations\CachedReader', $defaultAnnotationReader, 'AnnotationReader is not cached. For performance reasons, it should be wrapped in a CachedReader'); // Test if the driver contains the default lookup path $driverPaths = $defaultAnnotationDriver->getPaths(); $this->assertEquals(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, $driverPaths[0]); rmdir($root . '/application/src/Entity'); }
Test the default metadata implementation for the Application classes.
testGetConfigurationDefaultSettingsForTheApplication
php
concretecms/concretecms
tests/tests/Database/EntityManagerConfigFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerConfigFactoryTest.php
MIT
public function testGetConfigurationWithApplicationYmlDriverFallbackToDefault($setting) { $entityManagerConfigFactory = $this->getEntityManagerFactoryWithStubConfigRepository($setting); // Test if the correct MetadataDriver and MetadataReader are present $drivers = $entityManagerConfigFactory->getMetadataDriverImpl()->getDrivers(); $this->assertArrayHasKey('Application\Entity', $drivers); $defaultAnnotationDriver = $drivers['Application\Entity']; $defaultAnnotationReader = $defaultAnnotationDriver->getReader(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $defaultAnnotationDriver); $this->assertInstanceOf('Doctrine\Common\Annotations\CachedReader', $defaultAnnotationReader, 'AnnotationReader is not cached. For performance reasons, it should be wrapped in a CachedReader'); // Test if the driver contains the default lookup path $driverPaths = $defaultAnnotationDriver->getPaths(); $this->assertEquals(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, $driverPaths[0]); }
Test the metadata implementation for entities located under application/src/Entity with YAML driver In this case the folder application/config/xml is not present so it will fallback to default. @dataProvider dataProviderGetConfigurationWithApplicationYmlDriver @param string|int $setting
testGetConfigurationWithApplicationYmlDriverFallbackToDefault
php
concretecms/concretecms
tests/tests/Database/EntityManagerConfigFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerConfigFactoryTest.php
MIT
public function testGetConfigurationWithApplicationXmlDriverFallbackToDefault($setting) { $entityManagerConfigFactory = $this->getEntityManagerFactoryWithStubConfigRepository($setting); // Test if the correct MetadataDriver and MetadataReader are present $drivers = $entityManagerConfigFactory->getMetadataDriverImpl()->getDrivers(); $this->assertArrayHasKey('Application\Entity', $drivers); $defaultAnnotationDriver = $drivers['Application\Entity']; $defaultAnnotationReader = $defaultAnnotationDriver->getReader(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $defaultAnnotationDriver); $this->assertInstanceOf('Doctrine\Common\Annotations\CachedReader', $defaultAnnotationReader, 'AnnotationReader is not cached. For performance reasons, it should be wrapped in a CachedReader'); // Test if the driver contains the default lookup path $driverPaths = $defaultAnnotationDriver->getPaths(); $this->assertEquals(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, $driverPaths[0]); }
Test the metadata implementation for entities located under application/src with Xml driver In this case the folder application/config/xml is not present so it will fallback to default. @dataProvider dataProviderGetConfigurationWithApplicationXmlDriver @param string|int $setting
testGetConfigurationWithApplicationXmlDriverFallbackToDefault
php
concretecms/concretecms
tests/tests/Database/EntityManagerConfigFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerConfigFactoryTest.php
MIT
protected function getEntityManagerFactoryWithStubConfigRepository($setting) { $config = $this->app->make('Doctrine\ORM\Configuration'); $configRepoStub = $this->getMockBuilder('Concrete\Core\Config\Repository\Repository') ->disableOriginalConstructor() ->getMock(); $configRepoStub->method('get') ->will($this->onConsecutiveCalls( false, [], false, $setting )); $entityManagerConfigFactory = new \Concrete\Core\Database\EntityManagerConfigFactory($this->app, $config, $configRepoStub); return $entityManagerConfigFactory; }
Create the EntityManagerFactory with stub ConfigRepository option. @param array $setting with data from the dataProvider @return \Concrete\Core\Database\EntityManagerConfigFactory
getEntityManagerFactoryWithStubConfigRepository
php
concretecms/concretecms
tests/tests/Database/EntityManagerConfigFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManagerConfigFactoryTest.php
MIT
public function testGetDefaultDriver() { // prepare if (!$this->filesystem->isWritable(DIR_APPLICATION . '/' . DIRNAME_CLASSES)) { throw new \Exception('Cannot write to the application/src directory for the testing purposes. Please check permissions!'); } if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES); } // test $reader = $this->app->make('orm/cachedAnnotationReader'); $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); // check if its the correct driver $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $driver); // check if it contains the correct reader // Doctrine doesn't provied a way of accessing the original reader in the cached reader $this->assertEquals($reader, $driver->getReader(), 'The AnnotationReader is not wrapped with a CachedReader.'); }
Test default application driver with - empty CONFIG_ORM_METADATA_APPLICATION config setting - a present application/src/Entity folder. @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver @throws \Exception
testGetDefaultDriver
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testFailingGetDefaultDriverWithNoEntityDirectory() { $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); // this case doesn't return a driver $this->assertNull($driver); }
Test default application driver with no folder at application/src/Entity. @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver
testFailingGetDefaultDriverWithNoEntityDirectory
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testGetLegacyDriver() { // prepare if (!$this->filesystem->isWritable(DIR_APPLICATION . '/' . DIRNAME_CLASSES)) { throw new \Exception('Cannot write to the application/src directory for the testing purposes. Please check permissions!'); } $this->configRepository->set('app.enable_legacy_src_namespace', true); // test $reader = $this->app->make('orm/cachedSimpleAnnotationReader'); $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); // check if its the correct driver $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $driver); // check if it contains the correct reader // Doctrine doesn't provied a way of accessing the original reader in the cached reader $this->assertEquals($reader, $driver->getReader(), 'The SimpleAnnotationReader is not wrapped with a CachedReader.'); }
Test application legacy driver - empty CONFIG_ORM_METADATA_APPLICATION config setting - a present application/src folder - and config 'app.enable_legacy_src_namespace' = true. @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver @throws \Exception
testGetLegacyDriver
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testGetXMLDriver() { // prepare if (!$this->filesystem->isWritable(DIR_APPLICATION . '/' . DIRNAME_CONFIG)) { throw new \Exception('Cannot write to the application/config directory for the testing purposes. Please check permissions!'); } if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . REL_DIR_METADATA_XML)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . REL_DIR_METADATA_XML); } if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES); } $this->configRepository->set(CONFIG_ORM_METADATA_APPLICATION, 'xml'); // test $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); $this->assertEquals('xml', $this->configRepository->get(CONFIG_ORM_METADATA_APPLICATION)); $this->assertTrue($this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, 'application/src/Entities doesn\'t exist.')); $this->assertInstanceOf('\Doctrine\ORM\Mapping\Driver\XmlDriver', $driver); // Test if the driver contains the default lookup path $driverPaths = $driver->getLocator()->getPaths(); $this->assertEquals(DIR_APPLICATION . '/' . REL_DIR_METADATA_XML, $driverPaths[0]); }
Test application with xml driver - CONFIG_ORM_METADATA_APPLICATION = xml - a existing application/src/Entity folder - a existing application/config/xml. @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver @throws \Exception
testGetXMLDriver
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testFailingGetXMLDriverWithNoConfigXMLDirectory() { $this->configRepository->set(CONFIG_ORM_METADATA_APPLICATION, 'xml'); if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES); } $this->assertFalse($this->filesystem->isDirectory(DIR_APPLICATION . '/' . REL_DIR_METADATA_XML)); $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); // this case doesn't return a driver $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $driver); }
Failing test for XMLDriver with missing application/config/xml directory. @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver
testFailingGetXMLDriverWithNoConfigXMLDirectory
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testGetYMLDriver($setting) { // prepare if (!$this->filesystem->isWritable(DIR_APPLICATION . '/' . DIRNAME_CONFIG)) { throw new \Exception('Cannot write to the application/config directory for the testing purposes. Please check permissions!'); } if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML); } if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES); } $this->configRepository->set(CONFIG_ORM_METADATA_APPLICATION, $setting); // test $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); $this->assertEquals($setting, $this->configRepository->get(CONFIG_ORM_METADATA_APPLICATION)); $this->assertTrue($this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, 'application/src/Entities doesn\'t exist.')); $this->assertInstanceOf('\Doctrine\ORM\Mapping\Driver\YamlDriver', $driver); // Test if the driver contains the default lookup path $driverPaths = $driver->getLocator()->getPaths(); $this->assertEquals(DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML, $driverPaths[0]); }
Test application with xml driver - CONFIG_ORM_METADATA_APPLICATION = yml || yaml - a existing application/src/Entity folder - a existing application/config/yaml. @dataProvider dataProviderTestGetYMLDriver @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver @param string $setting @throws \Exception
testGetYMLDriver
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testFailingGetYMLDriverWithNoConfigYamlDirectory($setting) { $this->configRepository->set(CONFIG_ORM_METADATA_APPLICATION, $setting); if (!$this->filesystem->isDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES)) { $this->filesystem->makeDirectory(DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES); } $this->assertFalse($this->filesystem->isDirectory(DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML)); $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $driver = $applicationDriver->getDriver(); // this case doesn't return a driver $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $driver); }
Failing test for XMLDriver with missing application/config/yaml directory. @dataProvider dataProviderTestGetYMLDriver @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getDriver @param string $setting
testFailingGetYMLDriverWithNoConfigYamlDirectory
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testGetNamespace($isLegacy, $namespace) { if ($isLegacy) { $this->configRepository->save('app.enable_legacy_src_namespace', true); } $applicationDriver = new ApplicationDriver($this->configRepository, $this->app); $this->assertEquals($namespace, $applicationDriver->getNamespace()); if ($isLegacy) { $this->configRepository->save('app.enable_legacy_src_namespace', false); } }
Test namespace. @dataProvider dataProviderGetNamespace @covers \Concrete\Core\Database\EntityManager\Driver\ApplicationDriver::getNamespace @param bool $isLegacy @param string $namespace
testGetNamespace
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function dataProviderGetNamespace() { return [ ['isLegacy' => true, 'namespace' => 'Application\Src'], ['isLegacy' => false, 'namespace' => 'Application\Entity'], ]; }
Test the default and the legacy namespaces of application entites. @return array
dataProviderGetNamespace
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
protected function onNotSuccessfulTest(\Throwable $e):void { $this->cleanupFolderSystem(); $this->cleanupConfig(); }
Clean up if a Exception is thrown. @param \Exception $e
onNotSuccessfulTest
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/ApplicationDriverTest.php
MIT
public function testGetDriver() { $annotaionDriver = $this->coreDriver->getDriver(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $annotaionDriver, 'The core metadata driver musst be an AnnotationDriver'); $this->assertInstanceOf('Doctrine\Common\Annotations\CachedReader', $annotaionDriver->getReader(), 'AnnotationReader is not cached. For performance reasons, it should be wrapped in a CachedReader'); // Test if the driver contains the default lookup path $driverPaths = $annotaionDriver->getPaths(); $this->assertEquals(DIR_BASE_CORE . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, $driverPaths[0], 'CoreDriver doesn\'t contain the correct entity lookup path.'); }
Test if getDriver method contains the correct AnnotationDriver, a cached AnnotationReader and the correct entity lookup path.
testGetDriver
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/CoreDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/CoreDriverTest.php
MIT
public function testGetNamespace() { $this->assertInstanceOf('Doctrine\Persistence\Mapping\Driver\MappingDriverChain', $this->driverChain, 'Is not a Doctrine ORM MappingDriverChain'); $drivers = $this->driverChain->getDrivers(); $this->assertArrayHasKey('Concrete\Core\Entity', $drivers); }
Test getNamespce method returns the correct core namespace.
testGetNamespace
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/CoreDriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/CoreDriverTest.php
MIT
public function testGetDriver() { $this->assertInstanceOf('Doctrine\Persistence\Mapping\Driver\MappingDriver', $this->driver->getDriver()); }
@covers \Concrete\Core\Database\EntityManager\Driver\Driver::getDriver
testGetDriver
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/DriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/DriverTest.php
MIT
public function testGetNamespace() { $this->assertEquals('Test\Namespace', $this->driver->getNamespace()); }
@covers \Concrete\Core\Database\EntityManager\Driver\Driver::getNamespace
testGetNamespace
php
concretecms/concretecms
tests/tests/Database/EntityManager/Driver/DriverTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Driver/DriverTest.php
MIT
public function testGetDriversWithGetPackageEntityPath() { $package = new PackageControllerWithgetPackageEntityPath($this->app); $dpp = new DefaultPackageProvider($this->app, $package); $drivers = $dpp->getDrivers(); self::assertIsArray($drivers); $c5Driver = $drivers[0]; self::assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); self::assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $c5Driver->getDriver()); self::assertEquals($package->getNamespace() . '\Src', $c5Driver->getNamespace()); }
Test packages with removed getPackageEntityPath() method. @covers \Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider::getDrivers
testGetDriversWithGetPackageEntityPath
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
MIT
public function testGetDriversWithNoExistingSrcDirectory() { $package = new PackageControllerDefault($this->app); $dpp = new DefaultPackageProvider($this->app, $package); $drivers = $dpp->getDrivers(); self::assertIsArray($drivers); self::assertCount(0, $drivers); }
Test package with default driver and not existing source directory. @covers \Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider::getDrivers
testGetDriversWithNoExistingSrcDirectory
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
MIT
public function testGetDriversWithPackageWithLegacyNamespaceAndLegacyAnnotationReader() { $this->createPackageFolderOfTestMetadataDriverLegacy(); $package = new PackageControllerLegacy($this->app); $dpp = new DefaultPackageProvider($this->app, $package); $drivers = $dpp->getDrivers(); self::assertIsArray($drivers); $c5Driver = $drivers[0]; self::assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); self::assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $c5Driver->getDriver()); self::assertEquals($package->getNamespace() . '\Src', $c5Driver->getNamespace()); $this->removePackageFolderOfTestMetadataDriverLegacy(); }
Covers real word case of a package with $appVersionRequired < 8.0.0. @covers \Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider::getDrivers
testGetDriversWithPackageWithLegacyNamespaceAndLegacyAnnotationReader
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
MIT
public function testGetDriversWithPackageWithDefaultNamespaceAndDefaultAnnotationReader() { $this->createPackageFolderOfTestMetadatadriverDefault(); $package = new PackageControllerDefault($this->app); $dpp = new DefaultPackageProvider($this->app, $package); $drivers = $dpp->getDrivers(); self::assertIsArray($drivers); $c5Driver = $drivers[0]; self::assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); self::assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $c5Driver->getDriver()); self::assertEquals($package->getNamespace() . '\Entity', $c5Driver->getNamespace()); $this->removePackageFolderOfTestMetadataDriverDefault(); }
Covers real word case of a package with $appVersionRequired >= 8.0.0. @covers \Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider::getDrivers
testGetDriversWithPackageWithDefaultNamespaceAndDefaultAnnotationReader
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
MIT
public function testGetDriversWithPackageWithAdditionalNamespaces() { $this->createPackageFolderOfTestMetadataDriverAdditionalNamespace(); $package = new PackageControllerDefaultWithAdditionalNamespaces($this->app); $dpp = new DefaultPackageProvider($this->app, $package); $drivers = $dpp->getDrivers(); self::assertIsArray($drivers); self::assertCount(3, $drivers, 'Not all MappingDrivers have bin loaded'); $c5Driver1 = $drivers[1]; $driver1 = $c5Driver1->getDriver(); self::assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver1); self::assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $driver1); self::assertEquals('PortlandLabs\Concrete5\MigrationTool', $c5Driver1->getNamespace()); $pathsOfDriver1 = $driver1->getPaths(); self::assertEquals('src/PortlandLabs/Concrete5/MigrationTool', $this->folderPathCleaner($pathsOfDriver1[0], 4)); $this->removePackageFolderOfTestMetadataDriverAdditionalNamespace(); }
Covers package with additional namespaces and with $appVersionRewuired >= 8.0.0. @covers \Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider::getDrivers
testGetDriversWithPackageWithAdditionalNamespaces
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
MIT
protected function onNotSuccessfulTest(\Throwable $e):void { $this->removePackageFolderOfTestMetadataDriverDefault(); $this->removePackageFolderOfTestMetadataDriverDefault(); $this->removePackageFolderOfTestMetadataDriverAdditionalNamespace(); }
Clean up if a Exception is thrown. @param \Exception $e
onNotSuccessfulTest
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/DefaultPackageProviderTest.php
MIT
public function testGetEntityManagerProviderDefaultBehavior() { $package = new PackageControllerDefault($this->app); $ppf = new PackageProviderFactory($this->app, $package); $this->assertInstanceOf('Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider', $ppf->getEntityManagerProvider()); }
Test PackageProviderFactory if a package controller with no interfaces is passed This is de default behavior. @covers \Concrete\Core\Database\EntityManager\Provider\PackageProviderFactory::getEntityManagerProvider
testGetEntityManagerProviderDefaultBehavior
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/PackageProviderFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/PackageProviderFactoryTest.php
MIT
public function testGetEntityManagerProviderWithProviderInterface() { $package = new PackageControllerYaml($this->app); $ppf = new PackageProviderFactory($this->app, $package); $this->assertInstanceOf('Concrete\Core\Database\EntityManager\Provider\ProviderInterface', $ppf->getEntityManagerProvider()); }
Test PackageProviderFactory if a package controller with a ProviderInterface interface is passed. @covers \Concrete\Core\Database\EntityManager\Provider\PackageProviderFactory::getEntityManagerProvider
testGetEntityManagerProviderWithProviderInterface
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/PackageProviderFactoryTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/PackageProviderFactoryTest.php
MIT
public function testGetDriversDefaultBehaviourSuccess() { $yamlProvider = new XmlProvider($this->packageStub); $drivers = $yamlProvider->getDrivers(); // get c5 driver $c5Driver = $drivers[0]; $this->assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); // get Doctrine driver $driver = $c5Driver->getDriver(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\XmlDriver', $driver); $driverPaths = $driver->getLocator()->getPaths(); $shortenedPath = $this->folderPathCleaner($driverPaths[0]); $this->assertEquals('config/xml', $shortenedPath); $driverNamespace = $c5Driver->getNamespace(); $this->assertEquals('Concrete\Package\TestMetadatadriverXml\Entity', $driverNamespace); }
Test default mapping location and namespace for YamlProvidor.
testGetDriversDefaultBehaviourSuccess
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/XmlProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/XmlProviderTest.php
MIT
public function testGetDriversAddManuallyLocationAndNamespace($namespace, $locations) { $yamlProvider = new XmlProvider($this->packageStub, false); $yamlProvider->addDriver($namespace, $locations); $drivers = $yamlProvider->getDrivers(); // get c5 driver $c5Driver = $drivers[0]; $this->assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); // get Doctrine driver $driver = $c5Driver->getDriver(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\XmlDriver', $driver); $driverPaths = $driver->getLocator()->getPaths(); $shortenedPath = $this->folderPathCleaner($driverPaths[0]); $this->assertEquals($locations[0], $shortenedPath); $driverNamespace = $c5Driver->getNamespace(); // Important: Doctrine internally works with namespaces that don't start // with a backslash. If a namespace which starts with a backslash // is provided, doctrine wouldn't find it in the DriverChain and // through a MappingException. // To simulate this, the namespace is wrapped in ltrim function. $this->assertEquals(ltrim($namespace, '\\'), $driverNamespace); }
Test custom mapping location and namespace for YamlProvider. @dataProvider dataProviderGetDriversAddManuallyLocationAndNamespace @param mixed $namespace @param mixed $locations
testGetDriversAddManuallyLocationAndNamespace
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/XmlProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/XmlProviderTest.php
MIT
public function testGetDriversDefaultBehaviourSuccess() { $yamlProvider = new YamlProvider($this->packageStub); $drivers = $yamlProvider->getDrivers(); // get c5 driver $c5Driver = $drivers[0]; $this->assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); // get Doctrine driver $driver = $c5Driver->getDriver(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $driver); $driverPaths = $driver->getLocator()->getPaths(); $shortenedPath = $this->folderPathCleaner($driverPaths[0]); $this->assertEquals('config/yaml', $shortenedPath); $driverNamespace = $c5Driver->getNamespace(); $this->assertEquals('Concrete\Package\TestMetadatadriverYaml\Entity', $driverNamespace); }
Test default mapping location and namespace for YamlProvidor.
testGetDriversDefaultBehaviourSuccess
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/YamlProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/YamlProviderTest.php
MIT
public function testGetDriversAddManuallyLocationAndNamespace($namespace, $locations) { $yamlProvider = new YamlProvider($this->packageStub, false); $yamlProvider->addDriver($namespace, $locations); $drivers = $yamlProvider->getDrivers(); // get c5 driver $c5Driver = $drivers[0]; $this->assertInstanceOf('Concrete\Core\Database\EntityManager\Driver\Driver', $c5Driver); // get Doctrine driver $driver = $c5Driver->getDriver(); $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $driver); $driverPaths = $driver->getLocator()->getPaths(); $shortenedPath = $this->folderPathCleaner($driverPaths[0]); $this->assertEquals($locations[0], $shortenedPath); $driverNamespace = $c5Driver->getNamespace(); // Important: Doctrine internally works with namespaces that don't start // with a backslash. If a namespace which starts with a backslash // is provided, doctrine wouldn't find it in the DriverChain and // through a MappingException. // To simulate this, the namespace is wrapped in ltrim function. $this->assertEquals(ltrim($namespace, '\\'), $driverNamespace); }
Test custom mapping location and namespace for YamlProvider. @dataProvider dataProviderGetDriversAddManuallyLocationAndNamespace @param mixed $namespace @param mixed $locations
testGetDriversAddManuallyLocationAndNamespace
php
concretecms/concretecms
tests/tests/Database/EntityManager/Provider/YamlProviderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/EntityManager/Provider/YamlProviderTest.php
MIT
public function testEscapeForLike($input, $wildcardAtStart, $wildcardAtEnd, $expectedOutput) { $calculatedOutput = self::$defaultInstance->escapeForLike($input, $wildcardAtStart, $wildcardAtEnd); $this->assertSame($expectedOutput, $calculatedOutput); }
@dataProvider escapeForLikeProvider @param mixed $input @param mixed $wildcardAtStart @param mixed $wildcardAtEnd @param mixed $expectedOutput
testEscapeForLike
php
concretecms/concretecms
tests/tests/Database/Query/LikeBuilderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/Query/LikeBuilderTest.php
MIT
public function testSplitKeywordsForLike($input, $wordSeparators, $addWildcards, $expectedOutput) { $calculatedOutput = self::$defaultInstance->splitKeywordsForLike($input, $wordSeparators, $addWildcards); $this->assertSame($expectedOutput, $calculatedOutput); }
@dataProvider splitKeywordsForLikeProvider @param mixed $input @param mixed $wordSeparators @param mixed $addWildcards @param mixed $expectedOutput
testSplitKeywordsForLike
php
concretecms/concretecms
tests/tests/Database/Query/LikeBuilderTest.php
https://github.com/concretecms/concretecms/blob/master/tests/tests/Database/Query/LikeBuilderTest.php
MIT
public function testMultiTextAttributeHeaders() { $controller = M::mock(AttributeTypeController::class, MulticolumnTextExportableAttributeInterface::class); $controller->shouldReceive('getAttributeTextRepresentationHeaders')->andReturn(['foo', 'bar', 'baz']); $controller->shouldReceive('getAttributeValueTextRepresentation')->andReturn(['Fooz', 'Barz', 'Bazz']); $keys = [ 'foo' => $this->attributeKey('foo', 'Foo', $controller), ]; $values = [ $this->attributeValue($keys['foo'], 'Foo value', $controller), ]; list($entity, $list, $writer, $csvWriter) = $this->getCsvWriterMock($keys, $values); $csvWriter->insertHeaders($entity); $csvWriter->insertEntryList($list); $this->assertSame([ 'publicIdentifier' => 'publicIdentifier', 'ccm_date_created' => 'dateCreated', 'ccm_date_modified' => 'dateModified', 'site' => 'site', 'author_name' => 'authorName', 'foo' => 'Foo', 'foo.foo' => 'Foo - foo', 'foo.bar' => 'Foo - bar', 'foo.baz' => 'Foo - baz', ], $writer->headers); $this->assertSame([ [ 'publicIdentifier' => 'abc', 'ccm_date_created' => 'not now', 'ccm_date_modified' => 'not now', 'site' => 'foo', 'author_name' => 'author name', 'foo' => 'Foo value', 'foo.foo' => 'Fooz', 'foo.bar' => 'Barz', 'foo.baz' => 'Bazz', ] ], $writer->entries); }
Test an entry being exported that has attributes with mutlicolumn text export enabled
testMultiTextAttributeHeaders
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