Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/comment/tests/src/Unit/CommentManagerTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Tests\comment\Unit; | 3 namespace Drupal\Tests\comment\Unit; |
4 | 4 |
5 use Drupal\comment\CommentManager; | 5 use Drupal\comment\CommentManager; |
6 use Drupal\Core\Entity\EntityFieldManagerInterface; | |
7 use Drupal\Core\Entity\EntityTypeManagerInterface; | |
6 use Drupal\Core\Entity\FieldableEntityInterface; | 8 use Drupal\Core\Entity\FieldableEntityInterface; |
9 use Drupal\Core\Session\AccountInterface; | |
7 use Drupal\Tests\UnitTestCase; | 10 use Drupal\Tests\UnitTestCase; |
8 | 11 |
9 /** | 12 /** |
10 * @coversDefaultClass \Drupal\comment\CommentManager | 13 * @coversDefaultClass \Drupal\comment\CommentManager |
11 * @group comment | 14 * @group comment |
26 $entity_type->expects($this->any()) | 29 $entity_type->expects($this->any()) |
27 ->method('entityClassImplements') | 30 ->method('entityClassImplements') |
28 ->with(FieldableEntityInterface::class) | 31 ->with(FieldableEntityInterface::class) |
29 ->will($this->returnValue(TRUE)); | 32 ->will($this->returnValue(TRUE)); |
30 | 33 |
31 $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); | 34 $entity_field_manager = $this->createMock(EntityFieldManagerInterface::class); |
35 $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); | |
32 | 36 |
33 $entity_manager->expects($this->once()) | 37 $entity_field_manager->expects($this->once()) |
34 ->method('getFieldMapByFieldType') | 38 ->method('getFieldMapByFieldType') |
35 ->will($this->returnValue([ | 39 ->will($this->returnValue([ |
36 'node' => [ | 40 'node' => [ |
37 'field_foobar' => [ | 41 'field_foobar' => [ |
38 'type' => 'comment', | 42 'type' => 'comment', |
39 ], | 43 ], |
40 ], | 44 ], |
41 ])); | 45 ])); |
42 | 46 |
43 $entity_manager->expects($this->any()) | 47 $entity_type_manager->expects($this->any()) |
44 ->method('getDefinition') | 48 ->method('getDefinition') |
45 ->will($this->returnValue($entity_type)); | 49 ->will($this->returnValue($entity_type)); |
46 | 50 |
47 $comment_manager = new CommentManager( | 51 $comment_manager = new CommentManager( |
48 $entity_manager, | 52 $entity_type_manager, |
49 $this->getMock('Drupal\Core\Config\ConfigFactoryInterface'), | 53 $this->getMock('Drupal\Core\Config\ConfigFactoryInterface'), |
50 $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'), | 54 $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'), |
51 $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface'), | |
52 $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'), | 55 $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'), |
53 $this->getMock('Drupal\Core\Session\AccountInterface') | 56 $this->createMock(AccountInterface::class), |
57 $entity_field_manager | |
54 ); | 58 ); |
55 $comment_fields = $comment_manager->getFields('node'); | 59 $comment_fields = $comment_manager->getFields('node'); |
56 $this->assertArrayHasKey('field_foobar', $comment_fields); | 60 $this->assertArrayHasKey('field_foobar', $comment_fields); |
57 } | 61 } |
58 | 62 |