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 / PasswordConfirmTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Render\Element;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Render\Element\PasswordConfirm;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Render\Element\PasswordConfirm
11  * @group Render
12  */
13 class PasswordConfirmTest extends UnitTestCase {
14
15   /**
16    * @covers ::valueCallback
17    *
18    * @dataProvider providerTestValueCallback
19    */
20   public function testValueCallback($expected, $element, $input) {
21     $form_state = $this->prophesize(FormStateInterface::class)->reveal();
22     $this->assertSame($expected, PasswordConfirm::valueCallback($element, $input, $form_state));
23   }
24
25   /**
26    * Data provider for testValueCallback().
27    */
28   public function providerTestValueCallback() {
29     $data = [];
30     $data[] = [['pass1' => '', 'pass2' => ''], [], NULL];
31     $data[] = [['pass1' => '', 'pass2' => ''], ['#default_value' => ['pass2' => 'value']], NULL];
32     $data[] = [['pass2' => 'value', 'pass1' => ''], ['#default_value' => ['pass2' => 'value']], FALSE];
33     $data[] = [['pass1' => '123456', 'pass2' => 'qwerty'], [], ['pass1' => '123456', 'pass2' => 'qwerty']];
34     $data[] = [['pass1' => '123', 'pass2' => '234'], [], ['pass1' => 123, 'pass2' => 234]];
35     $data[] = [['pass1' => '', 'pass2' => '234'], [], ['pass1' => ['array'], 'pass2' => 234]];
36
37     return $data;
38   }
39
40 }