Releases for sf 1.0
| Version |
License |
API |
Released |
|
0.9.0beta
|
PHP License |
0.9.0beta
|
13/09/2007 |
Copyright (c) 2007 Rob Rosenbaum
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
We first need to find the lead developer of this plugin before you can contribute to it.
If you are the lead developer of this plugin, please send an email to fabien.potencier [[at]] symfony-project.com with your username.
Changelog for release 0.9.0 - 13/09/2007
Not available
Other releases
Release 0.9.0 - 13/09/2007
Not available
Installation for sf 1.0
php symfony plugin-install http://plugins.symfony-project.org/sfPropelTestPlugin
PEAR
Download the PEAR package
sfPropelTestPlugin plugin
The sfPropelTestPlugin is a symfony plugin for quickly creating unit tests that require database interaction.
Features
- Uses a separate test database
- Automatically reloads test data before each group of tests
- Easy to install and use
Installation
Uncompress the archive
cd /path/to/your/symfony/project/plugins/
tar -xzf /path/to/sfPropelTestPlugin-1.0.tgz
Create a database for testing. To load the schema, just use your existing sql
mysql -u username -p myApp_test < data/sql/lib.model.schema.sql
Add the test database to databases.yml
all:
propel:
class: sfPropelDatabase
param:
phptype: mysql
host: localhost
database: myApp
username: myUser
password: myPasswd
test:
propel:
class: sfPropelDatabase
param:
phptype: mysql
host: localhost
database: myApp_test
username: myUser
password: myPasswd
Create one or more YAML data files for testing, and put them in tests/fixtures. These files are just like the test data files you might put in data/fixtures, except they will be reloaded into the test database at the beginning of every test method. (see "Usage")
Create your unit tests! You will need to include the following two lines at the top of your unit tests, (replacing 'myApp' with, of course, the name of your app):
define('SF_APP', 'myApp');
include(dirname(__FILE__).'/../../plugins/sfPropelTestPlugin/bootstrap/propel-unit.php');
Usage
Unit tests that use this plugin are almost identical in form and function to those in Ruby on Rails. A unit test file will look like this:
[php]
define('SF_APP', 'myApp');
include(dirname(__FILE__).'/../../plugins/sfPropelTestPlugin/bootstrap/propel-unit.php');
class myUnitTest extends sfPropelTest
{
public function test_user()
{
$user = new User();
$user->setFirstName('Joe');
$user->setLastName('Smith');
$user->setUsername('bobbyjoe');
$user->save();
$joe = UserPeer::getBy(UserPeer::USERNAME, 'bobbyjoe');
$this->ok($joe, 'Joe exists!');
}
public function test_dataDelete()
{
$joe = UserPeer::getBy(UserPeer::USERNAME, 'bobbyjoe');
$this->ok(!$joe, 'Joe no longer exists.');
}
}
$test = new myUnitTest();
$test->execute();
Each unit test is a class that extends sfPropelTest (which itself extends lime_test). If you are familiar with Rails, the above should look familiar. If not, here is the quick summary:
For every test case, you write a class; every class method that begins with "test_" gets called in turn; before each test method is called, the data is reloaded and the setup() method is called (if you defined one); after each test method is called, the teardown() method is called (if you defined one).
All the test functions available from line are methods of your class, so call them with $this.