<?php include dirname(__FILE__) . '/../bootstrap/Doctrine.php'; include dirname(__FILE__) . '/../fixtures/fixtures.php'; $t = new lime_test(21, new lime_output_color()); include dirname(__FILE__) . '/../fixtures/fixtures.php'; // Doctrine::loadData(sfConfig::get('sf_test_dir').'/fixtures'); $t->comment('testing plugin'); $p = new SymfonyPlugin(); $p['title'] = 'sfThisIsATestPlugin'; $p->save(); $t->is($p->getIndexableTitle(), 'sf this is a test', 'correct string for Lucene indexing'); $t->is($p->isRegistered(), false, 'plugin is not registered'); $t->is($p['symfony_plugin_homepage'], 'http://www.symfony-project.org/plugins/sfThisIsATestPlugin', 'plugin URL matches Symfony Plugins URL'); $t->is($p['repository'], 'http://svn.symfony-project.com/plugins/sfThisIsATestPlugin', 'default repository set'); $t->is($p['num_votes'], 0, 'no votes'); $t->is($p['rating'], 0, 'no rating'); $t->comment('add a rating of 5'); $p->addRating(5); $t->is($p['num_votes'], 1, 'number of votes is now 1'); $t->is($p['rating'], 5, 'rating is now 5'); $t->comment('add a rating of 3'); $p->addRating(3); $t->is($p['num_votes'], 2, 'number of votes is now 2'); $t->is($p['rating'], 4, 'rating is now 4'); $t->comment('add another rating of 3'); $p->addRating(3); $t->is($p['num_votes'], 3, 'number of votes is now 3'); $t->is($p['rating'], 3, '3.667 rating rounds down to 3'); $t->comment('add another rating of 4'); $p->addRating(4);
<?php Doctrine::getTable('PluginAuthor')->findAll()->delete(); Doctrine::getTable('SymfonyPlugin')->findAll()->delete(); Doctrine::getTable('CommunityList')->findAll()->delete(); Doctrine::getTable('sfGuardUser')->findAll()->delete(); $user = new sfGuardUser(); $user['username'] = '******'; $user['password'] = '******'; $user->save(); $plugin1 = new SymfonyPlugin(); $plugin1->fromArray(array('title' => 'sfFooPlugin')); $plugin1->save(); $plugin2 = new SymfonyPlugin(); $plugin2->fromArray(array('title' => 'sfBarPlugin')); $plugin2->save(); $plugin3 = new SymfonyPlugin(); $plugin3->fromArray(array('title' => 'sfChunkyPlugin')); $plugin3->save(); $plugin4 = new SymfonyPlugin(); $plugin4->fromArray(array('title' => 'sfBaconPlugin')); $plugin4->save(); $plugin5 = new SymfonyPlugin(); $plugin5->fromArray(array('title' => 'sfBetterPlugin', 'Ratings' => array(array('rating' => '5'), array('rating' => '5')))); $plugin5->save(); $plugin6 = new SymfonyPlugin(); $plugin6->fromArray(array('title' => 'sfWorsePlugin', 'Ratings' => array(array('rating' => '1'), array('rating' => '1'), array('rating' => '1')))); $plugin6->save();