EmailTest.php in Feeds 8.3
File
tests/src/Unit/Feeds/Target/EmailTest.php
View source
<?php
namespace Drupal\Tests\feeds\Unit\Feeds\Target;
use Drupal\feeds\Feeds\Target\Email;
class EmailTest extends FieldTargetTestBase {
protected function getTargetClass() {
return Email::class;
}
public function testPrepareValue() {
$method = $this
->getMethod('Drupal\\feeds\\Feeds\\Target\\Email', 'prepareTarget')
->getClosure();
$configuration = [
'feed_type' => $this
->createMock('Drupal\\feeds\\FeedTypeInterface'),
'target_definition' => $method($this
->getMockFieldDefinition()),
];
$target = new Email($configuration, 'email', []);
$method = $this
->getProtectedClosure($target, 'prepareValue');
$values = [
'value' => 'string',
];
$method(0, $values);
$this
->assertSame($values['value'], '');
$values = [
'value' => 'admin@example.com',
];
$method(0, $values);
$this
->assertSame($values['value'], 'admin@example.com');
}
}