Commit 445abea9 authored by webchick's avatar webchick

Issue #2259301 by martin107 | alexpott: Move OptGroup tests out of FormBuilderTest.

parent cfbbef3c
......@@ -9,7 +9,6 @@
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Form\OptGroup;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -472,33 +471,6 @@ public function testRebuildForm() {
$this->assertNotSame($original_build_id, $form['#build_id']);
}
/**
* Tests the flattenOptions() method.
*
* @dataProvider providerTestFlattenOptions
*/
public function testFlattenOptions($options) {
$this->assertSame(array('foo' => 1), OptGroup::flattenOptions($options));
}
/**
* Provides test data for the flattenOptions() method.
*
* @return array
*/
public function providerTestFlattenOptions() {
$object1 = new \stdClass();
$object1->option = array('foo' => 'foo');
$object2 = new \stdClass();
$object2->option = array(array('foo' => 'foo'), array('foo' => 'foo'));
return array(
array(array('foo' => 'foo')),
array(array(array('foo' => 'foo'))),
array(array($object1)),
array(array($object2)),
);
}
/**
* Tests the getCache() method.
*/
......
<?php
/**
* @file
* Contains \Drupal\Tests\Core\Form\OptGroupTest.
*/
namespace Drupal\Tests\Core\Form;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Form\OptGroup;
/**
* Tests the OptGroup class.
*
* @coversDefaultClass \Drupal\Core\Form\OptGroup
*
* @group Drupal
* @group Form
*/
class OptGroupTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'OptGroup test',
'description' => 'Tests the OptGroup class.',
'group' => 'Form API',
);
}
/**
* Tests the flattenOptions() method.
*
* @dataProvider providerTestFlattenOptions
*/
public function testFlattenOptions($options) {
$this->assertSame(array('foo' => 1), OptGroup::flattenOptions($options));
}
/**
* Provides test data for the flattenOptions() method.
*
* @return array
*/
public function providerTestFlattenOptions() {
$object1 = new \stdClass();
$object1->option = array('foo' => 'foo');
$object2 = new \stdClass();
$object2->option = array(array('foo' => 'foo'), array('foo' => 'foo'));
return array(
array(array('foo' => 'foo')),
array(array(array('foo' => 'foo'))),
array(array($object1)),
array(array($object2)),
);
}
}
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