TS 69 PHP Code Completion & Editor

PHP Editor Test Specification for NetBeans 6.9

Author: Filip Zamboj, updated Vladimir Riha
Version: 1.1
Last Update: 16th April 2012
Introduction: This specification provides usecases for PHP editor in the NetBeans IDE
Comments: Note that code completion is always being developed and features changed. This TS contains basic code completion features that have to work. All other features will be/are covered by functional and unit tests as they are easily maintained and configured. List of covered topics by automated tests will be added to the list of TSs once the overview is complete.

Contents


Test suite: Code Completion

Purpose: Check that code completion works properly in PHP code and HTML for PHP source and PHP web page.
Prerequisites: a PHP project is created in the Netbeans IDE.

  1. Create a PHP source file.
    1. In the main menu, choose File > New File...
    2. In the Categories list, select Scripting. In the File Types list, choose PHP File. Click Next.
    3. Accept default values by pressing Finish button.
    • EXPECTED RESULT: A new PHP web page is created and opened in the editor.
  2. Verify automatic code completion invocation.
    1. In PHP source, type $.
    • EXPECTED RESULT: Code completion is invoked automatically - a list of available variables appears.
  3. Verify local variable code completion.
    1. Create a PHP function.
    2. Declare a variable in the function.
    3. Type several first symbols of the variable name and invoke code completion.
    • EXPECTED RESULT: Code completion appears and the variable name is among suggestions.
  4. Verify global variable code completion.
    1. Create a PHP function.
    2. Declare a global variable.
    3. Type several first symbols of the variable name and invoke code completion.
    • EXPECTED RESULT: Code completion appears and the variable name is among suggestions.
  5. Verify variable from included file code completion.
    1. Include an other PHP file into PHP source.
    2. Open that PHP source and create a global variable there.
    3. Create a PHP function in the first source.
    4. Inside that function, type several first symbols of the variable name and invoke code completion.
    5. Choose that variable in the list and press Enter.
    • EXPECTED RESULT: Code is completed properly. No require or include directive is auto-generated.
  6. Verify variable from required file code completion.
    1. Add an other PHP file into PHP source using the require directive.
    2. Open that PHP source and create a global variable there.
    3. Create a PHP function in the first source.
    4. Inside that function, type several first symbols of the variable name and invoke code completion.
    5. Choose that variable in the list and press Enter.
    • EXPECTED RESULT: Code is completed properly. No require or include directive is auto-generated.
  7. Verify code completion inside the identifier.
    1. Place the caret inside of existing PHP identifier.
    2. Invoke code completion.
    • EXPECTED RESULT: Code completion appears and the list of suggestions corresponds to the beginning of the identifier.
  8. Verify documentation hints for built-in identifiers.
    1. Invoke code completion for a whitespace.
    2. Select a built-in identifier in the list (like $GLOBALS, $_ENV)
    • EXPECTED RESULT: In the details code completion view, a description of the identifier appears.
  9. Verify documentation hints for keywords.
    1. Check #199406
    2. Invoke code completion for a whitespace.
    3. Select a keyword in the list (like extends, if).
    • EXPECTED RESULT: In the details code completion view, a description of the keyword appears.
  10. Verify keywords code completion.
    1. Type the beginning of a keyword in a situation appropriate for its usage.
    2. Invoke code completion.
    • EXPECTED RESULT: Code completion appears and the keyword is among suggestions.
  11. Verify code completion with a single option.
    1. Type the beginning of a identifier so that there is only one option for code completion.
    2. Invoke code completion.
    • EXPECTED RESULT: Identifier is instantly completed without any popup windows.
  12. Verify JavaDoc window.
    1. Create a PHP function.
    2. Add some JavaDoc to that function. Don't save the source.
    3. In some other place, type the beginning of that function name and invoke code completion.
    4. Select that function in the popup window.
    • EXPECTED RESULT: Just entered JavaDoc is shown in the JavaDoc window of code completion.
  13. Verify code completion after EXTENDS.
    1. Define Foo class.
    2. Type "class MyClass extends F".
    3. Invoke code completion.
    • EXPECTED RESULT: Code completion appears and Foo class is shown. No any other identifiers are shown.
  14. Verify that require directive is automatically added
    1. Create a function in PHP file.
    2. In another PHP file, invoke code completion so that that function is available.
    3. Select that function and press Enter.
    • EXPECTED RESULT: code is completed with that function name, and require directive is added for the corresponding class.
  15. Verify code completion in // comments.
    1. Create // style comment .
    2. Invoke code completion at that line after //.
    • EXPECTED RESULT: Code completion doesn't appear. It shouldn't be available in comments.
  16. Verify code completion in /* */ comments.
    1. Create /* */ style comment .
    2. Invoke code completion inside of that comment.
    • EXPECTED RESULT: Code completion does appear.
  17. Verify code completion in /** */ comments.
    1. Create /** */ comment .
    2. Invoke code completion inside of that comment.
    • EXPECTED RESULT: Code completion shows a list of JavaDoc tags (like @abstract).
  18. Verify smart method code completion
    1. Copy the code below to php file
    2. Invoke code completion at place of "|" (first remove the "|" char from code)
    • EXPECTED RESULT: Code completion the bar method, when you confirm it following is inserted bar($string, $int, $float), so the parameters are filled in based on their types and type described in PhpDoc of function bar() .
class Foo{   
    /**
     *Some PhpDoc
     * @param string $s
     * @param int $i
     * @param float $f 
     */
    function bar($s, $i, $f){}
    
    function foobar(){
        $string ="";
        $int = 42;
        $float = 3.1456;
        $this->|       
    }
}
  1. Verify smart method code completion 2
    1. Edit the code from previous test case: declare variable $s in foobar()
    2. Invoke code completion at place of "|" (first remove the "|" char from code)
    • EXPECTED RESULT: Code completion offers bar($s, $int, $float), so the parameters are filled in similarly like in previous test case but now not only type is considered but also name of the variable to be used (so $s is used instead of $string).
...   
    function foobar(){
        $string ="";
        $s = "";
        $int = 42;
        $float = 3.1456;
        $this->|       
    }
}
  1. Verify smart try/catch code completion
    1. Use the code belos
    2. Invoke code completion at place of "|" (first remove the "|" char from code)
    • EXPECTED RESULT: Code completion offers only classes inherited from Execption.
   try{
      new AppendIterator;
    }  catch (|)
    }


Test suite: Text Expansion from Templates

  1. Verify Templates Creation
    1. Choose Tools -> Options -> Editor -> Code Templates
    2. Choose PHP Language
    3. Choose New
    4. Write ajaj into dialog
    5. Add expaned text for abbreviation jajaj
    6. Press OK
    7. Create New Empty Project
    8. Delete index.php content
    9. Add following to index.php
<?

?>
    1. Write ajaj and press tab
    • EXPECTED RESULT: ajaj will be expanded to jajaj
  1. Verify Templates Deletion
    1. Choose Tools -> Options -> Editor -> Code Templates
    2. Choose PHP Language
    3. Choose ajaj abbreviation
    4. Choose Delete
    5. Press OK
    6. Create New Empty Project
    7. Delete index.php content
    8. Add following to index.php
<?

?>
    1. Write ajaj and press tab
    • EXPECTED RESULT: ajaj will NOT be expanded to jajaj


Testsuite: PHP 5.3 Support

  1. Verify Error Highlighting and Code Completion of PHP5.3 if PHP5.2 is Used
    1. Verify that PHP5.2 is set as PHP version in Project Properties -> Sources
    2. write name and invoke code completion
    • EXPECTED RESULT: namespace keyword is offered
    1. press enter/accept offered keyword
    2. complete keyword to namespace A;
    • EXPECTED RESULT: namespace keyword is underlined by red color and red bullet with exclamation mark appears on left side of editor window.
    1. change Project Properties -> Sources -> PHP Version to PHP 5.3
    • EXPECTED RESULT: error indication disappears
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo