You are here

class TamperableFeedItemAdapterTest in Feeds Tamper 8.2

@coversDefaultClass \Drupal\feeds_tamper\Adapter\TamperableFeedItemAdapter @group feeds_tamper

Hierarchy

Expanded class hierarchy of TamperableFeedItemAdapterTest

File

tests/src/Unit/Adapter/TamperableFeedItemAdapterTest.php, line 13

Namespace

Drupal\Tests\feeds_tamper\Unit\Adapter
View source
class TamperableFeedItemAdapterTest extends UnitTestCase {

  /**
   * A feed item.
   *
   * @var \Drupal\feeds\Feeds\Item\ItemInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $feedItem;

  /**
   * Wrapper around feed item to use it as a tamperable item.
   *
   * @var \Drupal\feeds_tamper\Adapter\TamperableFeedItemAdapter
   */
  protected $adapter;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    $this->feedItem = $this
      ->createMock(ItemInterface::class);
    $this->adapter = new TamperableFeedItemAdapter($this->feedItem);
  }

  /**
   * @covers ::getSource
   */
  public function testGetSource() {
    $this->feedItem
      ->expects($this
      ->once())
      ->method('toArray');
    $this->adapter
      ->getSource();
  }

  /**
   * @covers ::getSourceProperty
   */
  public function testGetSourceProperty() {
    $this->feedItem
      ->expects($this
      ->once())
      ->method('get')
      ->with('foo')
      ->willReturn('bar');
    $this
      ->assertEquals('bar', $this->adapter
      ->getSourceProperty('foo'));
  }

  /**
   * @covers ::setSourceProperty
   */
  public function testSetSourceProperty() {
    $this->feedItem
      ->expects($this
      ->once())
      ->method('set')
      ->with('foo', 'bar');
    $this->adapter
      ->setSourceProperty('foo', 'bar');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
TamperableFeedItemAdapterTest::$adapter protected property Wrapper around feed item to use it as a tamperable item.
TamperableFeedItemAdapterTest::$feedItem protected property A feed item.
TamperableFeedItemAdapterTest::setUp protected function Overrides UnitTestCase::setUp
TamperableFeedItemAdapterTest::testGetSource public function @covers ::getSource
TamperableFeedItemAdapterTest::testGetSourceProperty public function @covers ::getSourceProperty
TamperableFeedItemAdapterTest::testSetSourceProperty public function @covers ::setSourceProperty
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.