Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
Fix deprecated root() call on TreeBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Jun 8, 2019
1 parent 8f08f74 commit 8dc6410
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

### [1.2.1](https://github.com/webeweb/haveibeenpwned-bundle/tree/v1.2.1) (2019-06-08)

- Fix deprecated root() call on TreeBuilder

### [1.2.0](https://github.com/webeweb/haveibeenpwned-bundle/tree/v1.2.0) (2019-06-08)

- Change license
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use WBW\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper;

/**
* Configuration.
Expand All @@ -27,14 +28,13 @@ class Configuration implements ConfigurationInterface {
*/
public function getConfigTreeBuilder() {

$treeBuilder = new TreeBuilder();
$treeBuilder = new TreeBuilder(WBWHaveIBeenPwnedExtension::EXTENSION_ALIAS);

$rootNode = $treeBuilder->root("wbw_core");
$rootNode = ConfigurationHelper::getRootNode($treeBuilder, WBWHaveIBeenPwnedExtension::EXTENSION_ALIAS);
$rootNode->children()
->booleanNode("event_listeners")->defaultTrue()->info("Load event listeners")->end()
->end();

return $treeBuilder;
}

}
9 changes: 8 additions & 1 deletion DependencyInjection/WBWHaveIBeenPwnedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@
*/
class WBWHaveIBeenPwnedExtension extends Extension {

/**
* Extension alias.
*
* @var string
*/
const EXTENSION_ALIAS = "wbw_haveibeenpwned";

/**
* {@inheritdoc}
*/
public function getAlias() {
return "wbw_haveibeenpwned";
return self::EXTENSION_ALIAS;
}

/**
Expand Down
16 changes: 13 additions & 3 deletions Tests/DependencyInjection/WBWHaveIBeenPwnedExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ protected function setUp() {

// Set a configs array mock.
$this->configs = [
"wbw_haveibeenpwned" => [
WBWHaveIBeenPwnedExtension::EXTENSION_ALIAS => [
"event_listeners" => true,
],
];
}

/**
* Tests the __construct() method.
*
* @return void
*/
public function testConstruct() {

$this->assertEquals("wbw_haveibeenpwned", WBWHaveIBeenPwnedExtension::EXTENSION_ALIAS);
}

/**
* Tests the getAlias() method.
*
Expand All @@ -56,7 +66,7 @@ public function testGetAlias() {

$obj = new WBWHaveIBeenPwnedExtension();

$this->assertEquals("wbw_haveibeenpwned", $obj->getAlias());
$this->assertEquals(WBWHaveIBeenPwnedExtension::EXTENSION_ALIAS, $obj->getAlias());
}

/**
Expand Down Expand Up @@ -95,7 +105,7 @@ public function testLoad() {
public function testLoadWithoutEventListeners() {

// Set the configs mock.
$this->configs["wbw_haveibeenpwned"]["event_listeners"] = false;
$this->configs[WBWHaveIBeenPwnedExtension::EXTENSION_ALIAS]["event_listeners"] = false;

$obj = new WBWHaveIBeenPwnedExtension();

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"require": {
"php": "^5.6|^7.0",
"webeweb/core-bundle": "^2.0",
"webeweb/core-bundle": "^2.4",
"webeweb/haveibeenpwned-library": "^1.2"
},
"require-dev": {
Expand Down

0 comments on commit 8dc6410

Please sign in to comment.