You are here

class TamperableComplexDataAdapterTest in Tamper 8

@coversDefaultClass \Drupal\tamper\Adapter\TamperableComplexDataAdapter @group tamper

Hierarchy

Expanded class hierarchy of TamperableComplexDataAdapterTest

File

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

Namespace

Drupal\Tests\tamper\Unit\Adapter
View source
class TamperableComplexDataAdapterTest extends UnitTestCase {

  /**
   * Complex data object.
   *
   * @var \Drupal\Core\TypedData\ComplexDataInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $complexData;

  /**
   * Adapter for the complex data.
   *
   * @var \Drupal\tamper\Adapter\TamperableComplexDataAdapter
   */
  protected $adapter;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    $this->complexData = $this
      ->createMock(ComplexDataInterface::class);
    $this->adapter = new TamperableComplexDataAdapter($this->complexData);
  }

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

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

  /**
   * @covers ::setSourceProperty
   */
  public function testSetSourceProperty() {
    $this->complexData
      ->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.
TamperableComplexDataAdapterTest::$adapter protected property Adapter for the complex data.
TamperableComplexDataAdapterTest::$complexData protected property Complex data object.
TamperableComplexDataAdapterTest::setUp protected function Overrides UnitTestCase::setUp
TamperableComplexDataAdapterTest::testGetSource public function @covers ::getSource
TamperableComplexDataAdapterTest::testGetSourceProperty public function @covers ::getSourceProperty
TamperableComplexDataAdapterTest::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.