annotate core/modules/taxonomy/tests/src/Kernel/TaxonomyLegacyTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@18 1 <?php
Chris@18 2
Chris@18 3 namespace Drupal\Tests\taxonomy\Kernel;
Chris@18 4
Chris@18 5 use Drupal\KernelTests\KernelTestBase;
Chris@18 6 use Drupal\taxonomy\TermInterface;
Chris@18 7 use Drupal\taxonomy\VocabularyInterface;
Chris@18 8 use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait;
Chris@18 9
Chris@18 10 /**
Chris@18 11 * Tests legacy user functionality.
Chris@18 12 *
Chris@18 13 * @group user
Chris@18 14 * @group legacy
Chris@18 15 */
Chris@18 16 class TaxonomyLegacyTest extends KernelTestBase {
Chris@18 17 use TaxonomyTestTrait;
Chris@18 18
Chris@18 19 /**
Chris@18 20 * Modules to enable.
Chris@18 21 *
Chris@18 22 * @var array
Chris@18 23 */
Chris@18 24 public static $modules = ['filter', 'taxonomy', 'text', 'user'];
Chris@18 25
Chris@18 26 /**
Chris@18 27 * {@inheritdoc}
Chris@18 28 */
Chris@18 29 protected function setUp() {
Chris@18 30 parent::setUp();
Chris@18 31 $this->installConfig(['filter']);
Chris@18 32 $this->installEntitySchema('taxonomy_term');
Chris@18 33 }
Chris@18 34
Chris@18 35 /**
Chris@18 36 * @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
Chris@18 37 * @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
Chris@18 38 * @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
Chris@18 39 * @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
Chris@18 40 */
Chris@18 41 public function testEntityLegacyCode() {
Chris@18 42 $this->assertCount(0, taxonomy_term_load_multiple());
Chris@18 43 $this->assertCount(0, taxonomy_vocabulary_load_multiple());
Chris@18 44 $this->createTerm($this->createVocabulary());
Chris@18 45 $this->assertCount(1, taxonomy_term_load_multiple());
Chris@18 46 $this->assertCount(1, taxonomy_vocabulary_load_multiple());
Chris@18 47 $vocab = $this->createVocabulary();
Chris@18 48 $this->createTerm($vocab);
Chris@18 49 $this->createTerm($vocab);
Chris@18 50 $this->assertCount(3, taxonomy_term_load_multiple());
Chris@18 51 $this->assertCount(2, taxonomy_vocabulary_load_multiple());
Chris@18 52
Chris@18 53 $this->assertNull(taxonomy_term_load(3000));
Chris@18 54 $this->assertInstanceOf(TermInterface::class, taxonomy_term_load(1));
Chris@18 55 $this->assertNull(taxonomy_vocabulary_load('not_a_vocab'));
Chris@18 56 $this->assertInstanceOf(VocabularyInterface::class, taxonomy_vocabulary_load($vocab->id()));
Chris@18 57 }
Chris@18 58
Chris@18 59 }