|
@@ 199-214 (lines=16) @@
|
| 196 |
|
/** |
| 197 |
|
* Test create method. |
| 198 |
|
*/ |
| 199 |
|
public function testCreate() |
| 200 |
|
{ |
| 201 |
|
$value = $this->randomString(); |
| 202 |
|
$fieldName = 'name'; |
| 203 |
|
$fields = [$fieldName=> [['value' => $value]]]; |
| 204 |
|
|
| 205 |
|
// Test create method. |
| 206 |
|
$entity = DriverEntityDrupal8::create( |
| 207 |
|
$fields, |
| 208 |
|
$this->entityType |
| 209 |
|
)->save(); |
| 210 |
|
// The test driverfield plugin has been matched, which mutates the text. |
| 211 |
|
$processedName = 'now' . $value . 'processed'; |
| 212 |
|
$entities = $this->storage->loadByProperties(['name' => $processedName]); |
| 213 |
|
$this->assertEquals(1, count($entities)); |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
/** |
| 217 |
|
* Test identifying entity type by label. |
|
@@ 219-234 (lines=16) @@
|
| 216 |
|
/** |
| 217 |
|
* Test identifying entity type by label. |
| 218 |
|
*/ |
| 219 |
|
public function testEntityTypeLabel() |
| 220 |
|
{ |
| 221 |
|
$value = $this->randomString(); |
| 222 |
|
$fieldName = 'name'; |
| 223 |
|
$fields = [$fieldName=> [['value' => $value]]]; |
| 224 |
|
|
| 225 |
|
// "Test entity" is the label of the entity_test entity type. |
| 226 |
|
$entity = DriverEntityDrupal8::create( |
| 227 |
|
$fields, |
| 228 |
|
"Test entity" |
| 229 |
|
)->save(); |
| 230 |
|
// The test driverfield plugin has been matched, which mutates the text. |
| 231 |
|
$processedName = 'now' . $value . 'processed'; |
| 232 |
|
$entities = $this->storage->loadByProperties(['name' => $processedName]); |
| 233 |
|
$this->assertEquals(1, count($entities)); |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
/** |
| 237 |
|
* Test identifying entity type by machine name without underscores. |
|
@@ 239-254 (lines=16) @@
|
| 236 |
|
/** |
| 237 |
|
* Test identifying entity type by machine name without underscores. |
| 238 |
|
*/ |
| 239 |
|
public function testEntityTypeWithoutUnderscores() |
| 240 |
|
{ |
| 241 |
|
$value = $this->randomString(); |
| 242 |
|
$fieldName = 'name'; |
| 243 |
|
$fields = [$fieldName=> [['value' => $value]]]; |
| 244 |
|
|
| 245 |
|
// Instead of "entity_test", try capitalised and without underscores. |
| 246 |
|
$entity = DriverEntityDrupal8::create( |
| 247 |
|
$fields, |
| 248 |
|
"ENTITY TEST" |
| 249 |
|
)->save(); |
| 250 |
|
// The test driverfield plugin has been matched, which mutates the text. |
| 251 |
|
$processedName = 'now' . $value . 'processed'; |
| 252 |
|
$entities = $this->storage->loadByProperties(['name' => $processedName]); |
| 253 |
|
$this->assertEquals(1, count($entities)); |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
/** |
| 257 |
|
* Replace values in strings or recursively in arrays. |