TS 72 PHP Miscellaneous

PHP Editor Test Specification for NetBeans 7.2

Author: Vladimir Riha
Version: 1.0
Last Update: 2nd April 2012 Introduction: This specification provides usecases for PHP editor in the NetBeans IDE

Mac OS specific details: To find Options on MacOS, go to Netbeans menu -> Preferences

Contents



Test suite: Mark Occurrences

Purpose: Check that occurrences of PHP identifier highlighted when of the identifiers is selected.
Prerequisites: a PHP project is created in the Netbeans IDE.

  1. Create a PHP web page.
    1. In the main menu, choose File > New File...
    2. In the Categories list, select Scripting. In the File Types list, choose PHP Web Page. Click Next.
    3. Accept default values by pressing Finish button.
    4. Copy/paste a large PHP code peace into the editor.
    • EXPECTED RESULT: A new PHP web page is created and opened in the editor. The code is added there.
  2. Verify local variable occurrences marking.
    1. Create several PHP functions.
    2. Introduce a global variable.
    3. Introduce a variable with the same name in each of these functions.
    4. Add operators which use each of these variables.
    5. Place the cursor onto usage one of these variables.
    • EXPECTED RESULT: Definition and usages of this variable are highlighted. Definition and usages of other variables aren't.
  3. Verify function occurrences marking.
    1. Create a PHP function.
    2. Add several calls of that function, both inside and outside of its code.
    3. Place the cursor onto one of these calls.
    • EXPECTED RESULT: Definition and calls of this function are highlighted.
  4. Verify parameter occurrences marking.
    1. Create a PHP function with a parameter.
    2. Use that parameter in the function body.
    3. Place the cursor onto one of these usages.
    • EXPECTED RESULT: Definition and usages of this parameter are highlighted.



Test suite: HTML Palette

Purpose: Check adding the HTML Palette components to PHP source.
Prerequisites: a PHP project is created in the Netbeans IDE.

  1. Create a PHP web page.
    1. In the main menu, choose File > New File...
    2. In the Categories list, select Scripting. In the File Types list, choose PHP Web Page. Click Next.
    3. Accept default values by pressing Finish button.
    • EXPECTED RESULT: A new PHP web page is created and opened in the editor. Palette window on the right is opened and displays HTML and HTML Forms groups.
  2. DnD Table HTML component to HTML code.
    1. DnD Table HTML component to the editor, not into PHP code.
    2. In the "Insert Table" dialog, press OK.
    • EXPECTED RESULT: HTML tags added to DnD position. They correspond to visual representation of Table HTML component in the "Insert Table" dialog.
  3. DnD Table HTML component to PHP code.
    1. DnD Table HTML component to the editor, into PHP code.
    2. In the "Insert Table" dialog, press OK.
    • EXPECTED RESULT: HTML tags added to DnD position. They correspond to visual representation of Table HTML component in the "Insert Table" dialog. Editor lines are marked with red, and tooltip reads "Syntax error".
  4. DnD Table HTML component outside of editor view.
    1. DnD Table HTML component to the Projects window.
    2. DnD Table HTML component to the Navigator window.
    • EXPECTED RESULT: In both cases, mouse cursor indicates that DnD is impossible.
  5. DnD big Table HTML component to HTML code.
    1. DnD Table HTML component to the editor.
    2. In the "Insert Table" dialog, specify large values for rows and columns (like 1000), change values of other fields and press OK.
    • EXPECTED RESULT: After reasonable time (few seconds), HTML tags added to DnD position. They correspond to the visual representation of Table HTML component in the "Insert Table" dialog (with made changes).
  6. DnD Table HTML component with given parameters to HTML code.
    1. DnD Table HTML component to the editor.
    2. In the "Insert Table" dialog, change values of each field and press OK.
    • EXPECTED RESULT: HTML tags added to DnD position. They correspond to the visual representation of Table HTML component in the "Insert Table" dialog (with made changes).
  7. Add Table HTML component with given parameters to HTML code using double-click.
    1. Place the cursor to some position in editor.
    2. Double-click Table HTML component.
    3. In the "Insert Table" dialog, change values of each field and press OK.
    • EXPECTED RESULT: HTML tags added to DnD position. They correspond to the visual representation of Table HTML component in the "Insert Table" dialog (with made changes).
  8. Undo adding Table HTML component to HTML code.
    1. DnD Table HTML component to the editor.
    2. In the "Insert Table" dialog, change values of each field and press OK.
    3. In the main menu, choose Edit -> Undo.
    • EXPECTED RESULT: HTML tags added to DnD position, but reverted after Undo.
  9. DnD Form HTML component with given parameters to HTML code.
    1. DnD Form HTML component to the editor.
    2. In "Insert Table" dialog, change values of each field and press OK.
    • EXPECTED RESULT: HTML tags added to DnD position. They correspond to the visual representation of Form HTML component in the "Insert Form" dialog (with made changes).
  10. DnD other HTML components with given parameters to HTML code.
    1. Same as previous, for other components in HTML Palette.
    • EXPECTED RESULT: HTML tags added to DnD position. They correspond to the visual representation of an HTML component in the insert dialog (with made changes).



Test suite: Navigation

Purpose: Check Navigation in PHP code.
Prerequisites: a PHP project is created in the Netbeans IDE.

  1. Create a PHP web page.
    1. In the main menu, choose File -> New File...
    2. In the Categories list, select Scripting. In the File Types list, choose PHP Web Page. 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. Navigate to a specified line.
    1. In the editor popup menu, choose Navigation -> Line...
    2. Type a valid line number and press GoTo.
    • EXPECTED RESULT: The caret is moved to the specified line.
  3. Navigate to an invalid line.
    1. In the editor popup menu, choose Navigation -> Line...
    2. Type a line number which is greater that number of lines in the file and press GoTo.
    • EXPECTED RESULT: The caret is moved to the end of file.



Test suite: PHPUnit

Purpose: Check PHPUnit testing in PHP project.
Prerequisites: a PHP project is created in the Netbeans IDE, PHPUnit is installed. In IDE Options, remove (if any) path to Skeleton Generator

  1. Test PHPUnit groups.
    1. Create PHP project, in Projects window right click on the project node and select Properties
    2. In Categories section, select PHPUnit and check "Ask for test groups..."
    3. Create new class (you can use the code below) called Foo
class Foo {

    function plus($a, $b) {
        return $a + $b;
    }

    function minus($a, $b) {
        return $a - $b;
    }
    
    function toString(){
        return "Foo toString()";
    }

}
    1. In Projects window, right click on the Foo.php file and select Tools->Create PHPUnit tests (for the first time, you will have to specify target folder)
    2. New file called FooTest.php is created and opened in the editor
    3. There are 3 test functions: testMinus, testPlus, testToString
    4. To each of these function, add annotation @group with some different value (see the code below)

    /**
    * @group mathTests
    */
   public function testPlus() {
      ...
   }

    1. Run the FooTest.php
    • EXPECTED RESULT: You are asked to specify which test groups you want to run.


  1. Test PHPUnit tests per folder.
    1. Create PHP project, in Projects window right click on the project node and select Properties
    2. Create some new folders in Source Files and create new classes inside them
    3. Generate PHPUnit tests for these classes
    4. Expand Test Files node in Project window
    5. Right click on some folder and select Run Tests
    • EXPECTED RESULT: Only tests from given folder were performed.
  1. Test PHPUnit annotations.
    1. Create PHP class Calculator and copy&paste following code
class Calculator {
    /**
     * @assert (1, 2) == 3
     * @assert (10, 5) == 15
     */
    function add($a, $b) {
        return $a + $b;
    }    
}
    1. Right click on class file in project window and select Tools|Create PHPUnit tests
    2. Select test directory if it's not set yet
    • EXPECTED RESULT: New test file is created and (among others) it contains 2 methods: testAdd() and testAdd2(). Both are calling $this->assertEquals with valus specified by the PHP annotation in Calculator class

Test suite: PHPUnit Skeleton Generator

Prerequisites: Installed PHPUnit Skeleton Generator. In IDE Options, remove (if any) path to PHPUnit script and only path to Skeleton Generator should be set.

  1. Test PHPUnit with Skeleton Generator.
    1. Repeat steps from previous section
    • EXPECTED RESULT: Everything works the same way. There may be problem with missing require of the original class. If so add the require and try to run it again. Note that Skeleton Generator is supposed to only generate tests, to run them you have to use phpUnit again

Test suite: PHPUnit script per project

Prerequisites: Following steps are a bit of "ugly" but they allow to simply test if a custom script is really used if one does not have custom scripts. They are Linux specific but with minor updates (bat file used instead) they should work on Windows as well.

  1. Test custom PHPUnit scripts per project.
    1. Download another instance of PHPUnit from GitHub and extract it somewhere
    2. Rename phpunit.php to phpunit.sh
    3. open the file and add "Custom PHPUnit script" , so the start looks like
#!/usr/bin/env php
"Custom PHPUnit script";
<?php
    1. Right click on project in NetBeans (you can use project from previous test cases) and select Properties | PHPUnit
    2. Check "Use custom PHPUnit script" and add path to the modified phpunit.sh
    3. Click OK and run some test
    • EXPECTED RESULT: It should work fine. Check the Output window, there should be printed the "Custom PHPUnit script" msg - probably at the 1st line

Test suite: ApiGen

Prerequisites: Installed ApiGen

  1. Test ApiGen documentation
    1. Create PHP project, in Projects window right click on the project node and select Properties
    2. Select ApiGen
    3. Specify Target Directory
    4. Set Title to some custom value
    5. Check following items:
      1. Public (make Private uncheck!)
      2. add some value to Excludes (note it should be /probably/ absolute path with mask - asterisk etc.)
    6. Create some classes in and outside of the excluded path
    7. Add private & public methods to these classes
    8. Right click on project node in Project Window and select Generate documentation
    • EXPECTED RESULT: Information about the generation process is displayed in output window. When it's finished a new documentation is opened in browser window. Documentation for excluded classes is not created and private functions are not included in the documentation
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