2017 © Pedro Peláez
 

library symfony-test

Description of project symfony-test.

image

dayax/symfony-test

Description of project symfony-test.

  • Tuesday, July 23, 2013
  • by toni.munthi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 96 Installations
  • JavaScript
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Symfony Test

Symfony WebTestCase class with advanced assertion, (*1)

Build Status

  • Master: Build Status
  • Develop: Build Status

Installation

Include dayax/symfony test to your composer.json file., (*2)

// composer.json
"require-dev":{
    "dayax/symfony-test": "@dev"
}

Basic Usage

use dayax\symfony\test\WebTestCase;

class MyTestCase extends WebTestCase
{
    public function testIndexAction()
    {
        $this->open("/");
        $this->assertResponseStatus(200);
        $this->assertController("MyController");
        $this->assertAction("MyAction");
    }
}

Assertion List

$this->open("/complete_url_to_test");

// controller
$this->assertController("DemoController");
$this->assertController("demo");


// action
$this->assertAction("indexAction");
$this->assertAction("index");


//response status
$this->assertResponseStatus(200);
$this->assertNotResponseStatus(500);


// http header
$this->assertHasResponseHeader('Content-Type');
$this->assertNotHasResponseHeader('Unknown-Header');

$this->assertResponseHeaderContains("Content-Type","text/html; charset=UTF-8");
$this->assertNotResponseHeaderContains("Content-Type","text/json");

$this->assertResponseHeaderRegex('Content-Type','#charset#');
$this->assertResponseHeaderRegex('Content-Type','#text#');
$this->assertResponseHeaderRegex('Content-Type','#html#');

$this->assertNotResponseHeaderRegex('Content-Type','#json#');


// redirect
$this->open('/redirect');
$this->assertRedirect();

$this->open('/');
$this->assertNotRedirect();


// element
$this->open('/');
$this->assertHasElement('h1');
$this->assertElementContains('h1', 'Header h1');
$this->assertElementContentRegex('h1', '#Header#');
$this->assertNotElementContentRegex('h1', '#foo#');

Form Helper

$this->open("/new_data");

$form = $this->getForm("Save");
$form = $this->getForm("#form_html_id");
$form = $this->getForm("form_name");
$form->setValues(array(
    "form[firstname]"=>"Hello World",
));
$this->submitForm($form);

$this->assertResponseStatus(200);
$this->assertElementContains(".flash","Form Saved!");

The Versions

23/07 2013
11/07 2013

dev-develop

dev-develop

Description of project symfony-test.

  Sources   Download

MIT

The Requires

 

The Development Requires