Все вопросы: [phpunit]

74 вопросов

похожие теги:
3
голосов
3ответов
2998 просмотров

How do I fix my NetBeans + PHPUnit integration?

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:chec...

79
голосов
17ответов
60993 просмотров

phpunit require_once() error

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 openi...

12
голосов
1ответов
7902 просмотров

How to setup or construct a PHP Unit test

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 ...

3
голосов
2ответов
1107 просмотров

How to set a global before PHPUnit's skeleton-test is run

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...

10
голосов
1ответов
3405 просмотров

PHPUnit Database Extension - How to have an empty dataset?

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() ...

38
голосов
5ответов
33501 просмотров

PHPUnit: Verifying that array has a key with given value

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' ...

2
голосов
2ответов
1836 просмотров

How to dispatch url with subdomain in Zend PHPUnit Controller test?

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('u...

7
голосов
3ответов
10450 просмотров

can't install PHPUnit through pear

Possible Duplicate: Installing PHPUnit via PEAR 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...

2
голосов
1ответов
1798 просмотров

Removing a dependency in a constructor using PHPunit

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 Th...

4
голосов
3ответов
2327 просмотров

How to skip tests in PHPUnit if Selenium server is not running?

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 tes...

46
голосов
5ответов
47880 просмотров

How do I run all my PHPUnit tests?

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 Berg...

6
голосов
5ответов
8019 просмотров

Making PHPUnit ignore things?

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?

0
голосов
1ответов
545 просмотров

mock newly created instance?

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; ...

1
голосов
3ответов
3842 просмотров

unit testing with symfony + doctrine + PHPUnit

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 li...

2
голосов
4ответов
3581 просмотров

automated test generation?

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 ...

4
голосов
5ответов
5419 просмотров

phpunit (install) error

i have tried installing phpunit the install itself seems fine. i can run "phpunit" but when i try to run a test "phpunit test.php" i get '""C:\Program' is not recognized as an internal or external command, operable program or batch file. PHPUnit 3.3.17 by Sebastian Bergmann. .. Time: 0 seco...

1
голосов
1ответов
308 просмотров

Can Selenium RC tests written in Python be integrated into PHPUnit?

I'm working on large project in PHP and I'm running phpundercontrol with PHPUnit for my unit tests. I would like to use Selenium RC for running acceptance tests. Unfortunately the only person I have left to write tests only knows Python. Can Selenium tests written in Python be integrated into P...

38
голосов
6ответов
15434 просмотров

How do you use PHPUnit to test a function if that function is supposed to kill PHP?

Essentially I have a method of a class called killProgram, which is intended to send a hTTP redirect and then kill PHP. How am I supposed to test this? When I run phpunit it doesn't return anything for that test, and closes completely. Right now I'm considering having the killProgram function t...

9
голосов
4ответов
5034 просмотров

TeamCity and PHP

We are considering TeamCity for continuous integration but have projects in both Rails (Rake tests) and PHP (PHPUnit tests). I'm a bit new to CI - Has anyone setup TeamCity for PHP projects? If so, is it straight-forward? Thanks, Chad

9
голосов
1ответов
2541 просмотров

Creating mock Objects in PHP unit

I've searched but can't quite find what I'm looking for and the manual isn't much help in this respect. I'm fairly new to unit testing, so not sure if I'm on the right track at all. Anyway, onto the question. I have a class: <?php class testClass { public function doSomething($arr...

7
голосов
3ответов
6923 просмотров

PHPUnit getMock() with namespace

My quest of starting to use namespaces in PHP keeps continuing. This time PHPUnit gives me problems. My setup() method is like this: $test = new \MyNamespace\NonPersistentStorage(); // works $mock = $this->getMock('\MyNamespace\NonPersistentStorage'); // doesn't work The getMock() method on...

4
голосов
1ответов
3818 просмотров

Zend Framework: How to unit test a model using Zend_Service_Twitter

I have been getting into Unit Testing with Zend Framework. I am getting used to the other things it provide but I am having a hard time understanding Mock Objects. For this example, I am trying to use a Mock Object to test out my model. <?php class Twitter_Model_Twitter { private $_twit...

4
голосов
2ответов
1777 просмотров

Which unit testing framework do you use for Symfony?

Which unit testing framework do you use for Symfony? Lime or PHPUnit? What are the pros and cons of using them?

12
голосов
5ответов
9707 просмотров

test the return value of a method that triggers an error with PHPUnit

This question is specific to using PHPUnit. PHPUnit automatically converts php errors to exceptions. Is there a way to test the return value of a method that happens to trigger a php error (either built-in errors or user generated errors via trigger_error)? Example of code to test: function lo...

2
голосов
3ответов
1338 просмотров

Selenium RC Tests + Unit Tests using PHPUnit throws a Seg Fault

So I have a set of unit/integration tests and a set of selenium rc tests as part of my suite. When I run them together using PHPUnit I get a Segmentation fault error message at the very end of the run when, during normal operation, it starts to generate log files. The interesting part is, if I ru...

31
голосов
3ответов
21356 просмотров

Equivalent of SimpleTest "partial mocks" in PHPUnit?

I'm trying to migrate a bunch of tests from SimpleTest to PHPUnit and I was wondering if there is an equivalent for SimpleTest's partial mocks. Update: I can't seem to find anything in the docs which suggests that this feature is available, but it occurred to me that I could just use a subclass....

6
голосов
5ответов
2902 просмотров

Как провести модульное тестирование Zend_Form, включающего элемент формы CSRF?

Я использую скрытый хэш-элемент CSRF с Zend_Form и пытаюсь выполнить модульное тестирование входа в систему, но не знаю, как написать модульный тест для включения этого элемента. Посмотрел документацию и прочитал столько руководств, сколько смог найти. Я даже обманул их всех , но об этом никто ...

0
голосов
1ответов
401 просмотров

Отладчик PHP с модульным тестированием

Я получил отладчик Zend для работы с PDT 2.1. В проекте, над которым я работаю, я провожу модульное тестирование с помощью PHPUnit, но при запуске отладчика не будет обнаружена ни одна из точек останова, пока я не создам несколько экземпляров тестового класса, а затем запущу тесты вручную. Эт...

1
голосов
1ответов
254 просмотров

Как реорганизовать этот конструктор, чтобы его можно было тестировать?

У меня есть класс, который является контейнером для множества объектов модуля. Прямо сейчас контейнер принимает массив путей к файлам, затем включает файлы и создает экземпляры модулей class module { function execute(); } class container { public $Name; public $Modules; publ...

1
голосов
4ответов
6105 просмотров

Правильно установите PHPUnit и Pear на OSX Leopard

Я установил грушу, используя это руководство http://t-machine.org/index.php/2008/12/28/how-to-install-pear-on-os-x-105/ В /etc/php.ini мой include_path = ".: / usr / local / PEAR" PHPUnit устанавливается в / usr / local / PEAR / PHPUnit с помощью sudo pear install phpunit / PHPUni...