Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Render / Element / TextfieldTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Render\Element;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Render\Element\Textfield;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Render\Element\Textfield
11  * @group Render
12  */
13 class TextfieldTest extends UnitTestCase {
14
15   /**
16    * @covers ::valueCallback
17    *
18    * @dataProvider providerTestValueCallback
19    */
20   public function testValueCallback($expected, $input) {
21     $element = [];
22     $form_state = $this->prophesize(FormStateInterface::class)->reveal();
23     $this->assertSame($expected, Textfield::valueCallback($element, $input, $form_state));
24   }
25
26   /**
27    * Data provider for testValueCallback().
28    */
29   public function providerTestValueCallback() {
30     $data = [];
31     $data[] = [NULL, FALSE];
32     $data[] = [NULL, NULL];
33     $data[] = ['', ['test']];
34     $data[] = ['test', 'test'];
35     $data[] = ['123', 123];
36     $data[] = ['testwithnewline', "test\nwith\rnewline"];
37
38     return $data;
39   }
40
41 }