Archivo de la etiqueta: 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 

Sigue leyendo

Etiquetado , | Deja un comentario

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 couldSigue leyendo

Etiquetado , , , | Deja un comentario

ZF + 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?… Sigue leyendo

Etiquetado , , | Deja un comentario

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

Sigue leyendo

Etiquetado , , | 1 comentario

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. Sin embargo, when the code is tested with unit tests in PHPUnit, I get the following fatal PHP error:… Sigue leyendo

Etiquetado , , | Deja un comentario

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 runSigue leyendo

Etiquetado , , , | 1 comentario

SiteTest apertura Error ': Firefox.php' cuando se ejecuta prueba de Yii funcional

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
Me sale este error al intentar ejecutar el en el libro “Agile Desarrollo Web con Yii 1.1 y Sigue leyendo

Etiquetado , , , | Deja un comentario

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 PHPUnitSigue leyendo

Etiquetado , , , | Deja un comentario

How to use Selenium features from Selenium2 class?

I’m using PHPUnit and Selenium in my PHP project.
I have been following instruction at: http://www.phpunit.de/manual/3.6/en/selenium.html. Currently I am able to start Selenium server and I’ve done few test classes extending either PHPUnit_Extensions_Selenium2TestCase or PHPUnit_Extensions_SeleniumTestCase class.
I’ve been using https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.phpSigue leyendo

Etiquetado , , , | Deja un comentario

How can I PHPUnit test a Controller_Plugin that uses a Redirector helper to redirect?

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

Etiquetado , , | Deja un comentario
13 páginas