Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

KnpLabs/knpTestPlugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

knpTestPlugin

Enable the plugin.

Create your base test class which should inherit knpFunctionalTest or knpShortcutFunctionalTest (provides convenience shortcuts).

Requires a getDoctrineConnection() method.

<?php

class adminFunctionalTest extends knpLimeFunctionalTest
{

  protected function getDoctrineConnection()
  {
    return Doctrine::getTable('Product')->getConnection(); 
  }

  protected function login($login = 'knplabs', $password = 'loremipsum')
  {
    // Some logic here
  }
}

Add these lines to your /test/bootstrap/functional.php.

require_once($configuration->getRootDir(). '/plugins/knpTestPlugin/knpFunctionalTest.class.php');
// If adminFunctionalTest is your base test class:
require_once(dirname(__FILE__) . '/adminFunctionalTest.class.php');

Then create a test class for your functional tests; every test inside should use test* as method name. Each of these methods will be called inside a Doctrine transaction so that the DB is not changed.

<?php

include(dirname(__FILE__).'/../../bootstrap/functional.php');

class productActionsTest extends adminFunctionalTest
{
  public function testCreateSector()
  {
    $this
    ->get('/sector/new')
    ->setField('name', 'knplabs')
    ->click('Go on')
    ->with('response')->begin()
      ->matches("Right")
    ->end()
    ;
  }

  public function testOtherThing()
  {
    …
  }
}

$test = new productActionsTest();
$test->run();

About

[UNMAINTAINED] Base class for symfony functional tests. Uses DB transactions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages