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 

Continue lendo

Tagged , | Deixe um comentário

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 couldContinue lendo

Tagged , , , | Deixe um comentário

IF + 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?… Continue lendo

Tagged , , | Deixe um comentário

Com PHPUnit, usando um provedor de dados, o último conjunto de dados sempre mostra "O caso de teste foi encerrado inesperadamente”

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

Continue lendo

Tagged , , | 1 Como

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

Tagged , , | Deixe um comentário

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 runContinue lendo

Tagged , , , | 1 Como

SiteTest abertura falhou ': Firefox.php' ao executar Yii Teste 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
Eu recebo este erro ao tentar executar o exemplo sobre o livro “Agile Web Development com Yii 1.1 e Continue lendo

Tagged , , , | Deixe um comentário

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 PHPUnitContinue lendo

Tagged , , , | Deixe um comentário

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

Tagged , , , | Deixe um comentário

Como posso testar um PHPUnit Controller_Plugin que usa um ajudante Redirector para redirecionar?

Eu não posso resolver isso.

    $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:/');

Na minha preDispatch plugin de controlador() pode ou não um redirecionamento para SSL. Isso funciona no navegador, porém eu não sou capaz de escrever um teste para ele. Continue lendo

Tagged , , | Deixe um comentário
13 páginas