unit-testingtestingsymfony1symfony-1.4lime-unittest

How to run lime test in Symfony plugin?


I have a plugin in Symfony 1.4 and I have created for him some tests put them in ROOT/myPlugin/test/unit/MyTest.php

The plugin was generated with sfTaskExtraPlugin.

The content of MyTest.php is:

<?php

require_once dirname(__FILE__).'/../bootstrap/unit.php';
$t = new lime_test(1); 
$r = new My();
$v = $r->getSomething(2);
$t->is($v, true);         

?>

When I run ./symfony test:unit Rights the response is >> test no tests found

However if I copy MyTest.php file in ROOT/test/unit the command ./symfony test:unit Rights is working.

The plugin is enabled in ProjectConfiguration.class.php

Why the test are not working if I write them in plugin?


Solution

  • Plugin's tests are not run by default (for good reason - why would you want to run tests for a 3rd party plugin every time you want to test your app?).

    Edit your ProjectConfiguration like this:

    class ProjectConfiguration extends sfProjectConfiguration
    {
      public function setup()
      {
        $this->enablePlugins('myPlugin');
      }
    
      public function setupPlugins()
      {
        $this->pluginConfigurations['myPlugin']->connectTests();
      }
    }
    

    this will run the given plugin's tests along with the project's. Taken from symfony.com, about testing plugins.