Author: ts
Date: Tue Mar  4 11:19:08 2008
New Revision: 7509

Log:
- Fixed issue #12623: console menu dialog handles unexisting options wrong.

Added:
    
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3.php   
(with props)
    
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3_res.php
   (with props)
Modified:
    trunk/ConsoleTools/ChangeLog
    trunk/ConsoleTools/src/dialog/menu_dialog.php
    trunk/ConsoleTools/src/dialog/question_dialog.php
    trunk/ConsoleTools/tests/menu_dialog_test.php

Modified: trunk/ConsoleTools/ChangeLog
==============================================================================
--- trunk/ConsoleTools/ChangeLog [iso-8859-1] (original)
+++ trunk/ConsoleTools/ChangeLog [iso-8859-1] Tue Mar  4 11:19:08 2008
@@ -14,6 +14,7 @@
 - Fixed issue #12626: Type "ta" in ezconsoleoutput documentation.
 - Fixed issue #12625: console tools lacks documentation on targets.
 - Fixed issue #12624: Wrong text in documentation of eZConsoleDialogViewer.
+- Fixed issue #12623: console menu dialog handles unexisting options wrong.
 
 1.3.2 - Monday 14 January 2008
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Modified: trunk/ConsoleTools/src/dialog/menu_dialog.php
==============================================================================
--- trunk/ConsoleTools/src/dialog/menu_dialog.php [iso-8859-1] (original)
+++ trunk/ConsoleTools/src/dialog/menu_dialog.php [iso-8859-1] Tue Mar  4 
11:19:08 2008
@@ -99,6 +99,8 @@
      */
     public function display()
     {
+        $this->reset();
+
         $text = "{$this->options->text}\n";
         foreach ( $this->options->validator->getElements() as $key => $entry )
         {
@@ -112,7 +114,9 @@
 
         $this->output->outputText( $text, $this->options->format );
 
-        $result = $this->options->validator->fixup( 
ezcConsoleDialogViewer::readLine() );
+        $result = $this->options->validator->fixup(
+            ezcConsoleDialogViewer::readLine()
+        );
         if ( $this->options->validator->validate( $result ) )
         {
             $this->result = $result;

Modified: trunk/ConsoleTools/src/dialog/question_dialog.php
==============================================================================
--- trunk/ConsoleTools/src/dialog/question_dialog.php [iso-8859-1] (original)
+++ trunk/ConsoleTools/src/dialog/question_dialog.php [iso-8859-1] Tue Mar  4 
11:19:08 2008
@@ -108,6 +108,8 @@
      */
     public function display()
     {
+        $this->reset();
+
         $this->output->outputText(
             $this->options->text . ( $this->options->showResults === true ? " 
" . $this->options->validator->getResultString() : "" ) . " ",
             $this->options->format

Added: 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3.php
==============================================================================
--- 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3.php 
(added)
+++ 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3.php 
[iso-8859-1] Tue Mar  4 11:19:08 2008
@@ -1,0 +1,35 @@
+<?php
+
+require_once "Base/src/base.php";
+
+function __autoload( $className )
+{
+    ezcBase::autoload( $className );
+}
+
+$out = new ezcConsoleOutput();
+
+$opts = new ezcConsoleMenuDialogOptions();
+$opts->text = "Please choose a possibility:\n";
+$opts->validator = new ezcConsoleMenuDialogDefaultValidator(
+    array(
+        "A" => "Selection A",
+        "B" => "Selection B",
+        "C" => "Selection C",
+        "D" => "Selection D",
+        "Z" => "Selection Z",
+    ),
+    "Z",
+    ezcConsoleMenuDialogDefaultValidator::CONVERT_UPPER
+);
+
+$dialog = new ezcConsoleMenuDialog( $out, $opts );
+
+while ( ( $res = ezcConsoleDialogViewer::displayDialog( $dialog ) ) !== 'Z' )
+{
+    echo "User seletced $res\n";
+}
+
+echo "User quitted\n";
+
+?>

Propchange: 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3_res.php
==============================================================================
--- 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3_res.php
 (added)
+++ 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3_res.php
 [iso-8859-1] Tue Mar  4 11:19:08 2008
@@ -1,0 +1,46 @@
+<?php
+
+return array (
+  0 => 'Please choose a possibility:
+
+  A) Selection A
+  B) Selection B
+  C) Selection C
+  D) Selection D
+  Z) Selection Z
+
+Select: [Z] ',
+  1 => 'User seletced A
+',
+  2 => 'Please choose a possibility:
+
+  A) Selection A
+  B) Selection B
+  C) Selection C
+  D) Selection D
+  Z) Selection Z
+
+Select: [Z] ',
+  3 => 'Please choose a possibility:
+
+  A) Selection A
+  B) Selection B
+  C) Selection C
+  D) Selection D
+  Z) Selection Z
+
+Select: [Z] ',
+  4 => 'User seletced B
+',
+  5 => 'Please choose a possibility:
+
+  A) Selection A
+  B) Selection B
+  C) Selection C
+  D) Selection D
+  Z) Selection Z
+
+Select: [Z] ',
+);
+
+?>

Propchange: 
trunk/ConsoleTools/tests/data/posix/ezcConsoleMenuDialogTest__testDialog3_res.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/ConsoleTools/tests/menu_dialog_test.php
==============================================================================
--- trunk/ConsoleTools/tests/menu_dialog_test.php [iso-8859-1] (original)
+++ trunk/ConsoleTools/tests/menu_dialog_test.php [iso-8859-1] Tue Mar  4 
11:19:08 2008
@@ -184,6 +184,31 @@
         // $this->saveDialogResult( __METHOD__, $res );
         $this->assertEquals( $this->res, $res );
     }
+
+    public function testDialog3()
+    {
+        $this->runDialog( __METHOD__ );
+
+        $res[] = fread( $this->pipes[1], 1024 );
+        
+        fputs( $this->pipes[0], "A\n" );
+        $res[] = fread( $this->pipes[1], 1024 );
+        
+        fputs( $this->pipes[0], "K\n" );
+        $res[] = fread( $this->pipes[1], 1024 );
+        
+        fputs( $this->pipes[0], "B\n" );
+        $res[] = fread( $this->pipes[1], 1024 );
+        
+        fputs( $this->pipes[0], "T\n" );
+        $res[] = fread( $this->pipes[1], 1024 );
+        
+        fputs( $this->pipes[0], "Z\n" );
+        $res[] = fread( $this->pipes[1], 1024 );
+        
+        $this->saveDialogResult( __METHOD__, $res );
+        // $this->assertEquals( $this->res, $res );
+    }
 }
 
 ?>


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to