diff core/modules/taxonomy/tests/src/Kernel/TaxonomyLegacyTest.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/taxonomy/tests/src/Kernel/TaxonomyLegacyTest.php	Thu May 09 15:33:08 2019 +0100
@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\Tests\taxonomy\Kernel;
+
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\taxonomy\TermInterface;
+use Drupal\taxonomy\VocabularyInterface;
+use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait;
+
+/**
+ * Tests legacy user functionality.
+ *
+ * @group user
+ * @group legacy
+ */
+class TaxonomyLegacyTest extends KernelTestBase {
+  use TaxonomyTestTrait;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['filter', 'taxonomy', 'text', 'user'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(['filter']);
+    $this->installEntitySchema('taxonomy_term');
+  }
+
+  /**
+   * @expectedDeprecation taxonomy_term_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\taxonomy\Entity\Term::loadMultiple(). See https://www.drupal.org/node/2266845
+   * @expectedDeprecation taxonomy_vocabulary_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\taxonomy\Entity\Vocabulary::loadMultiple(). See https://www.drupal.org/node/2266845
+   * @expectedDeprecation taxonomy_term_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\taxonomy\Entity\Term::load(). See https://www.drupal.org/node/2266845
+   * @expectedDeprecation taxonomy_vocabulary_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\taxonomy\Entity\Vocabulary::load(). See https://www.drupal.org/node/2266845
+   */
+  public function testEntityLegacyCode() {
+    $this->assertCount(0, taxonomy_term_load_multiple());
+    $this->assertCount(0, taxonomy_vocabulary_load_multiple());
+    $this->createTerm($this->createVocabulary());
+    $this->assertCount(1, taxonomy_term_load_multiple());
+    $this->assertCount(1, taxonomy_vocabulary_load_multiple());
+    $vocab = $this->createVocabulary();
+    $this->createTerm($vocab);
+    $this->createTerm($vocab);
+    $this->assertCount(3, taxonomy_term_load_multiple());
+    $this->assertCount(2, taxonomy_vocabulary_load_multiple());
+
+    $this->assertNull(taxonomy_term_load(3000));
+    $this->assertInstanceOf(TermInterface::class, taxonomy_term_load(1));
+    $this->assertNull(taxonomy_vocabulary_load('not_a_vocab'));
+    $this->assertInstanceOf(VocabularyInterface::class, taxonomy_vocabulary_load($vocab->id()));
+  }
+
+}