Commit afd86e7d authored by catch's avatar catch
Browse files

Issue #3193955 by mondrake, daffie, catch: Swap assertEqual arguments in...

Issue #3193955 by mondrake, daffie, catch: Swap assertEqual arguments in preparation to replace with assertEquals
parent 543caad0
......@@ -77,8 +77,8 @@ public function testFeedLanguage() {
$feeds[2] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[2]]);
// Make sure that the language has been assigned.
$this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]);
$this->assertEqual($feeds[2]->language()->getId(), $this->langcodes[2]);
$this->assertEqual($this->langcodes[1], $feeds[1]->language()->getId());
$this->assertEqual($this->langcodes[2], $feeds[2]->language()->getId());
// Create example nodes to create feed items from and then update the feeds.
$this->createSampleNodes();
......@@ -92,7 +92,7 @@ public function testFeedLanguage() {
// Verify that the feed items were created.
$this->assertNotEmpty($items);
foreach ($items as $item) {
$this->assertEqual($item->language()->getId(), $feed->language()->getId());
$this->assertEqual($feed->language()->getId(), $item->language()->getId());
}
}
}
......
......@@ -98,7 +98,7 @@ public function testRedirectFeed() {
$feed->refreshItems();
// Make sure that the feed URL was updated correctly.
$this->assertEqual($feed->getUrl(), Url::fromRoute('aggregator_test.feed', [], ['absolute' => TRUE])->toString());
$this->assertEqual(Url::fromRoute('aggregator_test.feed', [], ['absolute' => TRUE])->toString(), $feed->getUrl());
}
/**
......
......@@ -66,7 +66,7 @@ public function testPostProcess() {
// Reload the feed to get new values.
$feed = Feed::load($feed_id);
// Make sure its refresh rate doubled.
$this->assertEqual($feed->getRefreshRate(), 3600);
$this->assertEqual(3600, $feed->getRefreshRate());
}
}
......@@ -119,7 +119,7 @@ protected function submitImportForm() {
$this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]));
$after = $count_query->execute();
$this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
$this->assertEqual(2, $after, 'Verifying that two distinct feeds were added.');
$feed_entities = Feed::loadMultiple();
$refresh = TRUE;
......
......@@ -54,14 +54,10 @@ public function testValidation() {
$violations = $feed->validate();
$this->assertCount(2, $violations);
$this->assertEqual($violations[0]->getPropertyPath(), 'title');
$this->assertEqual($violations[0]->getMessage(), t('A feed named %value already exists. Enter a unique title.', [
'%value' => $feed->label(),
]));
$this->assertEqual($violations[1]->getPropertyPath(), 'url');
$this->assertEqual($violations[1]->getMessage(), t('A feed with this URL %value already exists. Enter a unique URL.', [
'%value' => $feed->getUrl(),
]));
$this->assertEqual('title', $violations[0]->getPropertyPath());
$this->assertEqual(t('A feed named %value already exists. Enter a unique title.', ['%value' => $feed->label()]), $violations[0]->getMessage());
$this->assertEqual('url', $violations[1]->getPropertyPath());
$this->assertEqual(t('A feed with this URL %value already exists. Enter a unique URL.', ['%value' => $feed->getUrl()]), $violations[1]->getMessage());
}
}
......@@ -123,19 +123,19 @@ public function testAggregatorItemView() {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
return $view->field['title']->advancedRender($row);
});
$this->assertEqual($output, $expected_link->getGeneratedLink(), 'Ensure the right link is generated');
$this->assertEqual($expected_link->getGeneratedLink(), $output, 'Ensure the right link is generated');
$expected_author = Xss::filter($items[$iid]->getAuthor(), _aggregator_allowed_tags());
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
return $view->field['author']->advancedRender($row);
});
$this->assertEqual($output, $expected_author, 'Ensure the author got filtered');
$this->assertEqual($expected_author, $output, 'Ensure the author got filtered');
$expected_description = Xss::filter($items[$iid]->getDescription(), _aggregator_allowed_tags());
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
return $view->field['description']->advancedRender($row);
});
$this->assertEqual($output, $expected_description, 'Ensure the author got filtered');
$this->assertEqual($expected_description, $output, 'Ensure the author got filtered');
}
}
......
......@@ -59,7 +59,7 @@ public function testSystemBrandingSettings() {
->save();
$this->drupalGet('');
$site_slogan_element = $this->xpath($site_slogan_xpath);
$this->assertEqual($site_slogan_element[0]->getText(), 'alert("Community carpentry");', 'The site slogan was XSS-filtered.');
$this->assertEqual('alert("Community carpentry");', $site_slogan_element[0]->getText(), 'The site slogan was XSS-filtered.');
// Turn just the logo off.
$this->config('block.block.site-branding')
......
......@@ -210,7 +210,7 @@ public function testBlock() {
// Check to see if the block was created by checking its configuration.
$instance = Block::load($block['id']);
$this->assertEqual($instance->label(), $block['settings[label]'], 'Stored block title found.');
$this->assertEqual($block['settings[label]'], $instance->label(), 'Stored block title found.');
// Check whether the block can be moved to all available regions.
foreach ($this->regions as $region) {
......@@ -444,7 +444,7 @@ public function testBlockCacheTags() {
'rendered',
];
sort($expected_cache_tags);
$this->assertEqual($cache_entry->tags, $expected_cache_tags);
$this->assertEqual($expected_cache_tags, $cache_entry->tags);
$expected_cache_tags = [
'block_view',
'config:block.block.powered',
......@@ -550,17 +550,12 @@ public function testBlockUserRoleDelete() {
$block->save();
$this->assertEqual($block->getVisibility()['user_role']['roles'], [
$role1->id() => $role1->id(),
$role2->id() => $role2->id(),
]);
$this->assertEqual([$role1->id() => $role1->id(), $role2->id() => $role2->id()], $block->getVisibility()['user_role']['roles']);
$role1->delete();
$block = Block::load($block->id());
$this->assertEqual($block->getVisibility()['user_role']['roles'], [
$role2->id() => $role2->id(),
]);
$this->assertEqual([$role2->id() => $role2->id()], $block->getVisibility()['user_role']['roles']);
}
}
......@@ -264,7 +264,7 @@ public function testBlockRendering() {
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertEqual($result[0]->getText(), 'Custom title');
$this->assertEqual('Custom title', $result[0]->getText());
// Don't override the title anymore.
$plugin = $block->getPlugin();
......@@ -273,7 +273,7 @@ public function testBlockRendering() {
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertEqual($result[0]->getText(), 'test_view_block');
$this->assertEqual('test_view_block', $result[0]->getText());
// Hide the title.
$block->getPlugin()->setConfigurationValue('label_display', FALSE);
......
......@@ -85,7 +85,7 @@ public function testBlockConfigSchema() {
$block->save();
$config = $this->config("block.block.$id");
$this->assertEqual($config->get('id'), $id);
$this->assertEqual($id, $config->get('id'));
$this->assertConfigSchema($this->typedConfig, $config->getName(), $config->get());
}
}
......
......@@ -116,7 +116,7 @@ protected function loadTests() {
// Verify several properties of the block.
$this->assertSame('content', $entity->getRegion());
$this->assertTrue($entity->status());
$this->assertEqual($entity->getTheme(), 'stark');
$this->assertEqual('stark', $entity->getTheme());
$this->assertNotEmpty($entity->uuid());
}
......@@ -152,7 +152,7 @@ public function testDefaultBlocks() {
$entities = $this->controller->loadMultiple();
$entity = reset($entities);
$this->assertEqual($entity->id(), 'test_block', 'The default test block was loaded.');
$this->assertEqual('test_block', $entity->id(), 'The default test block was loaded.');
}
}
......@@ -93,7 +93,7 @@ public function testBasicRendering() {
$expected[] = ' </div>';
$expected[] = '';
$expected_output = implode("\n", $expected);
$this->assertEqual($this->renderer->renderRoot($output), $expected_output);
$this->assertEqual($expected_output, $this->renderer->renderRoot($output));
// Reset the HTML IDs so that the next render is not affected.
Html::resetSeenIds();
......@@ -118,7 +118,7 @@ public function testBasicRendering() {
$expected[] = ' </div>';
$expected[] = '';
$expected_output = implode("\n", $expected);
$this->assertEqual($this->renderer->renderRoot($output), $expected_output);
$this->assertEqual($expected_output, $this->renderer->renderRoot($output));
}
/**
......
......@@ -51,7 +51,7 @@ public function testListing() {
// Test the contents of each th cell.
$expected_items = [t('Block description'), t('Operations')];
foreach ($elements as $key => $element) {
$this->assertEqual($element->getText(), $expected_items[$key]);
$this->assertEqual($expected_items[$key], $element->getText());
}
$label = 'Antelope';
......
......@@ -76,9 +76,7 @@ public function testRevisions() {
->getStorage('block_content')
->loadRevision($revision_id);
// Verify revision log is the same.
$this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], new FormattableMarkup('Correct log message found for revision @revision', [
'@revision' => $loaded->getRevisionId(),
]));
$this->assertEqual($logs[$delta], $loaded->getRevisionLogMessage(), new FormattableMarkup('Correct log message found for revision @revision', ['@revision' => $loaded->getRevisionId()]));
if ($delta > 0) {
$this->assertInstanceOf(UserInterface::class, $loaded->getRevisionUser());
$this->assertIsNumeric($loaded->getRevisionUserId());
......
......@@ -51,7 +51,7 @@ public function testImport() {
$block->save();
// Verify that block_submit did not wipe the provided id.
$this->assertEqual($block->id(), $test_id, 'Block imported using provide id');
$this->assertEqual($test_id, $block->id(), 'Block imported using provide id');
// Test the import saved.
$block_by_id = BlockContent::load($test_id);
......@@ -67,11 +67,11 @@ public function testImport() {
public function testDeterminingChanges() {
// Initial creation.
$block = $this->createBlockContent('test_changes');
$this->assertEqual($block->getChangedTime(), REQUEST_TIME, 'Creating a block sets default "changed" timestamp.');
$this->assertEqual(REQUEST_TIME, $block->getChangedTime(), 'Creating a block sets default "changed" timestamp.');
// Update the block without applying changes.
$block->save();
$this->assertEqual($block->label(), 'test_changes', 'No changes have been determined.');
$this->assertEqual('test_changes', $block->label(), 'No changes have been determined.');
// Apply changes.
$block->setInfo('updated');
......@@ -80,12 +80,12 @@ public function testDeterminingChanges() {
// The hook implementations block_content_test_block_content_presave() and
// block_content_test_block_content_update() determine changes and change
// the title as well as programmatically set the 'changed' timestamp.
$this->assertEqual($block->label(), 'updated_presave_update', 'Changes have been determined.');
$this->assertEqual($block->getChangedTime(), 979534800, 'Saving a custom block uses "changed" timestamp set in presave hook.');
$this->assertEqual('updated_presave_update', $block->label(), 'Changes have been determined.');
$this->assertEqual(979534800, $block->getChangedTime(), 'Saving a custom block uses "changed" timestamp set in presave hook.');
// Test the static block load cache to be cleared.
$block = BlockContent::load($block->id());
$this->assertEqual($block->label(), 'updated_presave', 'Static cache has been cleared.');
$this->assertEqual('updated_presave', $block->label(), 'Static cache has been cleared.');
}
/**
......@@ -101,7 +101,7 @@ public function testBlockContentSaveOnInsert() {
// block_content_test_block_content_insert() triggers a save on insert if the
// title equals 'new'.
$block = $this->createBlockContent('new');
$this->assertEqual($block->label(), 'BlockContent ' . $block->id(), 'Custom block saved on block insert.');
$this->assertEqual('BlockContent ' . $block->id(), $block->label(), 'Custom block saved on block insert.');
}
}
......@@ -37,11 +37,9 @@ public function testValidation() {
// Make sure we have 1 violation.
$this->assertCount(1, $violations);
// Make sure the violation is on the info property
$this->assertEqual($violations[0]->getPropertyPath(), 'info');
$this->assertEqual('info', $violations[0]->getPropertyPath());
// Make sure the message is correct.
$this->assertEqual($violations[0]->getMessage(), new FormattableMarkup('A custom block with block description %value already exists.', [
'%value' => $block->label(),
]));
$this->assertEqual(new FormattableMarkup('A custom block with block description %value already exists.', ['%value' => $block->label()]), $violations[0]->getMessage());
}
}
......@@ -106,7 +106,7 @@ protected function assertPageCounts($path, $counts, $message) {
$text = $this->getTextContent();
foreach ($counts as $langcode => $count) {
$this->assertEqual(substr_count($text, $this->blockContentInfos[$langcode]), $count, 'Translation ' . $langcode . ' has count ' . $count . ' with ' . $message);
$this->assertEqual($count, substr_count($text, $this->blockContentInfos[$langcode]), 'Translation ' . $langcode . ' has count ' . $count . ' with ' . $message);
}
}
......
......@@ -66,7 +66,7 @@ protected function assertIds(array $expected_ids = []) {
foreach ($result as $element) {
$ids[] = $element->getText();
}
$this->assertEqual($ids, $expected_ids);
$this->assertEqual($expected_ids, $ids);
}
}
......@@ -71,7 +71,7 @@ protected function createBlockContent(array $values = []) {
if ($block_content = BlockContent::create($values)) {
$status = $block_content->save();
}
$this->assertEqual($status, SAVED_NEW, new FormattableMarkup('Created block content %info.', ['%info' => $block_content->label()]));
$this->assertEqual(SAVED_NEW, $status, new FormattableMarkup('Created block content %info.', ['%info' => $block_content->label()]));
return $block_content;
}
......@@ -103,7 +103,7 @@ protected function createBlockContentType(array $values = []) {
$status = $bundle->save();
block_content_add_body_field($bundle->id());
$this->assertEqual($status, SAVED_NEW, new FormattableMarkup('Created block content type %bundle.', ['%bundle' => $bundle->id()]));
$this->assertEqual(SAVED_NEW, $status, new FormattableMarkup('Created block content type %bundle.', ['%bundle' => $bundle->id()]));
return $bundle;
}
......
......@@ -492,11 +492,11 @@ public function testBookOutline() {
$this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, 'Add to book outline');
$node = \Drupal::entityTypeManager()->getStorage('node')->load($empty_book->id());
// Test the book array.
$this->assertEqual($node->book['nid'], $empty_book->id());
$this->assertEqual($node->book['bid'], $empty_book->id());
$this->assertEqual($node->book['depth'], 1);
$this->assertEqual($node->book['p1'], $empty_book->id());
$this->assertEqual($node->book['pid'], '0');
$this->assertEqual($empty_book->id(), $node->book['nid']);
$this->assertEqual($empty_book->id(), $node->book['bid']);
$this->assertEqual(1, $node->book['depth']);
$this->assertEqual($empty_book->id(), $node->book['p1']);
$this->assertEqual('0', $node->book['pid']);
// Create new book.
$this->drupalLogin($this->bookAuthor);
......@@ -516,11 +516,11 @@ public function testBookOutline() {
$node = \Drupal::entityTypeManager()->getStorage('node')->load($node->id());
// Test the book array.
$this->assertEqual($node->book['nid'], $node->id());
$this->assertEqual($node->book['bid'], $node->id());
$this->assertEqual($node->book['depth'], 1);
$this->assertEqual($node->book['p1'], $node->id());
$this->assertEqual($node->book['pid'], '0');
$this->assertEqual($node->id(), $node->book['nid']);
$this->assertEqual($node->id(), $node->book['bid']);
$this->assertEqual(1, $node->book['depth']);
$this->assertEqual($node->id(), $node->book['p1']);
$this->assertEqual('0', $node->book['pid']);
// Test the form itself.
$this->drupalGet('node/' . $node->id() . '/edit');
......@@ -627,7 +627,7 @@ public function testAdminBookNodeListing() {
$this->assertText($this->book->label());
$elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a');
$this->assertEqual($elements[0]->getText(), 'View', 'View link is found from the list.');
$this->assertEqual('View', $elements[0]->getText(), 'View link is found from the list.');
$this->assertEquals(count($nodes), count($elements), 'All the book pages are displayed on the book outline page.');
// Unpublish a book in the hierarchy.
......@@ -673,7 +673,7 @@ public function testHookNodeLoadAccess() {
$this->drupalLogin($this->webUserWithoutNodeAccess);
$book_node = $node_storage->load($this->book->id());
$this->assertTrue(!empty($book_node->book));
$this->assertEqual($book_node->book['bid'], $this->book->id());
$this->assertEqual($this->book->id(), $book_node->book['bid']);
// Reset the internal cache to retrigger the hook_node_load() call.
$node_storage->resetCache();
......@@ -681,7 +681,7 @@ public function testHookNodeLoadAccess() {
$this->drupalLogin($this->webUser);
$book_node = $node_storage->load($this->book->id());
$this->assertTrue(!empty($book_node->book));
$this->assertEqual($book_node->book['bid'], $this->book->id());
$this->assertEqual($this->book->id(), $book_node->book['bid']);
}
/**
......
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