comparison core/tests/Drupal/Tests/AssertHelperTraitTest.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\Tests;
4
5 use Drupal\Core\Render\Markup;
6
7 /**
8 * @coversDefaultClass \Drupal\Tests\AssertHelperTrait
9 * @group simpletest
10 * @group Tests
11 */
12 class AssertHelperTraitTest extends UnitTestCase {
13
14 /**
15 * @covers ::castSafeStrings
16 * @dataProvider providerCastSafeStrings
17 */
18 public function testCastSafeStrings($expected, $value) {
19 $class = new AssertHelperTestClass();
20 $this->assertSame($expected, $class->testMethod($value));
21 }
22
23 public function providerCastSafeStrings() {
24 $safe_string = Markup::create('test safe string');
25 return [
26 ['test simple string', 'test simple string'],
27 [['test simple array', 'test simple array'], ['test simple array', 'test simple array']],
28 ['test safe string', $safe_string],
29 [['test safe string', 'test safe string'], [$safe_string, $safe_string]],
30 [['test safe string', 'mixed array', 'test safe string'], [$safe_string, 'mixed array', $safe_string]],
31 ];
32 }
33
34 }
35
36 class AssertHelperTestClass {
37 use AssertHelperTrait;
38
39 public function testMethod($value) {
40 return $this->castSafeStrings($value);
41 }
42
43 }