summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-02-09 11:14:54 +0000
committerNathaniel Catchpole2017-02-09 11:14:54 +0000
commit8dbd209ef36d37c40f113a727ff6f4ffc2f4cd2e (patch)
tree5cc9b79f55df6c2631fe923437ad449eb67557d8
parented9c8e096c696f9191d49142e3157003f910b9af (diff)
Issue #2313095 by claudiu.cristea, l0ke, umarzaffer, mrjmd, dawehner, alexpott, catch: Move node constants to NodeInterface
-rw-r--r--core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php3
-rw-r--r--core/modules/book/src/Plugin/Block/BookNavigationBlock.php3
-rw-r--r--core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php9
-rw-r--r--core/modules/forum/src/Tests/Views/ForumIntegrationTest.php9
-rw-r--r--core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php3
-rw-r--r--core/modules/locale/src/Tests/LocaleContentTest.php3
-rw-r--r--core/modules/menu_ui/src/Tests/MenuTest.php3
-rw-r--r--core/modules/node/node.module24
-rw-r--r--core/modules/node/src/Entity/Node.php4
-rw-r--r--core/modules/node/src/NodeInterface.php30
-rw-r--r--core/modules/node/src/Plugin/Action/PublishNode.php3
-rw-r--r--core/modules/node/src/Plugin/Action/StickyNode.php3
-rw-r--r--core/modules/node/src/Plugin/Action/UnpublishNode.php3
-rw-r--r--core/modules/node/src/Plugin/Action/UnstickyNode.php3
-rw-r--r--core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php3
-rw-r--r--core/modules/node/src/Tests/NodeLinksTest.php4
-rw-r--r--core/modules/node/src/Tests/Views/StatusExtraTest.php8
-rw-r--r--core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php3
-rw-r--r--core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php5
-rw-r--r--core/modules/rdf/src/Tests/StandardProfileTest.php4
-rw-r--r--core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php3
-rw-r--r--core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php7
-rw-r--r--core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php3
-rw-r--r--core/modules/views/src/Tests/SearchMultilingualTest.php3
-rw-r--r--core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php7
25 files changed, 106 insertions, 47 deletions
diff --git a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
index 7159083..114bf23 100644
--- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
+++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php
@@ -6,6 +6,7 @@ use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Session\AccountInterface;
+use Drupal\node\NodeInterface;
/**
* Provides a couple of menu link tree manipulators.
@@ -147,7 +148,7 @@ class DefaultMenuLinkTreeManipulators {
}
else {
$access_result->addCacheContexts(['user.node_grants:view']);
- $query->condition('status', NODE_PUBLISHED);
+ $query->condition('status', NodeInterface::PUBLISHED);
}
$nids = $query->execute();
diff --git a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
index 6967077..a7b0f1e 100644
--- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
+++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
@@ -7,6 +7,7 @@ use Drupal\book\BookManagerInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\Entity\EntityStorageInterface;
@@ -160,7 +161,7 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
// not show unpublished books.
$nid = \Drupal::entityQuery('node')
->condition('nid', $node->book['bid'], '=')
- ->condition('status', NODE_PUBLISHED)
+ ->condition('status', NodeInterface::PUBLISHED)
->execute();
// Only show the block if the user has view access for the top-level node.
diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
index e00848c..90d4d1f 100644
--- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
+++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php
@@ -15,6 +15,7 @@ use Drupal\entity_test\Entity\EntityTestStringId;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
+use Drupal\node\NodeInterface;
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
use Drupal\file\Entity\File;
use Drupal\node\Entity\Node;
@@ -385,7 +386,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$node = Node::create([
'title' => $title,
'type' => 'node',
- 'status' => NODE_NOT_PUBLISHED,
+ 'status' => NodeInterface::NOT_PUBLISHED,
]);
$entity = EntityTest::create([
@@ -409,14 +410,14 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$unsaved_unpublished_node = Node::create([
'title' => $unsaved_unpublished_node_title,
'type' => 'node',
- 'status' => NODE_NOT_PUBLISHED,
+ 'status' => NodeInterface::NOT_PUBLISHED,
]);
$saved_unpublished_node_title = $this->randomString();
$saved_unpublished_node = Node::create([
'title' => $saved_unpublished_node_title,
'type' => 'node',
- 'status' => NODE_NOT_PUBLISHED,
+ 'status' => NodeInterface::NOT_PUBLISHED,
]);
$saved_unpublished_node->save();
@@ -424,7 +425,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$saved_published_node = Node::create([
'title' => $saved_published_node_title,
'type' => 'node',
- 'status' => NODE_PUBLISHED,
+ 'status' => NodeInterface::PUBLISHED,
]);
$saved_published_node->save();
diff --git a/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php b/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php
index 5502574..99ed945 100644
--- a/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php
+++ b/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php
@@ -2,6 +2,7 @@
namespace Drupal\forum\Tests\Views;
+use Drupal\node\NodeInterface;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
@@ -48,7 +49,7 @@ class ForumIntegrationTest extends ViewTestBase {
// Create some nodes which are part of this forum with some comments.
$nodes = array();
for ($i = 0; $i < 3; $i++) {
- $node = $this->drupalCreateNode(array('type' => 'forum', 'taxonomy_forums' => array($term->id()), 'sticky' => $i == 0 ? NODE_STICKY : NODE_NOT_STICKY));
+ $node = $this->drupalCreateNode(['type' => 'forum', 'taxonomy_forums' => [$term->id()], 'sticky' => $i == 0 ? NodeInterface::STICKY : NodeInterface::NOT_STICKY]);
$nodes[] = $node;
}
@@ -70,17 +71,17 @@ class ForumIntegrationTest extends ViewTestBase {
$expected_result = array();
$expected_result[] = array(
'nid' => $nodes[0]->id(),
- 'sticky' => NODE_STICKY,
+ 'sticky' => NodeInterface::STICKY,
'comment_count' => 1.
);
$expected_result[] = array(
'nid' => $nodes[1]->id(),
- 'sticky' => NODE_NOT_STICKY,
+ 'sticky' => NodeInterface::NOT_STICKY,
'comment_count' => 2.
);
$expected_result[] = array(
'nid' => $nodes[2]->id(),
- 'sticky' => NODE_NOT_STICKY,
+ 'sticky' => NodeInterface::NOT_STICKY,
'comment_count' => 3.
);
$column_map = array(
diff --git a/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php b/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php
index 35e038f..74f5104 100644
--- a/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php
+++ b/core/modules/hal/tests/src/Kernel/EntityTranslationNormalizeTest.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\hal\Kernel;
use Drupal\node\Entity\Node;
+use Drupal\node\NodeInterface;
use Drupal\user\Entity\User;
use Drupal\node\Entity\NodeType;
@@ -44,7 +45,7 @@ class EntityTranslationNormalizeTest extends NormalizerTestBase {
'title' => $this->randomMachineName(),
'uid' => $user->id(),
'type' => $node_type->id(),
- 'status' => NODE_PUBLISHED,
+ 'status' => NodeInterface::PUBLISHED,
'langcode' => 'en',
'promote' => 1,
'sticky' => 0,
diff --git a/core/modules/locale/src/Tests/LocaleContentTest.php b/core/modules/locale/src/Tests/LocaleContentTest.php
index 188b574..756b47b 100644
--- a/core/modules/locale/src/Tests/LocaleContentTest.php
+++ b/core/modules/locale/src/Tests/LocaleContentTest.php
@@ -4,6 +4,7 @@ namespace Drupal\locale\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\node\NodeInterface;
/**
* Tests you can enable multilingual support on content types and configure a
@@ -170,7 +171,7 @@ class LocaleContentTest extends WebTestBase {
$nodes[$langcode] = $this->drupalCreateNode(array(
'langcode' => $langcode,
'type' => $type->id(),
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
));
}
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index e9464ab..9c4e1ce 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -10,6 +10,7 @@ use Drupal\Core\Url;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\system\Entity\Menu;
use Drupal\node\Entity\Node;
+use Drupal\node\NodeInterface;
/**
* Add a custom menu, add menu links to the custom menu and Tools menu, check
@@ -542,7 +543,7 @@ class MenuTest extends MenuWebTestBase {
// Create an unpublished node.
$node = $this->drupalCreateNode(array(
'type' => 'article',
- 'status' => NODE_NOT_PUBLISHED,
+ 'status' => NodeInterface::NOT_PUBLISHED,
));
$item = $this->addMenuLink('', '/node/' . $node->id());
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index d3a83e0..7d7247b 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -31,31 +31,49 @@ use Drupal\node\NodeTypeInterface;
/**
* Denotes that the node is not published.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.x.
+ * Use \Drupal\node\NodeInterface::NOT_PUBLISHED instead.
*/
const NODE_NOT_PUBLISHED = 0;
/**
* Denotes that the node is published.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.x.
+ * Use \Drupal\node\NodeInterface::PUBLISHED instead.
*/
const NODE_PUBLISHED = 1;
/**
* Denotes that the node is not promoted to the front page.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.x.
+ * Use \Drupal\node\NodeInterface::NOT_PROMOTED instead.
*/
const NODE_NOT_PROMOTED = 0;
/**
* Denotes that the node is promoted to the front page.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.x.
+ * Use \Drupal\node\NodeInterface::PROMOTED instead.
*/
const NODE_PROMOTED = 1;
/**
* Denotes that the node is not sticky at the top of the page.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.x.
+ * Use \Drupal\node\NodeInterface::NOT_STICKY instead.
*/
const NODE_NOT_STICKY = 0;
/**
* Denotes that the node is sticky at the top of the page.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.x.
+ * Use \Drupal\node\NodeInterface::STICKY instead.
*/
const NODE_STICKY = 1;
@@ -742,15 +760,15 @@ function node_get_recent($number = 10) {
// have some unpublished nodes to view before adding the condition.
$access_query = \Drupal::entityQuery('node')
->condition('uid', $account->id())
- ->condition('status', NODE_NOT_PUBLISHED);
+ ->condition('status', NodeInterface::NOT_PUBLISHED);
if ($account->hasPermission('view own unpublished content') && ($own_unpublished = $access_query->execute())) {
$query->orConditionGroup()
- ->condition('status', NODE_PUBLISHED)
+ ->condition('status', NodeInterface::PUBLISHED)
->condition('nid', $own_unpublished, 'IN');
}
else {
// If not, restrict the query to published nodes.
- $query->condition('status', NODE_PUBLISHED);
+ $query->condition('status', NodeInterface::PUBLISHED);
}
}
$nids = $query
diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php
index bb0e36a..0edb58f 100644
--- a/core/modules/node/src/Entity/Node.php
+++ b/core/modules/node/src/Entity/Node.php
@@ -229,7 +229,7 @@ class Node extends ContentEntityBase implements NodeInterface {
* {@inheritdoc}
*/
public function setPromoted($promoted) {
- $this->set('promote', $promoted ? NODE_PROMOTED : NODE_NOT_PROMOTED);
+ $this->set('promote', $promoted ? NodeInterface::PROMOTED : NodeInterface::NOT_PROMOTED);
return $this;
}
@@ -244,7 +244,7 @@ class Node extends ContentEntityBase implements NodeInterface {
* {@inheritdoc}
*/
public function setSticky($sticky) {
- $this->set('sticky', $sticky ? NODE_STICKY : NODE_NOT_STICKY);
+ $this->set('sticky', $sticky ? NodeInterface::STICKY : NodeInterface::NOT_STICKY);
return $this;
}
diff --git a/core/modules/node/src/NodeInterface.php b/core/modules/node/src/NodeInterface.php
index f3bcaea..87b6892 100644
--- a/core/modules/node/src/NodeInterface.php
+++ b/core/modules/node/src/NodeInterface.php
@@ -14,6 +14,36 @@ use Drupal\Core\Entity\ContentEntityInterface;
interface NodeInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface, RevisionLogInterface, EntityPublishedInterface {
/**
+ * Denotes that the node is not published.
+ */
+ const NOT_PUBLISHED = 0;
+
+ /**
+ * Denotes that the node is published.
+ */
+ const PUBLISHED = 1;
+
+ /**
+ * Denotes that the node is not promoted to the front page.
+ */
+ const NOT_PROMOTED = 0;
+
+ /**
+ * Denotes that the node is promoted to the front page.
+ */
+ const PROMOTED = 1;
+
+ /**
+ * Denotes that the node is not sticky at the top of the page.
+ */
+ const NOT_STICKY = 0;
+
+ /**
+ * Denotes that the node is sticky at the top of the page.
+ */
+ const STICKY = 1;
+
+ /**
* Gets the node type.
*
* @return string
diff --git a/core/modules/node/src/Plugin/Action/PublishNode.php b/core/modules/node/src/Plugin/Action/PublishNode.php
index 83a4354..c8d3b5b 100644
--- a/core/modules/node/src/Plugin/Action/PublishNode.php
+++ b/core/modules/node/src/Plugin/Action/PublishNode.php
@@ -20,8 +20,7 @@ class PublishNode extends ActionBase {
* {@inheritdoc}
*/
public function execute($entity = NULL) {
- $entity->status = NODE_PUBLISHED;
- $entity->save();
+ $entity->setPublished()->save();
}
/**
diff --git a/core/modules/node/src/Plugin/Action/StickyNode.php b/core/modules/node/src/Plugin/Action/StickyNode.php
index 4068514..7aff92b 100644
--- a/core/modules/node/src/Plugin/Action/StickyNode.php
+++ b/core/modules/node/src/Plugin/Action/StickyNode.php
@@ -20,8 +20,7 @@ class StickyNode extends ActionBase {
* {@inheritdoc}
*/
public function execute($entity = NULL) {
- $entity->sticky = NODE_STICKY;
- $entity->save();
+ $entity->setSticky(TRUE)->save();
}
/**
diff --git a/core/modules/node/src/Plugin/Action/UnpublishNode.php b/core/modules/node/src/Plugin/Action/UnpublishNode.php
index 403a55e..ec6209d 100644
--- a/core/modules/node/src/Plugin/Action/UnpublishNode.php
+++ b/core/modules/node/src/Plugin/Action/UnpublishNode.php
@@ -20,8 +20,7 @@ class UnpublishNode extends ActionBase {
* {@inheritdoc}
*/
public function execute($entity = NULL) {
- $entity->status = NODE_NOT_PUBLISHED;
- $entity->save();
+ $entity->setUnpublished()->save();
}
/**
diff --git a/core/modules/node/src/Plugin/Action/UnstickyNode.php b/core/modules/node/src/Plugin/Action/UnstickyNode.php
index 6c3e947..92ccfe2 100644
--- a/core/modules/node/src/Plugin/Action/UnstickyNode.php
+++ b/core/modules/node/src/Plugin/Action/UnstickyNode.php
@@ -20,8 +20,7 @@ class UnstickyNode extends ActionBase {
* {@inheritdoc}
*/
public function execute($entity = NULL) {
- $entity->sticky = NODE_NOT_STICKY;
- $entity->save();
+ $entity->setSticky(FALSE)->save();
}
/**
diff --git a/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php b/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php
index 7943624..906f15f 100644
--- a/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php
+++ b/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php
@@ -4,6 +4,7 @@ namespace Drupal\node\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\node\NodeInterface;
/**
* Provides specific access control for the node entity type.
@@ -38,7 +39,7 @@ class NodeSelection extends DefaultSelection {
// modules in use on the site. As long as one access control module is there,
// it is supposed to handle this check.
if (!$this->currentUser->hasPermission('bypass node access') && !count($this->moduleHandler->getImplementations('node_grants'))) {
- $query->condition('status', NODE_PUBLISHED);
+ $query->condition('status', NodeInterface::PUBLISHED);
}
return $query;
}
diff --git a/core/modules/node/src/Tests/NodeLinksTest.php b/core/modules/node/src/Tests/NodeLinksTest.php
index 72990c0..f3694e4 100644
--- a/core/modules/node/src/Tests/NodeLinksTest.php
+++ b/core/modules/node/src/Tests/NodeLinksTest.php
@@ -2,6 +2,8 @@
namespace Drupal\node\Tests;
+use Drupal\node\NodeInterface;
+
/**
* Tests the output of node links (read more, add new comment, etc).
*
@@ -22,7 +24,7 @@ class NodeLinksTest extends NodeTestBase {
public function testHideLinks() {
$node = $this->drupalCreateNode(array(
'type' => 'article',
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
));
// Links are displayed by default.
diff --git a/core/modules/node/src/Tests/Views/StatusExtraTest.php b/core/modules/node/src/Tests/Views/StatusExtraTest.php
index 6d8b7ee..d8ae016 100644
--- a/core/modules/node/src/Tests/Views/StatusExtraTest.php
+++ b/core/modules/node/src/Tests/Views/StatusExtraTest.php
@@ -2,6 +2,8 @@
namespace Drupal\node\Tests\Views;
+use Drupal\node\NodeInterface;
+
/**
* Tests the node.status_extra field handler.
*
@@ -28,14 +30,14 @@ class StatusExtraTest extends NodeTestBase {
// Create one published and one unpublished node by the admin.
$node_published = $this->drupalCreateNode(array('uid' => $admin_user->id()));
- $node_unpublished = $this->drupalCreateNode(array('uid' => $admin_user->id(), 'status' => NODE_NOT_PUBLISHED));
+ $node_unpublished = $this->drupalCreateNode(['uid' => $admin_user->id(), 'status' => NodeInterface::NOT_PUBLISHED]);
// Create one unpublished node by a certain author user.
- $node_unpublished2 = $this->drupalCreateNode(array('uid' => $node_author->id(), 'status' => NODE_NOT_PUBLISHED));
+ $node_unpublished2 = $this->drupalCreateNode(['uid' => $node_author->id(), 'status' => NodeInterface::NOT_PUBLISHED]);
// Create one unpublished node by a user who does not have the `view own
// unpublished content` permission.
- $node_unpublished3 = $this->drupalCreateNode(array('uid' => $node_author_not_unpublished->id(), 'status' => NODE_NOT_PUBLISHED));
+ $node_unpublished3 = $this->drupalCreateNode(['uid' => $node_author_not_unpublished->id(), 'status' => NodeInterface::NOT_PUBLISHED]);
// The administrator should simply see all nodes.
$this->drupalLogin($admin_user);
diff --git a/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php b/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php
index 19eaf8f..4bc05c4 100644
--- a/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php
+++ b/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php
@@ -5,6 +5,7 @@ namespace Drupal\node_access_test_auto_bubbling\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\Query\QueryFactory;
+use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -46,7 +47,7 @@ class NodeAccessTestAutoBubblingController extends ControllerBase implements Con
*/
public function latest() {
$nids = $this->entityQuery->get('node')
- ->condition('status', NODE_PUBLISHED)
+ ->condition('status', NodeInterface::PUBLISHED)
->sort('created', 'DESC')
->range(0, 3)
->execute();
diff --git a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
index c8db96e..f9fd3de 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
@@ -6,6 +6,7 @@ use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Language\LanguageInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
+use Drupal\node\NodeInterface;
/**
* Enables the page cache and tests its cache tags in various scenarios.
@@ -44,7 +45,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
'body' => array(
0 => array('value' => 'Body 1', 'format' => 'basic_html'),
),
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
));
$author_2 = $this->drupalCreateUser();
$node_2 = $this->drupalCreateNode(array(
@@ -53,7 +54,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
'body' => array(
0 => array('value' => 'Body 2', 'format' => 'full_html'),
),
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
));
// Place a block, but only make it visible on full node page 2.
diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php
index d8aa1b1..0dcefc5 100644
--- a/core/modules/rdf/src/Tests/StandardProfileTest.php
+++ b/core/modules/rdf/src/Tests/StandardProfileTest.php
@@ -143,7 +143,7 @@ class StandardProfileTest extends WebTestBase {
// Create article.
$article_settings = array(
'type' => 'article',
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
'field_image' => array(
array(
'target_id' => $this->image->id(),
@@ -157,7 +157,7 @@ class StandardProfileTest extends WebTestBase {
);
$this->article = $this->drupalCreateNode($article_settings);
// Create second article to test teaser list.
- $this->drupalCreateNode(array('type' => 'article', 'promote' => NODE_PROMOTED,));
+ $this->drupalCreateNode(['type' => 'article', 'promote' => NodeInterface::PROMOTED]);
// Create article comment.
$this->articleComment = $this->saveComment($this->article->id(), $this->webUser->id(), NULL, 0);
diff --git a/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php b/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
index 0e1e298..9c9f070 100644
--- a/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
+++ b/core/modules/system/src/Tests/Common/NoJavaScriptAnonymousTest.php
@@ -3,6 +3,7 @@
namespace Drupal\system\Tests\Common;
use Drupal\simpletest\WebTestBase;
+use Drupal\node\NodeInterface;
/**
* Tests that anonymous users are not served any JavaScript in the Standard
@@ -27,7 +28,7 @@ class NoJavaScriptAnonymousTest extends WebTestBase {
public function testNoJavaScript() {
// Create a node that is listed on the frontpage.
$this->drupalCreateNode(array(
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
));
$user = $this->drupalCreateUser();
diff --git a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
index 86bc703..36f71aa 100644
--- a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
@@ -7,6 +7,7 @@ use Drupal\Component\Utility\Html;
use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface;
use Drupal\node\Entity\Node;
+use Drupal\node\NodeInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\user\Entity\User;
use Drupal\comment\Entity\Comment;
@@ -83,19 +84,19 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
$node_values = array(
'published1' => array(
'type' => 'article',
- 'status' => NODE_PUBLISHED,
+ 'status' => NodeInterface::PUBLISHED,
'title' => 'Node published1 (<&>)',
'uid' => 1,
),
'published2' => array(
'type' => 'article',
- 'status' => NODE_PUBLISHED,
+ 'status' => NodeInterface::PUBLISHED,
'title' => 'Node published2 (<&>)',
'uid' => 1,
),
'unpublished' => array(
'type' => 'article',
- 'status' => NODE_NOT_PUBLISHED,
+ 'status' => NodeInterface::NOT_PUBLISHED,
'title' => 'Node unpublished (<&>)',
'uid' => 1,
),
diff --git a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
index cc4af2a..2e55df8 100644
--- a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php
@@ -6,6 +6,7 @@ use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\node\NodeInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
use Drupal\taxonomy\Entity\Term;
@@ -102,7 +103,7 @@ class EntityFilteringThemeTest extends WebTestBase {
$this->node = $this->drupalCreateNode(array(
'title' => $this->xssLabel,
'type' => 'article',
- 'promote' => NODE_PROMOTED,
+ 'promote' => NodeInterface::PROMOTED,
'field_tags' => array(array('target_id' => $this->term->id())),
));
diff --git a/core/modules/views/src/Tests/SearchMultilingualTest.php b/core/modules/views/src/Tests/SearchMultilingualTest.php
index 5f583f0..3fdb8db 100644
--- a/core/modules/views/src/Tests/SearchMultilingualTest.php
+++ b/core/modules/views/src/Tests/SearchMultilingualTest.php
@@ -3,6 +3,7 @@
namespace Drupal\views\Tests;
use Drupal\language\Entity\ConfigurableLanguage;
+use Drupal\node\NodeInterface;
/**
* Tests search integration filters with multilingual nodes.
@@ -60,7 +61,7 @@ class SearchMultilingualTest extends ViewTestBase {
$node = $this->drupalCreateNode($values);
// "Translate" this node into Spanish, with title "pizza".
- $node->addTranslation('es', array('title' => 'pizza', 'status' => NODE_PUBLISHED));
+ $node->addTranslation('es', ['title' => 'pizza', 'status' => NodeInterface::PUBLISHED]);
$node->save();
// Run cron so that the search index tables are updated.
diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
index 2000fe6..90b189d 100644
--- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
@@ -8,6 +8,7 @@ use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Menu\DefaultMenuLinkTreeManipulators;
use Drupal\Core\Menu\MenuLinkTreeElement;
use Drupal\Tests\UnitTestCase;
+use Drupal\node\NodeInterface;
/**
* Tests the default menu link tree manipulators.
@@ -295,7 +296,7 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
->with('nid', array(1, 2, 3, 4));
$query->expects($this->at(1))
->method('condition')
- ->with('status', NODE_PUBLISHED);
+ ->with('status', NodeInterface::PUBLISHED);
$query->expects($this->once())
->method('execute')
->willReturn(array(1, 2, 4));
@@ -338,7 +339,3 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase {
}
}
-
-if (!defined('NODE_PUBLISHED')) {
- define('NODE_PUBLISHED', 1);
-}