phpunit

How might I integrate phpunit with Hudson CI?

Hello! We are looking at switching from phpundercontrol to Hudson (it looks to have some really cool features!) but I can't figure out how to get phpunit logs to show up. I have phpunit running fine in Hudson with ant, and --log-xml is putting a phpunit.xml in the appropriate builds/ folder for that build. But I can't figure out how to ...

Testing objects with dependencies in PHPUnit

For objects which compose another object as part of their implementation, what's the best way to write the unit test so only the principle object gets tested? Trivial example: class myObj { public function doSomethingWhichIsLogged() { // ... $logger = new logger('/tmp/log.txt'); $logger->info('some mess...

List of all PHPUnit assertions

Where can I find a list of all PHPUnit assertions? ...

Using PHPUnit in Zend Framework version 0.7

We have an application developed using Zend Framework preview version 0.7. Now I would like to write unit test its controllers / logic files. The logic mostly deals with the database and for database I am using my own wrapper. Did anybody try unit testing an application on top of Zend Framework version 0.7 ? ...

How do you install PHPUnit without using PEAR on Mac OS X 10.5?

I am having trouble installing PEAR, but I really only want to install PHPUnit. Does anyone have experience doing this? ...

Mocking methods used in Static Methods [PHPUnit]

I'm trying to stop a method that sends an email from actually sending the email and I think that mock objects (or some variant) are the way to go. Here is the situation: class UserModel { public static function resetPassword() { // Code to generate new password, etc, etc self::_sendMail($to, $body); return 1;...

Zend Framework: Getting started with Zend_Test

Has anyone had any success setting up Zend_Test? What was your method/approach and how do you run your tests/test suites? I already have PHPUnit installed and working. Now I'm trying to write some simple controller tests. The Zend Framework documentation assumes that autoloading is setup, which I haven't done. What method do you use to ...

How do you do Unit Testing With an App that Uses an ORM?

I've looked through the various questions on unit testing but can't find one that specifically answers this question. I've got several PHP classes that contain functions that look like this: static function _setSuspended($Suspended, $UserID) { try { $con = Propel::getConnection(); $c1 = new Crit...

Can I make PHPUnit fail if the code throws a notice?

It doesn't appear to do it by default, and I don't see any switch for it either. This is PHPUnit 2.3.5, and PHP 5.2.0-8. ...

Tagging unit-tests

I'm working on a PHP project with solid unit-tests coverage. I've noticed, that last time, I'm making very tricky manipulations with unit-tests Command-Line Test Runner' --filter command. Here is this command's explanation from official documentation: --filter Only runs tests whose name matches the given pattern. The ...

PHPUnit for command line integration tests

Recently, I've started to working on Email2SMS feature in our product. When I joined the project this component had zero code coverage by unit-tests. Legacy code. Since I started to working on it, I was using test-first approach. But code quality was very low. It was very hard to split it and tests small chunks by unit-tests, so I decid...

Class Zend_Test_PHPUnit_ControllerTestCase could not be found

When I run phpunit to test my controller there always comes the message: Class Zend_Test_PHPUnit_Controller_TestCase could not be found ... All require_once are executed and run without errors. My files: Test.php: <?php require_once 'bootstrap.php'; class indexTest extends Zend_Test_PHPUnit_ControllerTestCase { protected functi...

Will PHPUnit and XDebug work together?

I've been working on writing unit tests for my PHP code. PHPUnit is what I'm using for this. I have some classes that work great until... I throw XDebug into the mix. At that point, PHPUnit doesn't crash or anything, but setExpectedException never triggers. In fact, the code never goes beyond that point. Anyone run across this and ...

How to make several tests using MDB2 with PHPUnit DataBase?

I use PHPUnit DataBase to test some class using MDB2. All is well, since I encounter the second test, which returns an error: Caught exception: Object of class MDB2_Error could not be converted to string When I place the second test in place of the first one, the new first test is OK, but the second one returns the same error!...

How to integrate PHPUnit to a custom framework

I'd like to integrate PHPUnit to my framework. By this, I mean that I have to do some initializing in the beginning, like setting up autoloads, before I'd run the tests. I'd like to use the cli test runner, and if I understand correctly, I have to make a class, that has a static function suite(), which returns an instance of PHPUnit_Fra...

Is there a code covearge tool that works with manual testing?

In php, is there a tool that can generate a code coverage report without using automated unit test cases ? (basically not using phpunit or similar unit testing frameworks which do a good job generating the report but require unit testcases to be written in php!). Exactly what I am looking for, is a tool that would generate me a code co...

How do I write unit tests in PHP with a procedural codebase?

I'm mostly convinced of the benefits of unit testing, and I would like to start applying the concept to a large existing codebase written in PHP. Less than 10% of this code is object-oriented. I've looked at several unit testing frameworks (PHPUnit, SimpleTest, and phpt). However, I haven't found examples for any of these that test pr...

Is this piece of code secure - PHP && MySQL

<?php class test_class { public function __construct() { } public function doLogin($username,$password) { include("connection.php"); $query = "SELECT * FROM users WHERE username = '".mysql_escape_string($username)."' AND password = '".mysql_...

PHPUnit on a shared hosting plan?

PHPUnit works great, I love it actually, problem I'm having is that my hosting plan imposes a 30 second cap on the duration of a query. If PHPUnit tests take longer than that, the connection is closed by the server, and I never get to find out if all my tests passed or not. Is there an existing automatic way of running an arbitrarily l...

Why does PHPUnit insist on doing things the OO way?

At the risk of being flamed... what advantage does enforcing calls to methods rather than functions have in a context where the context is implicit. Considering that PHP's syntax is so ugly for calling methods why would PHPUnit's creators have enforced its usage? If the framework had set a global "currentTestCase" object and then trans...