Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function example() {
- return Drupal::config('my_module.job')->get('my_module.bucketName');
- }
- public function testExample() {
- $myModuleHelper = new MyModuleHelper();
- $expected_config = array(
- 'bucketName' => 'test_bucket',
- );
- $this->assertEquals($expected_config, $myModuleHelper ->example());
- }
- public function setUp() {
- $this->config = $this->getMockBuilder('DrupalCoreConfigImmutableConfig')
- ->disableOriginalConstructor()
- ->getMock();
- $this->configFactory = $this->getMockBuilder('DrupalCoreConfigConfigFactory')
- ->disableOriginalConstructor()
- ->getMock();
- $this->configFactory->expects($this->any())
- ->method('get')
- ->with('my_module.job')
- ->willReturn($this->config);
- $this->container = new ContainerBuilder();
- $this->container->set('config.factory', $this->configFactory);
- Drupal::setContainer($this->container);
- }
- $this->configFactory = $this->getConfigFactoryStub([
- 'mymodule.job' => ['bucketName' => 'test_bucket'],
- ]);
- $this->configFactory = $this->getConfigFactoryStub([
- 'mymodule.settings' => [
- 'key' => [
- 'subkey' => [
- 'subsubkey' => 'value',
- ],
- ],
- ],
- ]);
- $this->container = new ContainerBuilder();
- $this->container->set('config.factory', $this->configFactory);
- Drupal::setContainer($this->container);
- Drupal::config('mymodule.settings')->get('key.subkey.subsubkey');
Add Comment
Please, Sign In to add comment