Mercurial > hg > cmmr2012-drupal-site
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/tests/Drupal/Tests/AssertHelperTraitTest.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,43 @@ +<?php + +namespace Drupal\Tests; + +use Drupal\Core\Render\Markup; + +/** + * @coversDefaultClass \Drupal\Tests\AssertHelperTrait + * @group simpletest + * @group Tests + */ +class AssertHelperTraitTest extends UnitTestCase { + + /** + * @covers ::castSafeStrings + * @dataProvider providerCastSafeStrings + */ + public function testCastSafeStrings($expected, $value) { + $class = new AssertHelperTestClass(); + $this->assertSame($expected, $class->testMethod($value)); + } + + public function providerCastSafeStrings() { + $safe_string = Markup::create('test safe string'); + return [ + ['test simple string', 'test simple string'], + [['test simple array', 'test simple array'], ['test simple array', 'test simple array']], + ['test safe string', $safe_string], + [['test safe string', 'test safe string'], [$safe_string, $safe_string]], + [['test safe string', 'mixed array', 'test safe string'], [$safe_string, 'mixed array', $safe_string]], + ]; + } + +} + +class AssertHelperTestClass { + use AssertHelperTrait; + + public function testMethod($value) { + return $this->castSafeStrings($value); + } + +}