hi all
currently im writing a test for a report function
the more functionality the project gets the more
reports need to be written
in my case reports get a few 'search' paramters and limitations like
number of rows or such
now my question:
anyone knows how to generate test cases automatically for a function
which has a well known se...
I'm working with Symfony + Doctrine + PHPUnit, with NetBeans IDE. Here' my current approach to unit testing.
setUp() function loads the test fixtures from .yml files
tearDown() function delete all data from models. this is done by looping through an array of all my models' names to something like Doctrine_Query::delete($modelName)->exe...
hi
i have old code which didnt use TDD
now i want to write a test for a function which looks like this
function somefunction($someargs){
// do a few checks on $someargs
$database = new DB_PG();
$result = $database->select($query);
// do some changes on result
return $result;
}
since im not much expirienced with ph...
I have a PHPUnit Test class that I'd like to be ignored from a test run. I know I can do it by renaming it so that it doesn't contain the word Test in its filename, but I'd rather not do that since it muddies up the source control waters more than I'd like.
Does anyone have a suggestion?
...
I have script called Script.php and tests for it in Tests/Script.php, but when I run phpunit Tests it does not execute any tests in my test file. How do I run all my tests with phpunit?
PHPUnit 3.3.17, PHP 5.2.6-3ubuntu4.2, latest Ubuntu
Output:
$ phpunit Tests
PHPUnit 3.3.17 by Sebastian Bergmann.
Time: 0 seconds
OK (0 tests, 0 asser...
I want to add a suite of Selenium tests as part of a global PHPUnit test suite for an application. I have hooked the suite of Selenium tests into the global AllTests.php file and everything runs fine whilst the Selenium server is running.
However, I would like the script to skip the Selnium tests if the Selenium server isn't running so...
While trying to get a legacy codebase under test, I've come across an object that does the following:
class Foo
{
public function __construct($someargs)
{
$this->bar = new Bar();
// [lots more code]
}
}
Bar in this instance has a constructor that does some Bad Things e.g. connecting to a database. I'm tryi...
the install instructions for phpunit are running this:
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
the first one goes okay , on the second I get an error:
phpunit/PHPUnit requires PEAR Installer (version >= 1.8.1), installed version is 1.7.2
phpunit/PHPUnit can optionally use package "pear/Image_GraphViz" (vers...
I want to test my controller which works on subdomain www.username.domain.com
The problem is when I dispatch in ControllerTestCase it throws Zend_Controller_Dispatcher_Exception
routes.php:
$userRouter = new Zend_Controller_Router_Route_Hostname(':user.domain.com'));
$router->addRoute('user', $userRouter->chain(new Zend_Controller_...
Given the following class:
<?php
class Example {
private $Other;
public function __construct ($Other)
{
$this->Other = $Other;
}
public function query ()
{
$params = array(
'key1' => 'Value 1'
, 'key2' => 'Value 2'
);
$this->Other->post($params);
...
I want to create a test table that is empty. Using the Example from digitalsandwich, I want something like:
require_once 'PHPUnit/Extensions/Database/TestCase.php';
class BankAccountDBTest extends PHPUnit_Extensions_Database_TestCase
{
protected $pdo;
public function __construct()
{
$this->pdo = new PDO('sqlite::me...
We set a global in our prepend file used to form the path for our require_once calls. For example:
require_once($GLOBALS['root'].'/library/particleboard/JsonUtil.php');
Problem is, when I run PHPUnit's skeleton test builder, the prepend file is not run, so the global is never set. When I run
cd /company/trunk/queue/process; phpunit...
class TestClass extends PHPUnit_Framework_TestCase {
function testSomething() {
$class = new Class();
$this->assertTrue($class->someFunc(1));
}
function testSomethingAgain() {
$class = new Class();
$this->assertFalse($class->someFunc(0));
}
}
Hi, do I really have to create $class for every test function I create? Or is ...
I recently installed phpunit on my server via the pear installer.
When I go to run a test I get the following error:
PHP Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 44
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Filter.php' (i...
On NetBeans 6.7.1 with PHPUnit 3.4.1, If I try and run the test I setup in NetBeans it errors out and can't execute the test, here is the output:
PHPUnit 3.4.1 by Sebastian Bergmann.
The --log-xml option is deprecated, please use --log-junit instead.
Argument #1 of PHPUnit_Util_Fileloader:checkAndLoad() is no existing file
The test ...
Before installing PHPUnit on my Ubuntu machine, I thought I had zf.sh all set up correctly. I was able to create a new project without any issues. Now, since installing PHPUnit, everything is not working right.
When I try to create a test project, I get this:
Fatal error: Cannot redeclare class PHPUnit_Framework_TestSuite_DataProvider ...
I would like to downgrade my installation of PHPUnit 3.4 to 3.3. I'm just not sure how to do it.
How do I install version 3.3 of PHPUnit on Ubuntu using PEAR?
...
I'm using PHPUnit and my traditional approach is to use mock objects and methods that get called by the methods I'm testing. The mock objects are told what to expect as input by the unit test. The problem is that part of the input supplied to the mock objects are being randomly generated by the methods being tested (and the unit test has...
When testing for exceptions with PHPUnit, what is the best way to require that every statement or assertion must throw an exception in order for the test to pass?
I basically want to do something like this:
public function testExceptions()
{
$this->setExpectedException('Exception');
foo(-1); //throws exception
foo(1); //d...
Im using phpunit & phpundercontrol to run the RC Selenium on every build.
...