Mercurial > hg > isophonics-drupal-site
comparison core/modules/comment/tests/src/Unit/CommentManagerTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\comment\Unit; | |
4 | |
5 use Drupal\comment\CommentManager; | |
6 use Drupal\Core\Entity\FieldableEntityInterface; | |
7 use Drupal\Tests\UnitTestCase; | |
8 | |
9 /** | |
10 * @coversDefaultClass \Drupal\comment\CommentManager | |
11 * @group comment | |
12 */ | |
13 class CommentManagerTest extends UnitTestCase { | |
14 | |
15 /** | |
16 * Tests the getFields method. | |
17 * | |
18 * @covers ::getFields | |
19 */ | |
20 public function testGetFields() { | |
21 // Set up a content entity type. | |
22 $entity_type = $this->getMock('Drupal\Core\Entity\ContentEntityTypeInterface'); | |
23 $entity_type->expects($this->any()) | |
24 ->method('getClass') | |
25 ->will($this->returnValue('Node')); | |
26 $entity_type->expects($this->any()) | |
27 ->method('entityClassImplements') | |
28 ->with(FieldableEntityInterface::class) | |
29 ->will($this->returnValue(TRUE)); | |
30 | |
31 $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); | |
32 | |
33 $entity_manager->expects($this->once()) | |
34 ->method('getFieldMapByFieldType') | |
35 ->will($this->returnValue([ | |
36 'node' => [ | |
37 'field_foobar' => [ | |
38 'type' => 'comment', | |
39 ], | |
40 ], | |
41 ])); | |
42 | |
43 $entity_manager->expects($this->any()) | |
44 ->method('getDefinition') | |
45 ->will($this->returnValue($entity_type)); | |
46 | |
47 $comment_manager = new CommentManager( | |
48 $entity_manager, | |
49 $this->getMock('Drupal\Core\Config\ConfigFactoryInterface'), | |
50 $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'), | |
51 $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface'), | |
52 $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'), | |
53 $this->getMock('Drupal\Core\Session\AccountInterface') | |
54 ); | |
55 $comment_fields = $comment_manager->getFields('node'); | |
56 $this->assertArrayHasKey('field_foobar', $comment_fields); | |
57 } | |
58 | |
59 } |