Unverified Commit b644848b authored by alexpott's avatar alexpott

Issue #2555145 by TR, kostyashupenko, Mile23, oriol_e9g, geertvd: Remove t()...

Issue #2555145 by TR, kostyashupenko, Mile23, oriol_e9g, geertvd: Remove t() from pass/fail assertions in tests
parent 45f97bcf
...@@ -100,20 +100,20 @@ public function testCreateField() { ...@@ -100,20 +100,20 @@ public function testCreateField() {
// Guarantee that the field/bundle combination is unique. // Guarantee that the field/bundle combination is unique.
try { try {
FieldConfig::create($this->fieldDefinition)->save(); FieldConfig::create($this->fieldDefinition)->save();
$this->fail(t('Cannot create two fields with the same field / bundle combination.')); $this->fail('Cannot create two fields with the same field / bundle combination.');
} }
catch (EntityStorageException $e) { catch (EntityStorageException $e) {
$this->pass(t('Cannot create two fields with the same field / bundle combination.')); $this->pass('Cannot create two fields with the same field / bundle combination.');
} }
// Check that the specified field exists. // Check that the specified field exists.
try { try {
$this->fieldDefinition['field_name'] = $this->randomMachineName(); $this->fieldDefinition['field_name'] = $this->randomMachineName();
FieldConfig::create($this->fieldDefinition)->save(); FieldConfig::create($this->fieldDefinition)->save();
$this->fail(t('Cannot create a field with a non-existing storage.')); $this->fail('Cannot create a field with a non-existing storage.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create a field with a non-existing storage.')); $this->pass('Cannot create a field with a non-existing storage.');
} }
// TODO: test other failures. // TODO: test other failures.
......
...@@ -78,10 +78,10 @@ public function testCreate() { ...@@ -78,10 +78,10 @@ public function testCreate() {
// Guarantee that the name is unique. // Guarantee that the name is unique.
try { try {
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create two fields with the same name.')); $this->fail('Cannot create two fields with the same name.');
} }
catch (EntityStorageException $e) { catch (EntityStorageException $e) {
$this->pass(t('Cannot create two fields with the same name.')); $this->pass('Cannot create two fields with the same name.');
} }
// Check that field type is required. // Check that field type is required.
...@@ -91,10 +91,10 @@ public function testCreate() { ...@@ -91,10 +91,10 @@ public function testCreate() {
'entity_type' => 'entity_type', 'entity_type' => 'entity_type',
]; ];
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with no type.')); $this->fail('Cannot create a field with no type.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create a field with no type.')); $this->pass('Cannot create a field with no type.');
} }
// Check that field name is required. // Check that field name is required.
...@@ -104,10 +104,10 @@ public function testCreate() { ...@@ -104,10 +104,10 @@ public function testCreate() {
'entity_type' => 'entity_test', 'entity_type' => 'entity_test',
]; ];
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create an unnamed field.')); $this->fail('Cannot create an unnamed field.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create an unnamed field.')); $this->pass('Cannot create an unnamed field.');
} }
// Check that entity type is required. // Check that entity type is required.
try { try {
...@@ -130,10 +130,10 @@ public function testCreate() { ...@@ -130,10 +130,10 @@ public function testCreate() {
'type' => 'test_field', 'type' => 'test_field',
]; ];
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with a name starting with a digit.')); $this->fail('Cannot create a field with a name starting with a digit.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create a field with a name starting with a digit.')); $this->pass('Cannot create a field with a name starting with a digit.');
} }
// Check that field name must only contain lowercase alphanumeric or _. // Check that field name must only contain lowercase alphanumeric or _.
...@@ -144,10 +144,10 @@ public function testCreate() { ...@@ -144,10 +144,10 @@ public function testCreate() {
'type' => 'test_field', 'type' => 'test_field',
]; ];
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with a name containing an illegal character.')); $this->fail('Cannot create a field with a name containing an illegal character.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create a field with a name containing an illegal character.')); $this->pass('Cannot create a field with a name containing an illegal character.');
} }
// Check that field name cannot be longer than 32 characters long. // Check that field name cannot be longer than 32 characters long.
...@@ -158,10 +158,10 @@ public function testCreate() { ...@@ -158,10 +158,10 @@ public function testCreate() {
'type' => 'test_field', 'type' => 'test_field',
]; ];
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field with a name longer than 32 characters.')); $this->fail('Cannot create a field with a name longer than 32 characters.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create a field with a name longer than 32 characters.')); $this->pass('Cannot create a field with a name longer than 32 characters.');
} }
// Check that field name can not be an entity key. // Check that field name can not be an entity key.
...@@ -173,10 +173,10 @@ public function testCreate() { ...@@ -173,10 +173,10 @@ public function testCreate() {
'entity_type' => 'entity_test', 'entity_type' => 'entity_test',
]; ];
FieldStorageConfig::create($field_storage_definition)->save(); FieldStorageConfig::create($field_storage_definition)->save();
$this->fail(t('Cannot create a field bearing the name of an entity key.')); $this->fail('Cannot create a field bearing the name of an entity key.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot create a field bearing the name of an entity key.')); $this->pass('Cannot create a field bearing the name of an entity key.');
} }
} }
...@@ -376,10 +376,10 @@ public function testUpdateFieldType() { ...@@ -376,10 +376,10 @@ public function testUpdateFieldType() {
try { try {
$field_storage->set('type', 'integer'); $field_storage->set('type', 'integer');
$field_storage->save(); $field_storage->save();
$this->fail(t('Cannot update a field to a different type.')); $this->fail('Cannot update a field to a different type.');
} }
catch (FieldException $e) { catch (FieldException $e) {
$this->pass(t('Cannot update a field to a different type.')); $this->pass('Cannot update a field to a different type.');
} }
} }
...@@ -442,18 +442,18 @@ public function testUpdateForbid() { ...@@ -442,18 +442,18 @@ public function testUpdateForbid() {
$field_storage->setSetting('changeable', $field_storage->getSetting('changeable') + 1); $field_storage->setSetting('changeable', $field_storage->getSetting('changeable') + 1);
try { try {
$field_storage->save(); $field_storage->save();
$this->pass(t("A changeable setting can be updated.")); $this->pass('A changeable setting can be updated.');
} }
catch (FieldStorageDefinitionUpdateForbiddenException $e) { catch (FieldStorageDefinitionUpdateForbiddenException $e) {
$this->fail(t("An unchangeable setting cannot be updated.")); $this->fail('An unchangeable setting cannot be updated.');
} }
$field_storage->setSetting('unchangeable', $field_storage->getSetting('unchangeable') + 1); $field_storage->setSetting('unchangeable', $field_storage->getSetting('unchangeable') + 1);
try { try {
$field_storage->save(); $field_storage->save();
$this->fail(t("An unchangeable setting can be updated.")); $this->fail('An unchangeable setting can be updated.');
} }
catch (FieldStorageDefinitionUpdateForbiddenException $e) { catch (FieldStorageDefinitionUpdateForbiddenException $e) {
$this->pass(t("An unchangeable setting cannot be updated.")); $this->pass('An unchangeable setting cannot be updated.');
} }
} }
......
...@@ -97,10 +97,10 @@ public function testFailedPageCreation() { ...@@ -97,10 +97,10 @@ public function testFailedPageCreation() {
// An exception is generated by node_test_exception_node_insert() if the // An exception is generated by node_test_exception_node_insert() if the
// title is 'testing_transaction_exception'. // title is 'testing_transaction_exception'.
Node::create($edit)->save(); Node::create($edit)->save();
$this->fail(t('Expected exception has not been thrown.')); $this->fail('Expected exception has not been thrown.');
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->pass(t('Expected exception has been thrown.')); $this->pass('Expected exception has been thrown.');
} }
if (Database::getConnection()->supportsTransactions()) { if (Database::getConnection()->supportsTransactions()) {
......
...@@ -65,7 +65,7 @@ public function testNodeQueryAlterLowLevelWithAccess() { ...@@ -65,7 +65,7 @@ public function testNodeQueryAlterLowLevelWithAccess() {
$this->assertEqual(count($result), 4, 'User with access can see correct nodes'); $this->assertEqual(count($result), 4, 'User with access can see correct nodes');
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->fail(t('Altered query is malformed')); $this->fail('Altered query is malformed');
} }
} }
...@@ -106,7 +106,7 @@ public function testNodeQueryAlterLowLevelNoAccess() { ...@@ -106,7 +106,7 @@ public function testNodeQueryAlterLowLevelNoAccess() {
$this->assertEqual(count($result), 0, 'User with no access cannot see nodes'); $this->assertEqual(count($result), 0, 'User with no access cannot see nodes');
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->fail(t('Altered query is malformed')); $this->fail('Altered query is malformed');
} }
} }
...@@ -131,7 +131,7 @@ public function testNodeQueryAlterLowLevelEditAccess() { ...@@ -131,7 +131,7 @@ public function testNodeQueryAlterLowLevelEditAccess() {
catch (\Exception $e) { catch (\Exception $e) {
$this->fail($e->getMessage()); $this->fail($e->getMessage());
$this->fail((string) $query); $this->fail((string) $query);
$this->fail(t('Altered query is malformed')); $this->fail('Altered query is malformed');
} }
} }
...@@ -170,7 +170,7 @@ public function testNodeQueryAlterOverride() { ...@@ -170,7 +170,7 @@ public function testNodeQueryAlterOverride() {
$this->assertEqual(count($result), 0, 'User view privileges are not overridden'); $this->assertEqual(count($result), 0, 'User view privileges are not overridden');
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->fail(t('Altered query is malformed')); $this->fail('Altered query is malformed');
} }
// Have node_test_node_grants return a node_access_all privilege, // Have node_test_node_grants return a node_access_all privilege,
...@@ -192,7 +192,7 @@ public function testNodeQueryAlterOverride() { ...@@ -192,7 +192,7 @@ public function testNodeQueryAlterOverride() {
$this->assertEqual(count($result), 4, 'User view privileges are overridden'); $this->assertEqual(count($result), 4, 'User view privileges are overridden');
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->fail(t('Altered query is malformed')); $this->fail('Altered query is malformed');
} }
\Drupal::state()->delete('node_access_test.no_access_uid'); \Drupal::state()->delete('node_access_test.no_access_uid');
} }
......
...@@ -40,10 +40,10 @@ public function testUpdateAllowedValues() { ...@@ -40,10 +40,10 @@ public function testUpdateAllowedValues() {
$this->fieldStorage->setSetting('allowed_values', [2 => 'Two']); $this->fieldStorage->setSetting('allowed_values', [2 => 'Two']);
try { try {
$this->fieldStorage->save(); $this->fieldStorage->save();
$this->fail(t('Cannot update a list field storage to not include keys with existing data.')); $this->fail('Cannot update a list field storage to not include keys with existing data.');
} }
catch (FieldStorageDefinitionUpdateForbiddenException $e) { catch (FieldStorageDefinitionUpdateForbiddenException $e) {
$this->pass(t('Cannot update a list field storage to not include keys with existing data.')); $this->pass('Cannot update a list field storage to not include keys with existing data.');
} }
// Empty the value, so that we can actually remove the option. // Empty the value, so that we can actually remove the option.
unset($entity->{$this->fieldName}); unset($entity->{$this->fieldName});
......
...@@ -205,7 +205,7 @@ public function stubTest() { ...@@ -205,7 +205,7 @@ public function stubTest() {
// This causes the eleventh of the sixteen passes asserted in // This causes the eleventh of the sixteen passes asserted in
// confirmStubResults(). // confirmStubResults().
$this->pass(t('Test ID is @id.', ['@id' => $this->testId])); $this->pass('Test ID is ' . $this->testId . '.');
// These cause the twelfth to fifteenth of the sixteen passes asserted in // These cause the twelfth to fifteenth of the sixteen passes asserted in
// confirmStubResults(). // confirmStubResults().
...@@ -234,7 +234,7 @@ public function stubTest() { ...@@ -234,7 +234,7 @@ public function stubTest() {
* Assert nothing. * Assert nothing.
*/ */
public function assertNothing() { public function assertNothing() {
$this->pass("This is nothing."); $this->pass('This is nothing.');
} }
/** /**
......
...@@ -92,10 +92,10 @@ public function testDependencyResolution() { ...@@ -92,10 +92,10 @@ public function testDependencyResolution() {
try { try {
$result = $this->moduleInstaller()->install(['color']); $result = $this->moduleInstaller()->install(['color']);
$this->fail(t('ModuleInstaller::install() throws an exception if dependencies are missing.')); $this->fail('ModuleInstaller::install() throws an exception if dependencies are missing.');
} }
catch (MissingDependencyException $e) { catch (MissingDependencyException $e) {
$this->pass(t('ModuleInstaller::install() throws an exception if dependencies are missing.')); $this->pass('ModuleInstaller::install() throws an exception if dependencies are missing.');
} }
$this->assertFalse($this->moduleHandler()->moduleExists('color'), 'ModuleInstaller::install() aborts if dependencies are missing.'); $this->assertFalse($this->moduleHandler()->moduleExists('color'), 'ModuleInstaller::install() aborts if dependencies are missing.');
......
...@@ -293,9 +293,10 @@ public function testTransactionWithDdlStatement() { ...@@ -293,9 +293,10 @@ public function testTransactionWithDdlStatement() {
try { try {
$transaction->rollBack(); $transaction->rollBack();
unset($transaction); unset($transaction);
// @TODO: an exception should be triggered here, but is not, because // @todo An exception should be triggered here, but is not because
// "ROLLBACK" fails silently in MySQL if there is no transaction active. // "ROLLBACK" fails silently in MySQL if there is no transaction active.
// $this->fail(t('Rolling back a transaction containing DDL should fail.')); // @see https://www.drupal.org/project/drupal/issues/2736777
// $this->fail('Rolling back a transaction containing DDL should fail.');
} }
catch (TransactionNoActiveException $e) { catch (TransactionNoActiveException $e) {
$this->pass('Rolling back a transaction containing DDL should fail.'); $this->pass('Rolling back a transaction containing DDL should fail.');
......
...@@ -341,10 +341,10 @@ public function testUpdateFieldSchemaWithData() { ...@@ -341,10 +341,10 @@ public function testUpdateFieldSchemaWithData() {
$field_storage->setSetting('scale', 3); $field_storage->setSetting('scale', 3);
try { try {
$field_storage->save(); $field_storage->save();
$this->fail(t('Cannot update field schema with data.')); $this->fail('Cannot update field schema with data.');
} }
catch (FieldStorageDefinitionUpdateForbiddenException $e) { catch (FieldStorageDefinitionUpdateForbiddenException $e) {
$this->pass(t('Cannot update field schema with data.')); $this->pass('Cannot update field schema with data.');
} }
} }
...@@ -370,10 +370,10 @@ public function testFieldUpdateFailure() { ...@@ -370,10 +370,10 @@ public function testFieldUpdateFailure() {
$field_storage->setSetting('max_length', '-1)'); $field_storage->setSetting('max_length', '-1)');
try { try {
$field_storage->save(); $field_storage->save();
$this->fail(t('Update succeeded.')); $this->fail('Update succeeded.');
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->pass(t('Update properly failed.')); $this->pass('Update properly failed.');
} }
// Ensure that the field tables are still there. // Ensure that the field tables are still there.
......
...@@ -99,7 +99,7 @@ public function testAddAdditionalRoutes() { ...@@ -99,7 +99,7 @@ public function testAddAdditionalRoutes() {
foreach ($collection_routes as $name => $route) { foreach ($collection_routes as $name => $route) {
if (empty($dumper_routes[$name])) { if (empty($dumper_routes[$name])) {
$success = FALSE; $success = FALSE;
$this->fail(t('Not all routes found in the dumper.')); $this->fail('Not all routes found in the dumper.');
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment