You are here

public function SchemaMetatagManagerTest::arrayData in Schema.org Metatag 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/SchemaMetatagManagerTest.php \Drupal\Tests\schema_metatag\Unit\SchemaMetatagManagerTest::arrayData()

Provides array data.

Return value

array

  • name: name of the data set.

    • tests: array of the tests this data set applies to.
    • original: original data array.
    • original_serialized: serialized version of original data.
    • desired: desired result as array.
    • desired_serialized: desired result, serialized.

File

tests/src/Unit/SchemaMetatagManagerTest.php, line 143

Class

SchemaMetatagManagerTest
@coversDefaultClass \Drupal\schema_metatag\SchemaMetatagManager

Namespace

Drupal\Tests\schema_metatag\Unit

Code

public function arrayData() {
  $values['Dirty input'] = [
    [
      'explode',
    ],
    [
      '@type' => ' Organization',
      'name' => 'test ',
      'description' => 'more text',
    ],
    'a:1:{s:5:"@type";a:1:{s:13:" Organization";a:2:{s:4:"name";s:5:"test ";s:11:"description";s:9:"more text";}}}',
    [
      '@type' => 'Organization',
      'name' => 'test',
      'description' => 'more text',
    ],
    'a:1:{s:5:"@type";a:1:{s:12:"Organization";a:2:{s:4:"name";s:4:"test";s:11:"description";s:9:"more text";}}}',
  ];
  $values['Nested array'] = [
    [
      'arraytrim',
      'serialize',
      'unserialize',
      'explode',
      'recompute',
    ],
    [
      '@type' => 'Organization',
      'memberOf' => [
        '@type' => 'Organization',
        'name' => 'test',
        'description' => 'more text',
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:8:"memberOf";a:3:{s:5:"@type";s:12:"Organization";s:4:"name";s:4:"test";s:11:"description";s:9:"more text";}}',
    [
      '@type' => 'Organization',
      'memberOf' => [
        '@type' => 'Organization',
        'name' => 'test',
        'description' => 'more text',
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:8:"memberOf";a:3:{s:5:"@type";s:12:"Organization";s:4:"name";s:4:"test";s:11:"description";s:9:"more text";}}',
  ];
  $values['Nested array 2 levels deep'] = [
    [
      'arraytrim',
      'serialize',
      'unserialize',
      'explode',
      'recompute',
    ],
    [
      '@type' => 'Organization',
      'publishedIn' => [
        '@type' => 'CreativeWork',
        'name' => 'test',
        'description' => 'more text',
        'level3' => [
          '@type' => 'Book',
          'name' => 'Book Name',
        ],
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:11:"publishedIn";a:4:{s:5:"@type";s:12:"CreativeWork";s:4:"name";s:4:"test";s:11:"description";s:9:"more text";s:6:"level3";a:2:{s:5:"@type";s:4:"Book";s:4:"name";s:9:"Book Name";}}}',
    [
      '@type' => 'Organization',
      'publishedIn' => [
        '@type' => 'CreativeWork',
        'name' => 'test',
        'description' => 'more text',
        'level3' => [
          '@type' => 'Book',
          'name' => 'Book Name',
        ],
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:11:"publishedIn";a:4:{s:5:"@type";s:12:"CreativeWork";s:4:"name";s:4:"test";s:11:"description";s:9:"more text";s:6:"level3";a:2:{s:5:"@type";s:4:"Book";s:4:"name";s:9:"Book Name";}}}',
  ];
  $values['Nested array with nested type only'] = [
    [
      'arraytrim',
      'serialize',
      'unserialize',
      'explode',
      'recompute',
    ],
    [
      '@type' => 'Organization',
      'publishedIn' => [
        '@type' => 'CreativeWork',
      ],
      'anotherThing' => [
        '@type' => 'Thing',
        'name' => 'test',
        'description' => 'more text',
        'level3' => [
          '@type' => 'Book',
          'name' => 'Book Name',
        ],
      ],
    ],
    'a:3:{s:5:"@type";s:12:"Organization";s:11:"publishedIn";a:1:{s:5:"@type";s:12:"CreativeWork";}s:12:"anotherThing";a:4:{s:5:"@type";s:5:"Thing";s:4:"name";s:4:"test";s:11:"description";s:9:"more text";s:6:"level3";a:2:{s:5:"@type";s:4:"Book";s:4:"name";s:9:"Book Name";}}}',
    [
      '@type' => 'Organization',
      'anotherThing' => [
        '@type' => 'Thing',
        'name' => 'test',
        'description' => 'more text',
        'level3' => [
          '@type' => 'Book',
          'name' => 'Book Name',
        ],
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:12:"anotherThing";a:4:{s:5:"@type";s:5:"Thing";s:4:"name";s:4:"test";s:11:"description";s:9:"more text";s:6:"level3";a:2:{s:5:"@type";s:4:"Book";s:4:"name";s:9:"Book Name";}}}',
  ];
  $values['Empty nested array'] = [
    [
      'arraytrim',
      'serialize',
      'unserialize',
      'explode',
    ],
    [
      'name' => [],
      'Organization' => [
        '@type' => '',
        'name' => '',
      ],
    ],
    'a:2:{s:4:"name";a:0:{}s:12:"Organization";a:2:{s:5:"@type";s:0:"";s:4:"name";s:0:"";}}',
    [],
    '',
  ];
  $values['Missing type to empty array'] = [
    [
      'arraytrim',
      'serialize',
      'unserialize',
      'explode',
    ],
    [
      'organization' => [
        '@type' => '',
        'name' => 'test',
        'description' => 'test2',
      ],
    ],
    'a:1:{s:12:"organization";a:3:{s:5:"@type";s:0:"";s:4:"name";s:4:"test";s:11:"description";s:5:"test2";}}',
    [],
    '',
  ];
  $values['Type only to empty array'] = [
    [
      'arraytrim',
      'serialize',
      'unserialize',
      'explode',
    ],
    [
      'organization' => [
        '@type' => 'Organization',
        'name' => '',
        'description' => '',
      ],
    ],
    'a:1:{s:12:"organization";a:3:{s:5:"@type";s:12:"Organization";s:4:"name";s:0:"";s:11:"description";s:0:"";}}',
    [],
    '',
  ];
  $values['Array with empty parts'] = [
    [
      'recompute',
    ],
    [
      '@type' => 'Organization',
      'memberOf' => [
        '@type' => 'Organization',
        'name' => '',
        'description' => 'more text',
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:8:"memberOf";a:3:{s:5:"@type";s:12:"Organization";s:4:"name";s:0:"";s:11:"description";s:9:"more text";}}',
    [
      '@type' => 'Organization',
      'memberOf' => [
        '@type' => 'Organization',
        'description' => 'more text',
      ],
    ],
    'a:2:{s:5:"@type";s:12:"Organization";s:8:"memberOf";a:3:{s:5:"@type";s:12:"Organization";s:11:"description";s:9:"more text";}}',
  ];
  return $values;
}