Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Form / OptGroupTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Form;
4
5 use Drupal\Tests\UnitTestCase;
6 use Drupal\Core\Form\OptGroup;
7
8 /**
9  * @coversDefaultClass \Drupal\Core\Form\OptGroup
10  * @group Form
11  */
12 class OptGroupTest extends UnitTestCase {
13
14   /**
15    * Tests the flattenOptions() method.
16    *
17    * @dataProvider providerTestFlattenOptions
18    */
19   public function testFlattenOptions($options) {
20     $this->assertSame(['foo' => 'foo'], OptGroup::flattenOptions($options));
21   }
22
23   /**
24    * Provides test data for the flattenOptions() method.
25    *
26    * @return array
27    */
28   public function providerTestFlattenOptions() {
29     $object1 = new \stdClass();
30     $object1->option = ['foo' => 'foo'];
31     $object2 = new \stdClass();
32     $object2->option = [['foo' => 'foo'], ['foo' => 'foo']];
33     $object3 = new \stdClass();
34     return [
35       [['foo' => 'foo']],
36       [[['foo' => 'foo']]],
37       [[$object1]],
38       [[$object2]],
39       [[$object1, $object2]],
40       [['foo' => $object3, $object1, ['foo' => 'foo']]],
41     ];
42   }
43
44 }