I am new to PHPUnit and I want to use it with Netbeans. I already know that there is documentation for PHPUnit, but documentation on how to use it with Netbeans is scarce. It would be great to see some working examples. I studied so well.
So, from the Netbeans website they give this example, and then you should Right Click File Create PHPUnit Tests automatically generate PHPUnit classes:
class Calculator{ public function add($a, $b){ return $a + $b; } }
However, I am reading another PHP book, and in it they do it like this.
class Session { public function __construct($one, $two){} public function login(){} public function isLoggedIn() {return null;} } require_once("PHPUnit/Autoload.php"); class TestSession extends PHPUnit_Framework_TestCase { private $_session; function setUp() { $dsn = array( 'phptype' => "pgsql", 'hostspec' => "localhost", 'database' => "widgetworld", 'username' => "wuser", 'password' => "foobar" ); $this->_session = new Session($dsn, true); } function testValidLogin() { $this->_session->login("ed", "12345"); $this->assertEquals(true, $this->_session->isLoggedIn()); } function testInvalidLogin() { $this->_session->login("ed", "54321");
Could you help me understand how to do PHPUnit tests in Netbeans by converting the above example? Thanks
I don't know, but would something like this in Netbeans be right ?:
class Session { public function __construct($one, $two) {} public function login() { } public function isLoggedIn() {return null;} }
source share