Guest User

Untitled

a guest
Nov 23rd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. public function example() {
  2. return Drupal::config('my_module.job')->get('my_module.bucketName');
  3. }
  4.  
  5. public function testExample() {
  6. $myModuleHelper = new MyModuleHelper();
  7. $expected_config = array(
  8. 'bucketName' => 'test_bucket',
  9. );
  10.  
  11. $this->assertEquals($expected_config, $myModuleHelper ->example());
  12. }
  13.  
  14. public function setUp() {
  15. $this->config = $this->getMockBuilder('DrupalCoreConfigImmutableConfig')
  16. ->disableOriginalConstructor()
  17. ->getMock();
  18.  
  19. $this->configFactory = $this->getMockBuilder('DrupalCoreConfigConfigFactory')
  20. ->disableOriginalConstructor()
  21. ->getMock();
  22. $this->configFactory->expects($this->any())
  23. ->method('get')
  24. ->with('my_module.job')
  25. ->willReturn($this->config);
  26.  
  27. $this->container = new ContainerBuilder();
  28. $this->container->set('config.factory', $this->configFactory);
  29. Drupal::setContainer($this->container);
  30. }
  31.  
  32. $this->configFactory = $this->getConfigFactoryStub([
  33. 'mymodule.job' => ['bucketName' => 'test_bucket'],
  34. ]);
  35.  
  36. $this->configFactory = $this->getConfigFactoryStub([
  37. 'mymodule.settings' => [
  38. 'key' => [
  39. 'subkey' => [
  40. 'subsubkey' => 'value',
  41. ],
  42. ],
  43. ],
  44. ]);
  45. $this->container = new ContainerBuilder();
  46. $this->container->set('config.factory', $this->configFactory);
  47. Drupal::setContainer($this->container);
  48.  
  49. Drupal::config('mymodule.settings')->get('key.subkey.subsubkey');
Add Comment
Please, Sign In to add comment