Browse Source

Change boolean/required to be rendered as '0' instead of '' in XML

chinpei215 9 years ago
parent
commit
c807ccf083

+ 1 - 1
src/Console/ConsoleInputArgument.php

@@ -186,7 +186,7 @@ class ConsoleInputArgument
         $option = $parent->addChild('argument');
         $option->addAttribute('name', $this->_name);
         $option->addAttribute('help', $this->_help);
-        $option->addAttribute('required', $this->isRequired());
+        $option->addAttribute('required', (int)$this->isRequired());
         $choices = $option->addChild('choices');
         foreach ($this->_choices as $valid) {
             $choices->addChild('choice', $valid);

+ 1 - 1
src/Console/ConsoleInputOption.php

@@ -253,7 +253,7 @@ class ConsoleInputOption
         }
         $option->addAttribute('short', $short);
         $option->addAttribute('help', $this->_help);
-        $option->addAttribute('boolean', $this->_boolean);
+        $option->addAttribute('boolean', (int)$this->_boolean);
         $option->addChild('default', $this->_default);
         $choices = $option->addChild('choices');
         foreach ($this->_choices as $valid) {

+ 8 - 8
tests/TestCase/Console/HelpFormatterTest.php

@@ -322,7 +322,7 @@ xml;
 		<default></default>
 		<choices></choices>
 	</option>
-	<option name="--test" short="" help="A test option." boolean="">
+	<option name="--test" short="" help="A test option." boolean="0">
 		<default></default>
 		<choices>
 			<choice>one</choice>
@@ -337,7 +337,7 @@ xml;
 			<choice>aro</choice>
 		</choices>
 	</argument>
-	<argument name="other_longer" help="Another argument." required="">
+	<argument name="other_longer" help="Another argument." required="0">
 		<choices></choices>
 	</argument>
 </arguments>
@@ -373,7 +373,7 @@ xml;
 		<default></default>
 		<choices></choices>
 	</option>
-	<option name="--test" short="" help="A test option." boolean="">
+	<option name="--test" short="" help="A test option." boolean="0">
 		<default></default>
 		<choices></choices>
 	</option>
@@ -415,7 +415,7 @@ xml;
 		<default></default>
 		<choices></choices>
 	</option>
-	<option name="--test" short="" help="A test option." boolean="">
+	<option name="--test" short="" help="A test option." boolean="0">
 		<default></default>
 		<choices></choices>
 	</option>
@@ -449,7 +449,7 @@ xml;
 <description/>
 <subcommands/>
 <options>
-	<option name="--connection" short="-c" help="The connection to use." boolean="">
+	<option name="--connection" short="-c" help="The connection to use." boolean="0">
 		<default>default</default>
 		<choices></choices>
 	</option>
@@ -457,7 +457,7 @@ xml;
 		<default></default>
 		<choices></choices>
 	</option>
-	<option name="--test" short="" help="A test option." boolean="">
+	<option name="--test" short="" help="A test option." boolean="0">
 		<default></default>
 		<choices></choices>
 	</option>
@@ -494,7 +494,7 @@ xml;
 			<default></default>
 			<choices></choices>
 		</option>
-		<option name="--test" short="" help="A test option." boolean="">
+		<option name="--test" short="" help="A test option." boolean="0">
 			<default></default>
 			<choices></choices>
 		</option>
@@ -503,7 +503,7 @@ xml;
 		<argument name="model" help="The model to make." required="1">
 			<choices></choices>
 		</argument>
-		<argument name="other_longer" help="Another argument." required="">
+		<argument name="other_longer" help="Another argument." required="0">
 			<choices></choices>
 		</argument>
 	</arguments>