Issue #3131820 by jungle, mero.S, quietone: Replace assertions involving calls to is_string() with assertIsString()/assertIsNotString()

merge-requests/2419/head
catch 2020-05-01 10:59:36 +01:00
parent 15340c8899
commit 0dfb1d0d6d
4 changed files with 14 additions and 14 deletions

View File

@ -187,7 +187,7 @@ EOD;
$this->drupalPostForm(NULL, [], t('Confirm'));
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertTrue(is_string($entity->label()), 'Entity label is a string');
$this->assertIsString($entity->label());
$this->assertStringContainsString('ObjectSerialization', $entity->label(), 'Label contains serialized object');
}
else {

View File

@ -53,7 +53,7 @@ class ThemeTokenTest extends BrowserTestBase {
$settings = $this->getDrupalSettings();
$this->assertNotNull($settings['ajaxPageState']['theme_token']);
// The CSRF token is a 43 length string.
$this->assertTrue(is_string($settings['ajaxPageState']['theme_token']));
$this->assertIsString($settings['ajaxPageState']['theme_token']);
$this->assertEqual(strlen($settings['ajaxPageState']['theme_token']), 43);
}

View File

@ -390,7 +390,7 @@ class EntityFieldTest extends EntityKernelTestBase {
// Access the name field.
$this->assertEqual(1, $entity->id->value, new FormattableMarkup('%entity_type: ID value can be read.', ['%entity_type' => $entity_type]));
$this->assertTrue(is_string($entity->uuid->value), new FormattableMarkup('%entity_type: UUID value can be read.', ['%entity_type' => $entity_type]));
$this->assertIsString($entity->uuid->value);
$this->assertEqual('en', $entity->{$langcode_key}->value, new FormattableMarkup('%entity_type: Language code can be read.', ['%entity_type' => $entity_type]));
$this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, new FormattableMarkup('%entity_type: Language object can be read.', ['%entity_type' => $entity_type]));
$this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, new FormattableMarkup('%entity_type: User id can be read.', ['%entity_type' => $entity_type]));

View File

@ -73,7 +73,7 @@ class TypedDataTest extends KernelTestBase {
$typed_data->setValue(FALSE);
$this->assertTrue($typed_data->getValue() === FALSE, 'Boolean value was changed.');
$this->assertEqual($typed_data->validate()->count(), 0);
$this->assertTrue(is_string($typed_data->getString()), 'Boolean value was converted to string');
$this->assertIsString($typed_data->getString());
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Boolean wrapper is null-able.');
$this->assertEqual($typed_data->validate()->count(), 0);
@ -91,7 +91,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertTrue($typed_data->getValue() === $new_value, 'String value was changed.');
$this->assertEqual($typed_data->validate()->count(), 0);
// Funky test.
$this->assertTrue(is_string($typed_data->getString()), 'String value was converted to string');
$this->assertIsString($typed_data->getString());
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'String wrapper is null-able.');
$this->assertEqual($typed_data->validate()->count(), 0);
@ -107,7 +107,7 @@ class TypedDataTest extends KernelTestBase {
$new_value = rand();
$typed_data->setValue($new_value);
$this->assertTrue($typed_data->getValue() === $new_value, 'Integer value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'Integer value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Integer wrapper is null-able.');
@ -124,7 +124,7 @@ class TypedDataTest extends KernelTestBase {
$new_value = 678.90;
$typed_data->setValue($new_value);
$this->assertTrue($typed_data->getValue() === $new_value, 'Float value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'Float value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Float wrapper is null-able.');
@ -229,7 +229,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue('P40D');
$this->assertEqual($typed_data->getDuration()->d, 40, 'DurationIso8601 value was changed and set by duration string.');
$this->assertTrue(is_string($typed_data->getString()), 'DurationIso8601 value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'DurationIso8601 wrapper is null-able.');
@ -253,7 +253,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(60 * 60 * 4);
$this->assertEqual($typed_data->getDuration()->s, 14400, 'Time span was changed');
$this->assertTrue(is_string($typed_data->getString()), 'Time span value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Time span wrapper is null-able.');
@ -276,7 +276,7 @@ class TypedDataTest extends KernelTestBase {
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue($uri . 'bar.txt');
$this->assertTrue($typed_data->getValue() === $uri . 'bar.txt', 'URI value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'URI value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'URI wrapper is null-able.');
@ -304,7 +304,7 @@ class TypedDataTest extends KernelTestBase {
$new_value = 'test@example.com';
$typed_data->setValue($new_value);
$this->assertIdentical($typed_data->getValue(), $new_value, 'Email value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'Email value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Email wrapper is null-able.');
@ -320,12 +320,12 @@ class TypedDataTest extends KernelTestBase {
// Try setting by URI.
$typed_data->setValue($files[1]->getFileUri());
$this->assertEqual(fgets($typed_data->getValue()), fgets(fopen($files[1]->getFileUri(), 'r')), 'Binary value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'Binary value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
// Try setting by resource.
$typed_data->setValue(fopen($files[2]->getFileUri(), 'r'));
$this->assertEqual(fgets($typed_data->getValue()), fgets(fopen($files[2]->getFileUri(), 'r')), 'Binary value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'Binary value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Binary wrapper is null-able.');
@ -340,7 +340,7 @@ class TypedDataTest extends KernelTestBase {
$new_value = 'test@example.com';
$typed_data->setValue($new_value);
$this->assertIdentical($typed_data->getValue(), $new_value, 'Any value was changed.');
$this->assertTrue(is_string($typed_data->getString()), 'Any value was converted to string');
$this->assertIsString($typed_data->getString());
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(NULL);
$this->assertNull($typed_data->getValue(), 'Any wrapper is null-able.');