ItemTestBase.php in Feeds 8.3
File
tests/src/Unit/Feeds/Item/ItemTestBase.php
View source
<?php
namespace Drupal\Tests\feeds\Unit\Feeds\Item;
use Drupal\feeds\Feeds\Item\ItemInterface;
use Drupal\Tests\feeds\Unit\FeedsUnitTestCase;
abstract class ItemTestBase extends FeedsUnitTestCase {
protected $item;
public function testImplementingInterface() {
$this
->assertInstanceOf(ItemInterface::class, $this->item);
}
public function testSetAndGet() {
$this
->assertSame($this->item, $this->item
->set('field', 'value'));
$this
->assertSame('value', $this->item
->get('field'));
}
public function testToArray() {
$this->item
->set('field', 'value');
$this->item
->set('field2', 'value2');
$expected = [
'field' => 'value',
'field2' => 'value2',
];
$this
->assertEquals($expected, $this->item
->toArray());
}
public function testFromArray() {
$this
->assertSame($this->item, $this->item
->fromArray([
'Foo' => 'Bar',
'Baz' => 'Qux',
]));
$this
->assertSame('Bar', $this->item
->get('Foo'));
$this
->assertSame('Qux', $this->item
->get('Baz'));
$this
->assertNull($this->item
->get('Bar'));
$this
->assertNull($this->item
->get('Qux'));
}
}