Loading core/tests/Drupal/Tests/Component/Utility/VariableTest.php +19 −15 Original line number Diff line number Diff line Loading @@ -15,12 +15,6 @@ */ class VariableTest extends TestCase { /** * A bogus callable for testing ::callableToString(). */ public static function fake(): void { } /** * Data provider for testCallableToString(). * Loading @@ -28,15 +22,15 @@ public static function fake(): void { * Sets of arguments to pass to the test method. */ public function providerCallableToString(): array { $self = static::class; $mock = VariableTestMock::class; return [ 'string' => [ "$self::fake", "$self::fake", "$mock::fake", "$mock::fake", ], 'static method as array' => [ [$self, 'fake'], "$self::fake", [$mock, 'fake'], "$mock::fake", ], 'closure' => [ function () { Loading @@ -45,8 +39,8 @@ function () { '[closure]', ], 'object method' => [ [new static(), 'fake'], "$self::fake", [new VariableTestMock(), 'fake'], "$mock::fake", ], 'service method' => [ 'fake_service:method', Loading Loading @@ -184,11 +178,21 @@ public function testExport($expected, $variable) { } class VariableTestMock { /** * A bogus callable for testing ::callableToString(). */ public static function fake(): void { } } /** * No-op test class for VariableTest::testExport(). * * @see Drupal\Tests\Component\Utility\VariableTest::testExport() * @see Drupal\Tests\Component\Utility\VariableTest::providerTestExport() * @see \Drupal\Tests\Component\Utility\VariableTest::testExport() * @see \Drupal\Tests\Component\Utility\VariableTest::providerTestExport() */ class StubVariableTestClass { Loading core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php +7 −18 Original line number Diff line number Diff line Loading @@ -11,11 +11,13 @@ */ class AssertContentTraitTest extends UnitTestCase { use AssertContentTrait; /** * @covers ::getTextContent */ public function testGetTextContent() { $test = new TestClass(); $raw_content = <<<EOT <Head> Loading @@ -27,23 +29,10 @@ public function testGetTextContent() { bar </body> EOT; $test->_setRawContent($raw_content); $this->assertStringNotContainsString('foo', $test->_getTextContent()); $this->assertStringNotContainsString('<body>', $test->_getTextContent()); $this->assertStringContainsString('bar', $test->_getTextContent()); } } class TestClass extends UnitTestCase { use AssertContentTrait; public function _setRawContent($content) { $this->setRawContent($content); } public function _getTextContent() { return $this->getTextContent(); $this->setRawContent($raw_content); $this->assertStringNotContainsString('foo', $this->getTextContent()); $this->assertStringNotContainsString('<body>', $this->getTextContent()); $this->assertStringContainsString('bar', $this->getTextContent()); } } Loading
core/tests/Drupal/Tests/Component/Utility/VariableTest.php +19 −15 Original line number Diff line number Diff line Loading @@ -15,12 +15,6 @@ */ class VariableTest extends TestCase { /** * A bogus callable for testing ::callableToString(). */ public static function fake(): void { } /** * Data provider for testCallableToString(). * Loading @@ -28,15 +22,15 @@ public static function fake(): void { * Sets of arguments to pass to the test method. */ public function providerCallableToString(): array { $self = static::class; $mock = VariableTestMock::class; return [ 'string' => [ "$self::fake", "$self::fake", "$mock::fake", "$mock::fake", ], 'static method as array' => [ [$self, 'fake'], "$self::fake", [$mock, 'fake'], "$mock::fake", ], 'closure' => [ function () { Loading @@ -45,8 +39,8 @@ function () { '[closure]', ], 'object method' => [ [new static(), 'fake'], "$self::fake", [new VariableTestMock(), 'fake'], "$mock::fake", ], 'service method' => [ 'fake_service:method', Loading Loading @@ -184,11 +178,21 @@ public function testExport($expected, $variable) { } class VariableTestMock { /** * A bogus callable for testing ::callableToString(). */ public static function fake(): void { } } /** * No-op test class for VariableTest::testExport(). * * @see Drupal\Tests\Component\Utility\VariableTest::testExport() * @see Drupal\Tests\Component\Utility\VariableTest::providerTestExport() * @see \Drupal\Tests\Component\Utility\VariableTest::testExport() * @see \Drupal\Tests\Component\Utility\VariableTest::providerTestExport() */ class StubVariableTestClass { Loading
core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php +7 −18 Original line number Diff line number Diff line Loading @@ -11,11 +11,13 @@ */ class AssertContentTraitTest extends UnitTestCase { use AssertContentTrait; /** * @covers ::getTextContent */ public function testGetTextContent() { $test = new TestClass(); $raw_content = <<<EOT <Head> Loading @@ -27,23 +29,10 @@ public function testGetTextContent() { bar </body> EOT; $test->_setRawContent($raw_content); $this->assertStringNotContainsString('foo', $test->_getTextContent()); $this->assertStringNotContainsString('<body>', $test->_getTextContent()); $this->assertStringContainsString('bar', $test->_getTextContent()); } } class TestClass extends UnitTestCase { use AssertContentTrait; public function _setRawContent($content) { $this->setRawContent($content); } public function _getTextContent() { return $this->getTextContent(); $this->setRawContent($raw_content); $this->assertStringNotContainsString('foo', $this->getTextContent()); $this->assertStringNotContainsString('<body>', $this->getTextContent()); $this->assertStringContainsString('bar', $this->getTextContent()); } }