RowCountExceptionTest.php in Drupal 10
File
core/tests/Drupal/Tests/Core/Database/RowCountExceptionTest.php
View source
<?php
namespace Drupal\Tests\Core\Database;
use Drupal\Core\Database\RowCountException;
use Drupal\Tests\UnitTestCase;
class RowCountExceptionTest extends UnitTestCase {
private const DEFAULT_EXCEPTION_MESSAGE = "rowCount() is supported for DELETE, INSERT, or UPDATE statements performed with structured query builders only, since they would not be portable across database engines otherwise. If the query builders are not sufficient, use a prepareStatement() with an \$allow_row_count argument set to TRUE, execute() the Statement and get the number of affected rows via rowCount().";
public function providerTestExceptionMessage() {
return [
[
static::DEFAULT_EXCEPTION_MESSAGE,
'',
],
[
'test',
'test',
],
];
}
public function testExceptionMessage($expected, $message) {
$e = new RowCountException($message);
$this
->assertSame($expected, $e
->getMessage());
}
public function testExceptionMessageNull() {
$e = new RowCountException(NULL);
$this
->assertSame(static::DEFAULT_EXCEPTION_MESSAGE, $e
->getMessage());
}
}