Commit a8ceb42c authored by anon's avatar anon

Code standards

parent 31870a71
......@@ -92,9 +92,10 @@ class LinkitFilter extends FilterBase implements ContainerFactoryPluginInterface
// The processed text now depends on:
$result
// - the linked entity access for the current user
// - the linked entity access for the current user.
->addCacheableDependency($access)
// - the generated URL (which has undergone path & route processing)
// - the generated URL (which has undergone path & route
// processing)
->addCacheableDependency($url)
// - the linked entity (whose URL and title may change)
->addCacheableDependency($entity);
......@@ -103,7 +104,7 @@ class LinkitFilter extends FilterBase implements ContainerFactoryPluginInterface
throw new EntityNotFoundException(sprintf('Unable to load entity %s %s.', $entity_type, $uuid));
}
}
catch(\Exception $e) {
catch (\Exception $e) {
watchdog_exception('linkit_filter', $e);
}
}
......
......@@ -26,9 +26,17 @@ class LinkitAutocompleteTest extends KernelTestBase {
*
* @var array
*/
public static $modules = ['system', 'user', 'entity_test', 'linkit', 'language'];
public static $modules = [
'system',
'user',
'entity_test',
'linkit',
'language',
];
/**
* The linkit profile.
*
* @var \Drupal\Linkit\ProfileInterface
*/
protected $linkitProfile;
......@@ -87,7 +95,7 @@ class LinkitAutocompleteTest extends KernelTestBase {
/**
* Tests that 'front' adds the front page match.
*/
function testAutocompletionFront() {
public function testAutocompletionFront() {
$data = $this->getAutocompleteResult('front');
$this->assertSame('Front page', $data[0]['title'], 'Autocomplete returned the front page match.');
}
......@@ -179,7 +187,7 @@ class LinkitAutocompleteTest extends KernelTestBase {
* The label of the entity to query by.
*
* @return array
* An array of matches.
* An array of matches.
*/
protected function getAutocompleteResult($input) {
$request = Request::create('linkit/autocomplete/' . $this->linkitProfile->id());
......@@ -222,13 +230,14 @@ class LinkitAutocompleteTest extends KernelTestBase {
/**
* Returns the "no results" match.
*
* @return array with a fixed value of no results.
* @return array
* An array with a fixed value of no results.
*
* @todo Should this use some kind of t() function?
*/
protected function noResults() {
return [
'title' => 'No results'
'title' => 'No results',
];
}
......@@ -239,9 +248,8 @@ class LinkitAutocompleteTest extends KernelTestBase {
$this->langcodes = ['sv', 'da', 'fi'];
foreach ($this->langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)->save();
$prefixes[$langcode] = $langcode;
}
array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->getId());
}
}
\ No newline at end of file
}
......@@ -50,7 +50,7 @@ class LinkitFilterEntityTest extends LinkitFilterTestBase {
// Automatically set the title.
$this->filter->setConfiguration(['settings' => ['title' => 1]]);
// The title should not be included
// The title should not be included.
$input = '<a data-entity-type="' . $entity_no_access->getEntityTypeId() . '" data-entity-uuid="' . $entity_no_access->uuid() . '">Link text</a>';
$this->assertFalse(strpos($this->process($input)->getProcessedText(), 'title'), 'The link does not contain a title attribute.');
$this->assertLinkitFilterWithTitle($entity_with_access);
......@@ -81,17 +81,17 @@ class LinkitFilterEntityTest extends LinkitFilterTestBase {
// Disable the automatic title attribute.
$this->filter->setConfiguration(['settings' => ['title' => 0]]);
/** @var \Drupal\Core\Language\Language $language */
/** @var \Drupal\Core\Language\Language $language */
foreach ($entity->getTranslationLanguages() as $language) {
$this->assertLinkitFilter($entity->getTranslation($language->getId()), $language->getId());
}
// Enable the automatic title attribute.
$this->filter->setConfiguration(['settings' => ['title' => 1]]);
/** @var \Drupal\Core\Language\Language $language */
/** @var \Drupal\Core\Language\Language $language */
foreach ($entity->getTranslationLanguages() as $language) {
$this->assertLinkitFilterWithTitle($entity->getTranslation($language->getId()), $language->getId());
}
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment