File tree Expand file tree Collapse file tree 7 files changed +55
-0
lines changed
phpbu/Configuration/Loader Expand file tree Collapse file tree 7 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 122122 <xs : attribute name =" bootstrap" type =" xs:anyURI" />
123123 <xs : attribute name =" verbose" type =" xs:boolean" default =" false" />
124124 <xs : attribute name =" colors" type =" xs:boolean" default =" false" />
125+ <xs : attribute name =" debug" type =" xs:boolean" default =" false" />
125126 </xs : attributeGroup >
126127
127128 <xs : group name =" configGroup" >
Original file line number Diff line number Diff line change @@ -121,6 +121,9 @@ public function setAppSettings(Configuration $configuration)
121121 if (isset ($ this ->json ['colors ' ])) {
122122 $ configuration ->setColors ($ this ->json ['colors ' ]);
123123 }
124+ if (isset ($ this ->json ['debug ' ])) {
125+ $ configuration ->setDebug ($ this ->json ['debug ' ]);
126+ }
124127 }
125128
126129 /**
Original file line number Diff line number Diff line change @@ -139,6 +139,9 @@ public function setAppSettings(Configuration $configuration)
139139 if ($ root ->hasAttribute ('colors ' )) {
140140 $ configuration ->setColors (Str::toBoolean ($ root ->getAttribute ('colors ' ), false ));
141141 }
142+ if ($ root ->hasAttribute ('debug ' )) {
143+ $ configuration ->setDebug (Str::toBoolean ($ root ->getAttribute ('debug ' ), false ));
144+ }
142145 }
143146
144147 /**
Original file line number Diff line number Diff line change 1+ {
2+ "debug" : true ,
3+ "backups" : [
4+ {
5+ "name" : " tarball" ,
6+ "source" : {
7+ "type" : " tar" ,
8+ "options" : {
9+ "path" : " src"
10+ }
11+ },
12+ "target" : {
13+ "dirname" : " backup/src" ,
14+ "filename" : " tarball-%Y%m%d-%H%i.tar" ,
15+ "compress" : " bzip2"
16+ }
17+ }
18+ ]
19+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <phpbu bootstrap =" backup/bootstrap.php" debug =" true" >
3+ <backups >
4+ <backup name =" tarball" >
5+ <source type =" tar" >
6+ <option name =" path" value =" src" />
7+ </source >
8+ <target dirname =" backup/src" filename =" tarball-%Y%m%d-%H%i.tar" compress =" bzip2" />
9+ </backup >
10+ </backups >
11+ </phpbu >
Original file line number Diff line number Diff line change @@ -139,6 +139,13 @@ public function testFileNoSyncType()
139139 $ config = $ loader ->getConfiguration (self ::$ factory );
140140 }
141141
142+ public function testWithDebug (): void
143+ {
144+ $ loader = new Json (PHPBU_TEST_FILES . '/conf/json/config-with-debug.json ' , $ this ->getBootstrapperMock (true ));
145+ $ config = $ loader ->getConfiguration (self ::$ factory );
146+ $ this ->assertTrue ($ config ->getDebug ());
147+ }
148+
142149 /**
143150 * Tests Json::getConfiguration
144151 */
@@ -152,6 +159,7 @@ public function testAppSettings()
152159 $ this ->assertEquals ($ dir . '/backup/bootstrap.php ' , $ config ->getBootstrap ());
153160 $ this ->assertTrue ($ config ->getColors ());
154161 $ this ->assertFalse ($ config ->getVerbose ());
162+ $ this ->assertFalse ($ config ->getDebug ());
155163 }
156164
157165 /**
Original file line number Diff line number Diff line change @@ -146,6 +146,15 @@ public function testCustomAdapter()
146146 $ this ->assertEquals ('demo ' , $ source ->options ['password ' ]);
147147 }
148148
149+ public function testWithDebug (): void
150+ {
151+ $ loader = new Xml (PHPBU_TEST_FILES . '/conf/xml/config-with-debug.xml ' , $ this ->getBootstrapperMock (true ));
152+ $ config = $ loader ->getConfiguration (self ::$ factory );
153+
154+ $ this ->assertFalse ($ loader ->hasValidationErrors ());
155+ $ this ->assertTrue ($ config ->getDebug ());
156+ }
157+
149158 /**
150159 * Tests Xml::getConfiguration
151160 */
@@ -161,6 +170,7 @@ public function testAppSettings()
161170 $ this ->assertEquals ($ dir . '/backup/bootstrap.php ' , $ config ->getBootstrap ());
162171 $ this ->assertTrue ($ config ->getColors ());
163172 $ this ->assertFalse ($ config ->getVerbose ());
173+ $ this ->assertFalse ($ config ->getDebug ());
164174 }
165175
166176 /**
You can’t perform that action at this time.
0 commit comments