Unverified Commit 84d5e361 authored by alexpott's avatar alexpott
Browse files

Issue #2969549 by marcel66, martin107: Fix "The $published parameter is...

Issue #2969549 by marcel66, martin107: Fix "The $published parameter is deprecated since version 8.3.x and will be removed in 9.0.0." deprecation
parent 21d49303
......@@ -36,7 +36,7 @@ public function testViewShowsCorrectStates() {
$page = $this->getSession()->getPage();
$this->assertTrue($page->has('css', '.block-block-content' . $block_content->uuid()));
$block_content->setPublished(FALSE);
$block_content->setUnpublished();
$block_content->save();
$this->drupalGet('<front>');
......
......@@ -523,7 +523,7 @@ function comment_user_cancel($edit, $account, $method) {
case 'user_cancel_block_unpublish':
$comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) {
$comment->setPublished(CommentInterface::NOT_PUBLISHED);
$comment->setUnpublished();
$comment->save();
}
break;
......
......@@ -82,7 +82,7 @@ public static function create(ContainerInterface $container) {
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function commentApprove(CommentInterface $comment) {
$comment->setPublished(TRUE);
$comment->setPublished();
$comment->save();
$this->messenger()->addStatus($this->t('Comment approved.'));
......
......@@ -78,7 +78,7 @@ public function execute($comment = NULL) {
$text = $this->renderer->renderPlain($build);
foreach ($this->configuration['keywords'] as $keyword) {
if (strpos($text, $keyword) !== FALSE) {
$comment->setPublished(FALSE);
$comment->setUnpublished();
$comment->save();
break;
}
......
......@@ -42,7 +42,7 @@ public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
// In order to create a referenceable comment, it needs to published.
/** @var \Drupal\comment\CommentInterface $comment */
$comment->setPublished(TRUE);
$comment->setPublished();
return $comment;
}
......
......@@ -78,7 +78,7 @@ public function testCannotCommentOnEntitiesYouCannotView() {
$assert->statusCodeEquals(403);
// Publishing the node grants access.
$this->unpublishedNode->setPublished(TRUE)->save();
$this->unpublishedNode->setPublished()->save();
$this->drupalGet($comment_url);
$assert->statusCodeEquals(200);
}
......@@ -112,7 +112,7 @@ public function testCannotViewCommentReplyFormOnEntitiesYouCannotView() {
$assert->statusCodeEquals(403);
// Publishing the node grants access.
$this->unpublishedNode->setPublished(TRUE)->save();
$this->unpublishedNode->setPublished()->save();
$this->drupalGet($comment_url);
$assert->statusCodeEquals(200);
}
......
......@@ -166,7 +166,7 @@ public function testCommentInterface() {
$this->setCommentsPerPage(50);
// Attempt to reply to an unpublished comment.
$reply_loaded->setPublished(FALSE);
$reply_loaded->setUnpublished();
$reply_loaded->save();
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $reply_loaded->id());
$this->assertResponse(403);
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\comment\Kernel\Views;
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Url;
......@@ -84,7 +83,7 @@ public function testLinkApprove() {
$this->assertEqual(\Drupal::l('Approve', $url), (string) $approve_comment, 'Found a comment approve link for an unapproved comment.');
// Approve the comment.
$comment->setPublished(CommentInterface::PUBLISHED);
$comment->setPublished();
$comment->save();
$view = Views::getView('test_comment');
$view->preview();
......@@ -97,7 +96,7 @@ public function testLinkApprove() {
// anonymous user.
$account_switcher->switchTo(new AnonymousUserSession());
// Set the comment as unpublished again.
$comment->setPublished(CommentInterface::NOT_PUBLISHED);
$comment->setUnpublished();
$comment->save();
$view = Views::getView('test_comment');
......@@ -168,7 +167,7 @@ public function testLinkReply() {
$this->assertFalse((string) $replyto_comment, "I can't reply to an unapproved comment.");
// Approve the comment.
$comment->setPublished(CommentInterface::PUBLISHED);
$comment->setPublished();
$comment->save();
$view = Views::getView('test_comment');
$view->preview();
......
......@@ -98,14 +98,14 @@ public function testOperationTranslateLink() {
'access content' => TRUE,
]
);
$node->setPublished(FALSE)->save();
$node->setUnpublished()->save();
$this->drupalGet($node->urlInfo('drupal:content-translation-overview'));
$this->assertResponse(403);
$this->drupalLogout();
// Ensure the 'Translate' local task does not show up anymore when disabling
// translations for a content type.
$node->setPublished(TRUE)->save();
$node->setPublished()->save();
user_role_change_permissions(
Role::AUTHENTICATED_ID,
[
......@@ -136,7 +136,7 @@ public function testContentTranslationOverviewAccess() {
$this->assertFalse(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache();
$node->setPublished(TRUE);
$node->setPublished();
$node->save();
$this->assertTrue(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache();
......
......@@ -112,7 +112,7 @@ public function testEditorPrivateFileReferenceFilter() {
// When the published node is also unpublished, the image should also
// become inaccessible to anonymous users.
$published_node->setPublished(FALSE)->save();
$published_node->setUnpublished()->save();
$this->drupalGet($published_node->toUrl());
$this->assertSession()->statusCodeEquals(403);
......@@ -121,7 +121,7 @@ public function testEditorPrivateFileReferenceFilter() {
// Disallow anonymous users to view the entity, which then should also
// disallow them to view the image.
$published_node->setPublished(TRUE)->save();
$published_node->setPublished()->save();
Role::load(RoleInterface::ANONYMOUS_ID)
->revokePermission('access content')
->save();
......
......@@ -428,7 +428,7 @@ public function testAutocreateValidation() {
$this->assertEqual($errors[0]->getPropertyPath(), 'field_test_node.0.entity');
// Publish the node and try again.
$node->setPublished(TRUE);
$node->setPublished();
$errors = $entity->validate();
$this->assertEqual(0, count($errors));
......@@ -478,7 +478,7 @@ public function testAutocreateValidation() {
$this->assertEqual($errors[1]->getPropertyPath(), 'field_test_node.1.target_id');
// Publish one of the nodes and try again.
$saved_unpublished_node->setPublished(TRUE);
$saved_unpublished_node->setPublished();
$saved_unpublished_node->save();
$errors = $entity->validate();
$this->assertEqual(1, count($errors));
......@@ -486,7 +486,7 @@ public function testAutocreateValidation() {
$this->assertEqual($errors[0]->getPropertyPath(), 'field_test_node.0.entity');
// Publish the last invalid node and try again.
$unsaved_unpublished_node->setPublished(TRUE);
$unsaved_unpublished_node->setPublished();
$errors = $entity->validate();
$this->assertEqual(0, count($errors));
......@@ -510,7 +510,7 @@ public function testAutocreateValidation() {
$this->assertEqual($errors[0]->getPropertyPath(), 'field_test_comment.0.entity');
// Publish the comment and try again.
$comment->setPublished(TRUE);
$comment->setPublished();
$errors = $entity->validate();
$this->assertEqual(0, count($errors));
......
......@@ -214,7 +214,7 @@ public function testPrivateFile() {
$edit['files[' . $field_name . '_0]'] = $file_system->realpath($test_file->getFileUri());
$this->drupalPostForm(NULL, $edit, t('Save'));
$new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$new_node->setPublished(FALSE);
$new_node->setUnpublished();
$new_node->save();
$file = File::load($new_node->{$field_name}->target_id);
$this->assertTrue($file->isPermanent(), 'File is permanent.');
......
......@@ -217,7 +217,7 @@ public function form(array $form, FormStateInterface $form_state) {
public function updateStatus($entity_type_id, NodeInterface $node, array $form, FormStateInterface $form_state) {
$element = $form_state->getTriggeringElement();
if (isset($element['#published_status'])) {
$node->setPublished($element['#published_status']);
$element['#published_status'] ? $node->setPublished() : $node->setUnpublished();
}
}
......
......@@ -25,7 +25,7 @@ public function execute($node = NULL) {
foreach ($this->configuration['keywords'] as $keyword) {
$elements = node_view(clone $node);
if (strpos(\Drupal::service('renderer')->render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) {
$node->setPublished(FALSE);
$node->setUnpublished();
$node->save();
break;
}
......
......@@ -42,7 +42,7 @@ public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
// In order to create a referenceable node, it needs to published.
/** @var \Drupal\node\NodeInterface $node */
$node->setPublished(TRUE);
$node->setPublished();
return $node;
}
......
......@@ -32,7 +32,7 @@ protected function createEntity() {
// Create a "Llama" node.
$node = Node::create(['type' => 'camelids']);
$node->setTitle('Llama')
->setPublished(TRUE)
->setPublished()
->save();
return $node;
......
......@@ -284,7 +284,7 @@ public function testTranslationRendering() {
$translation = $node->addTranslation($langcode, $values[$langcode]);
// Publish and promote the translation to frontpage.
$translation->setPromoted(TRUE);
$translation->setPublished(TRUE);
$translation->setPublished();
}
$node->save();
......
......@@ -67,7 +67,7 @@ protected function createEntity() {
'format' => 'plain_text',
],
])
->setPublished(FALSE);
->setUnpublished();
$block_content->save();
return $block_content;
}
......
......@@ -107,7 +107,7 @@ protected function createEntity() {
]);
$comment->setSubject('Llama')
->setOwnerId(static::$auth ? $this->account->id() : 0)
->setPublished(TRUE)
->setPublished()
->setCreatedTime(123456789)
->setChangedTime(123456789);
$comment->save();
......
......@@ -106,7 +106,7 @@ protected function createEntity() {
]);
$media
->setName('Llama')
->setPublished(TRUE)
->setPublished()
->setCreatedTime(123456789)
->setOwnerId(static::$auth ? $this->account->id() : 0)
->setRevisionUserId(static::$auth ? $this->account->id() : 0)
......
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