Tag Archives: PHPUnit

Assert that a function gets called

When testing with phpunit, I want to assert a function call:
Given a Class:

Class TimeWrapper {
  public function time() {
    return time();
  }
}

And Its unittest:

Class TimeWrapperTest extends PHPUnit_FrameworkTestCase {
  public function testTime() {
    //Pseudocode as example 

Continuer la lecture

Tagged , | Laisser un commentaire

phpunit testing with ajax and zend framework

i have a problem with writing tests for my action that gets called by jquery via ajax. i don’t know how to catch the data that is being sent back to the view, by the action, so that i couldContinuer la lecture

Tagged , , , | Laisser un commentaire

SI + PHPUnit: How to assert existence of html elements within ajax response?

Should I extend the ControllerTestCase and create a custom method to handle this? What is the best way?… Continuer la lecture

Tagged , , | Laisser un commentaire

With PHPUnit, using a Data Provider, the last data set always shows “The test case was unexpectedly terminated

So I’m using PHPUnit for testing. Trying to use a DataProvider with one of my tests.

/**
 * Tests Events_Event->Events_Event()
 * @dataProvider provider
 */
public function testEvents_Event($Name, $param, $time) {
        //$this->assertInstanceOf("Events_Event", $this->Events_Event->Events_Event("test2", array()));
        $this->assertTrue(true);
    }

public static function provider()
    {
        

Continuer la lecture

Tagged , , | 1 Comment

PHPUnit undefined function mysql_connect()

When I try to connect to my MySQL database from PHP code all seems to be fine, all queries are executed successfully. Cependant, when the code is tested with unit tests in PHPUnit, I get the following fatal PHP error:… Continuer la lecture

Tagged , , | Laisser un commentaire

Netbeans “no tests executed

I have a php project with unit tests included. I use Netbeans for development and would like to have phpunit intergration in my IDE. If I run phpunit from the commandline, it is working. If I press Alt+F6 to runContinuer la lecture

Tagged , , , | 1 Comment

Failed opening 'SiteTest: Firefox.php' when running Yii Functional Test

Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion
... yiiframeworkYiiBase.php on line 418

Yii v1.1.10
PHPUnit v3.6.10
PHPUnit_Selenium v 1.2.6
I get this error when trying to run the example on the bookAgile Web Development with Yii 1.1 et Continuer la lecture

Tagged , , , | Laisser un commentaire

Using YAML Files as data provider in PHPUnit (CIUnit)

I am writing an application using the PHP CodeIgniter Framework. I am trying to test the application using CI_Unit, by extension PHPUnit. To test a model, I am trying to load a YAML data provider as defined in the PHPUnitContinuer la lecture

Tagged , , , | Laisser un commentaire

Comment utiliser les fonctionnalités de sélénium à partir de la classe Selenium2?

J'utilise PHPUnit et Selenium dans mon projet PHP.
J'ai suivi l'enseignement à: http://www.phpunit.de/manual/3.6/en/selenium.html. Actuellement, je suis en mesure de démarrer le serveur de sélénium et de ce que j'ai fait quelques classes de test s'étendant soit PHPUnit_Extensions_Selenium2TestCase ou PHPUnit_Extensions_SeleniumTestCase classe.
I’ve been using https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.phpContinuer la lecture

Tagged , , , | Laisser un commentaire

Comment puis-je tester un PHPUnit Controller_Plugin qui utilise une aide Redirector pour rediriger?

I can’t work this out.

    $this->_request->setBasePath('http://localhost/');
    $this->_request->setModuleKey('admin');
    $this->_request->setControllerKey('controller-page');
    $this->_request->setActionKey('index');

    $this->_sslRedirect->preDispatch($this->_request);

    $this->assertRedirectRegex('/https:/');

In my controller plugin preDispatch() may or may not do a redirect to SSL. This works in the browser, however I’m not able to write a test for it. Continuer la lecture

Tagged , , | Laisser un commentaire
13 pages