Commit 3f7ca145 authored by Matthew Radcliffe's avatar Matthew Radcliffe
Browse files

Issue #3293175 by mradcliffe: Passed by Reference Errors

parent 5113e15b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ class FreelinkingPrepopulate extends FreelinkingPluginBase implements ContainerF

    $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple();

    $options = array_reduce($node_types, function (&$result, $node_type) {
    $options = array_reduce($node_types, function ($result, $node_type) {
      /** @var \Drupal\node\Entity\NodeType $node_type */
      $result[$node_type->id()] = $node_type->label();
      return $result;
+13 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\freelinking\Functional\FreelinkingBrowserTestBase;
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
use Drupal\user\Entity\Role;

/**
 * Tests embedded prepopulate links.
@@ -39,6 +40,15 @@ class FreelinkingPrepopulateTest extends FreelinkingBrowserTestBase {

    // Creates a content type to act as default prepopulate content type.
    $this->createContentType(['name' => 'Person', 'type' => 'person']);
    $this->createContentType(['name' => 'Restricted', 'type' => 'restricted']);

    $role_ids = $this->privilegedUser->getRoles(TRUE);
    $rid = reset($role_ids);
    $role = Role::load($rid);
    $this->grantPermissions($role, [
      'create person content',
      'edit own person content',
    ]);

    $vocabulary = $this->createVocabulary();

@@ -119,6 +129,7 @@ class FreelinkingPrepopulateTest extends FreelinkingBrowserTestBase {
        <li>Default with body: [[create:Alex|Alex|Add Alex|body="A page about Alex."]]</li>
        <li>Basic page: [[create:History of Programming|History of Programming|Create New Page|type=page]]</li>
        <li>With fields: [[create:Sam|Sam|Add Sam|body="A page about Sam."|field_basic="test"|field_tags="tag1,tag2,tag3"]]</li>
        <li>Restricted: [[create:Secret|Secret|Create New Restricted|type=restricted]]</li>
      </ul>
EOF;
    $this->drupalGet('node/add/page');
@@ -147,6 +158,8 @@ EOF;
      ->linkByHrefExists($pageLinkHref);
    $this->assertSession()
      ->linkByHrefExists($fieldsLinkHref);
    $this->assertSession()
      ->pageTextContainsOnce('Freelinking: Access denied to create missing content.');

    // Logout and visit the page.
    $this->drupalLogout();
+2 −2
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ EOF;
   *   The plugin information.
   */
  public static function extractPluginSettings($plugin_name, array $plugins) {
    return array_reduce($plugins, function (&$result, $info) use ($plugin_name) {
    return array_reduce($plugins, function ($result, $info) use ($plugin_name) {
      if ($info['plugin'] === $plugin_name) {
        $result = $info;
      }
@@ -336,7 +336,7 @@ EOF;
   *   An indexed array of allowed plugin information.
   */
  protected function extractAllowedPlugins(array $plugins) {
    return array_reduce($plugins, function (&$result, $info) {
    return array_reduce($plugins, function ($result, $info) {
      if ($info['enabled']) {
        $result[$info['plugin']] = $info;
      }
+1 −1
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ class NodeTitle extends FreelinkingPluginBase implements FreelinkingPluginInterf
   */
  protected function getAllowedNodeTypes() {
    $node_types = $this->configuration['settings']['nodetypes'];
    return array_reduce($node_types, function (&$result, $item) {
    return array_reduce($node_types, function ($result, $item) {
      if ($item) {
        $result[] = $item;
      }
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class DrupalOrgTest extends UnitTestCase {
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  protected function setUp(): void {
    // Mock string translation service.
    $tProphet = $this->prophesize('\Drupal\Core\StringTranslation\TranslationInterface');
    $tProphet->translateString(Argument::any())->willReturn('Click to view on drupal.org.');
Loading