You are here

class ConfigTest in Zircon Profile 8.0

Same name in this branch
  1. 8.0 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest
  2. 8.0 core/modules/system/src/Tests/File/ConfigTest.php \Drupal\system\Tests\File\ConfigTest
  3. 8.0 core/modules/config/tests/config_test/src/Entity/ConfigTest.php \Drupal\config_test\Entity\ConfigTest
  4. 8.0 core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest
Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest

@coversDefaultClass \Drupal\migrate\Plugin\migrate\destination\Config @group migrate

Hierarchy

  • class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
    • class \Drupal\Tests\migrate\Unit\destination\ConfigTest

Expanded class hierarchy of ConfigTest

File

core/modules/migrate/tests/src/Unit/destination/ConfigTest.php, line 17
Contains \Drupal\Tests\migrate\Unit\destination\ConfigTest.

Namespace

Drupal\Tests\migrate\Unit\destination
View source
class ConfigTest extends UnitTestCase {

  /**
   * Test the import method.
   */
  public function testImport() {
    $source = array(
      'test' => 'x',
    );
    $migration = $this
      ->getMockBuilder('Drupal\\migrate\\Entity\\Migration')
      ->disableOriginalConstructor()
      ->getMock();
    $config = $this
      ->getMockBuilder('Drupal\\Core\\Config\\Config')
      ->disableOriginalConstructor()
      ->getMock();
    foreach ($source as $key => $val) {
      $config
        ->expects($this
        ->once())
        ->method('set')
        ->with($this
        ->equalTo($key), $this
        ->equalTo($val))
        ->will($this
        ->returnValue($config));
    }
    $config
      ->expects($this
      ->once())
      ->method('save');
    $config
      ->expects($this
      ->once())
      ->method('getName')
      ->willReturn('d8_config');
    $config_factory = $this
      ->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
    $config_factory
      ->expects($this
      ->once())
      ->method('getEditable')
      ->with('d8_config')
      ->will($this
      ->returnValue($config));
    $row = $this
      ->getMockBuilder('Drupal\\migrate\\Row')
      ->disableOriginalConstructor()
      ->getMock();
    $row
      ->expects($this
      ->once())
      ->method('getRawDestination')
      ->will($this
      ->returnValue($source));
    $destination = new Config(array(
      'config_name' => 'd8_config',
    ), 'd8_config', array(
      'pluginId' => 'd8_config',
    ), $migration, $config_factory);
    $destination_id = $destination
      ->import($row);
    $this
      ->assertEquals($destination_id, [
      'd8_config',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigTest::testImport public function Test the import method.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root.
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName protected function Mocks a block with a block plugin.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed in 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.
UnitTestCase::setUp protected function 259