Calculator (PHPUnit)
NetBeans PHP Sample Application
What is Calculator?
Calculator is a simple calculator that supports basic arithmetical operations. This PHP application is created to highlight PHP features supported by NetBeans IDE.
This sample is not intented to be used in a production environment without any changes.
This sample demonstrates the following features:
- unit testing using PHPUnit
- creating unit tests using PHPUnit_SkeletonGenerator
Requirements
Follow these before you run the sample:- Install NetBeans IDE with PHP support
- Install and configure PHP Runtime
- Install and configure PHPUnit
- Install and configure PHPUnit_SkeletonGenerator
What is included?
- NetBeans PHP Application Project
Before the start
- If you want to try the sample out, follow Getting Started guidelines.
- In case of you want to try debugging features of the NetBeans IDE, follow the Debugging guidelines.
Getting Started
- Firstly, create a unit test for Calculator class - open it in the editor and select Tools > Create Tests.
-
Secondly, add
require_once __DIR__ . '/../src/Calculator.php';
line to the top of the file, just after <? php. - Finally, test the project. Right-click the project node and select Test. IDE will inform you about the test results (window with test results can be opened manually).
- Play futher with the sample :)
Debugging
These steps should enable you the debugging option at the sample project,
if you already have PHP debugger
installed and configured.
For demonstrating the PHP debugger in NetBeans, try the following:
- Open source class Calculator.php or generated CalculatorTest.php in the editor.
- Put breakpoint on some line with PHP code.
- To debug, right-click CalculatorTest.php and select Debug.