comparison core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\rdf\Unit; 3 namespace Drupal\Tests\rdf\Unit;
4 4
5 use Drupal\Core\DependencyInjection\ContainerBuilder; 5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\Core\Entity\EntityManager;
7 use Drupal\Core\Entity\EntityTypeManagerInterface;
6 use Drupal\Tests\UnitTestCase; 8 use Drupal\Tests\UnitTestCase;
7 use Drupal\rdf\Entity\RdfMapping; 9 use Drupal\rdf\Entity\RdfMapping;
8 10
9 /** 11 /**
10 * @coversDefaultClass \Drupal\rdf\Entity\RdfMapping 12 * @coversDefaultClass \Drupal\rdf\Entity\RdfMapping
23 * The entity manager used for testing. 25 * The entity manager used for testing.
24 * 26 *
25 * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject 27 * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
26 */ 28 */
27 protected $entityManager; 29 protected $entityManager;
30
31 /**
32 * The entity type manager used for testing.
33 *
34 * @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
35 */
36 protected $entityTypeManager;
28 37
29 /** 38 /**
30 * The ID of the type of the entity under test. 39 * The ID of the type of the entity under test.
31 * 40 *
32 * @var string 41 * @var string
49 $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); 58 $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
50 $this->entityType->expects($this->any()) 59 $this->entityType->expects($this->any())
51 ->method('getProvider') 60 ->method('getProvider')
52 ->will($this->returnValue('entity')); 61 ->will($this->returnValue('entity'));
53 62
54 $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); 63 $this->entityManager = new EntityManager();
64 $this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
55 65
56 $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); 66 $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
57 67
58 $container = new ContainerBuilder(); 68 $container = new ContainerBuilder();
59 $container->set('entity.manager', $this->entityManager); 69 $container->set('entity.manager', $this->entityManager);
70 $container->set('entity_type.manager', $this->entityTypeManager);
60 $container->set('uuid', $this->uuid); 71 $container->set('uuid', $this->uuid);
72 $this->entityManager->setContainer($container);
61 \Drupal::setContainer($container); 73 \Drupal::setContainer($container);
62 74
63 } 75 }
64 76
65 /** 77 /**
75 $values = ['targetEntityType' => $target_entity_type_id]; 87 $values = ['targetEntityType' => $target_entity_type_id];
76 $target_entity_type->expects($this->any()) 88 $target_entity_type->expects($this->any())
77 ->method('getBundleEntityType') 89 ->method('getBundleEntityType')
78 ->will($this->returnValue(NULL)); 90 ->will($this->returnValue(NULL));
79 91
80 $this->entityManager->expects($this->at(0)) 92 $this->entityTypeManager->expects($this->at(0))
81 ->method('getDefinition') 93 ->method('getDefinition')
82 ->with($target_entity_type_id) 94 ->with($target_entity_type_id)
83 ->will($this->returnValue($target_entity_type)); 95 ->will($this->returnValue($target_entity_type));
84 $this->entityManager->expects($this->at(1)) 96 $this->entityTypeManager->expects($this->at(1))
85 ->method('getDefinition') 97 ->method('getDefinition')
86 ->with($this->entityTypeId) 98 ->with($this->entityTypeId)
87 ->will($this->returnValue($this->entityType)); 99 ->will($this->returnValue($this->entityType));
88 100
89 $entity = new RdfMapping($values, $this->entityTypeId); 101 $entity = new RdfMapping($values, $this->entityTypeId);
106 118
107 $target_entity_type->expects($this->any()) 119 $target_entity_type->expects($this->any())
108 ->method('getBundleConfigDependency') 120 ->method('getBundleConfigDependency')
109 ->will($this->returnValue(['type' => 'config', 'name' => 'test_module.type.' . $bundle_id])); 121 ->will($this->returnValue(['type' => 'config', 'name' => 'test_module.type.' . $bundle_id]));
110 122
111 $this->entityManager->expects($this->at(0)) 123 $this->entityTypeManager->expects($this->at(0))
112 ->method('getDefinition') 124 ->method('getDefinition')
113 ->with($target_entity_type_id) 125 ->with($target_entity_type_id)
114 ->will($this->returnValue($target_entity_type)); 126 ->will($this->returnValue($target_entity_type));
115 $this->entityManager->expects($this->at(1)) 127 $this->entityTypeManager->expects($this->at(1))
116 ->method('getDefinition') 128 ->method('getDefinition')
117 ->with($this->entityTypeId) 129 ->with($this->entityTypeId)
118 ->will($this->returnValue($this->entityType)); 130 ->will($this->returnValue($this->entityType));
119 131
120 $entity = new RdfMapping($values, $this->entityTypeId); 132 $entity = new RdfMapping($values, $this->entityTypeId);