AssertHelperTraitTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Drupal\Tests;
  3. use Drupal\Core\Render\Markup;
  4. /**
  5. * @coversDefaultClass \Drupal\Tests\AssertHelperTrait
  6. * @group simpletest
  7. * @group Tests
  8. */
  9. class AssertHelperTraitTest extends UnitTestCase {
  10. /**
  11. * @covers ::castSafeStrings
  12. * @dataProvider providerCastSafeStrings
  13. */
  14. public function testCastSafeStrings($expected, $value) {
  15. $class = new AssertHelperTestClass();
  16. $this->assertSame($expected, $class->testMethod($value));
  17. }
  18. public function providerCastSafeStrings() {
  19. $safe_string = Markup::create('test safe string');
  20. return [
  21. ['test simple string', 'test simple string'],
  22. [['test simple array', 'test simple array'], ['test simple array', 'test simple array']],
  23. ['test safe string', $safe_string],
  24. [['test safe string', 'test safe string'], [$safe_string, $safe_string]],
  25. [['test safe string', 'mixed array', 'test safe string'], [$safe_string, 'mixed array', $safe_string]],
  26. ];
  27. }
  28. }
  29. class AssertHelperTestClass {
  30. use AssertHelperTrait;
  31. public function testMethod($value) {
  32. return $this->castSafeStrings($value);
  33. }
  34. }