/** * * @param lime_test $t * @return PHPGit_Repository the git repo */ function _createTmpGitRepo(lime_test $t, array $options = array()) { $repoDir = sys_get_temp_dir() . '/php-git-repo/' . uniqid(); $t->ok(!is_dir($repoDir . '/.git'), $repoDir . ' is not a Git repo'); try { new PHPGit_Repository($repoDir, true, $options); $t->fail($repoDir . ' is not a valid git repository'); } catch (InvalidArgumentException $e) { $t->pass($repoDir . ' is not a valid git repository'); } $t->comment('Create Git repo'); exec('git init ' . escapeshellarg($repoDir)); $t->ok(is_dir($repoDir . '/.git'), $repoDir . ' is a Git repo'); $repo = new PHPGit_Repository($repoDir, true, $options); $t->isa_ok($repo, 'PHPGit_Repository', $repoDir . ' is a valid git repo'); $originalRepoDir = dirname(__FILE__) . '/repo'; foreach (array('README.markdown', 'index.php') as $file) { copy($originalRepoDir . '/' . $file, $repoDir . '/' . $file); } return $repo; }
$testItems = 0; foreach ($reflect->getMethods() as $reflectmethod) { $params = ''; foreach ($reflectmethod->getParameters() as $key => $row) { if ($params != '') { $params .= ', '; } $params .= '$' . $row->name; } $testItems++; $methods[$reflectmethod->getName()] = $params; } //To change the case only the first letter of each word, TIA $className = ucwords($className); $t->diag("class {$className}"); $t->isa_ok($obj, "wsBase", "class {$className} created"); //$t->is( count($methods) , 26, "class $className have " . 26 . ' methods.' ); $t->is(count($methods), 28, "class {$className} have " . 28 . ' methods.'); //checking method '__construct' $t->can_ok($obj, '__construct', '__construct() is callable'); //$result = $obj->__construct ( ); //$t->isa_ok( $result, 'NULL', 'call to method __construct '); $t->todo("call to method __construct using "); //checking method 'login' $t->can_ok($obj, 'login', 'login() is callable'); //$result = $obj->login ( $userid, $password); //$t->isa_ok( $result, 'NULL', 'call to method login '); $t->todo("call to method login using {$userid}, {$password} "); //checking method 'processList' $t->can_ok($obj, 'processList', 'processList() is callable'); //$result = $obj->processList ( );
require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot('front'); clearstatcache(true); $isSqlite = Doctrine_Manager::getInstance()->getConnection('doctrine') instanceof Doctrine_Connection_Sqlite; $t = new lime_test(16 + ($isSqlite ? 0 : 1) + 3 * count($helper->get('i18n')->getCultures())); $user = $helper->get('user'); try { $index = $helper->get('search_index'); $t->fail('Can\'t create index without dir'); } catch (dmSearchIndexException $e) { $t->pass('Can\'t create index without dir'); } $engine = $helper->get('search_engine'); $t->isa_ok($engine, 'dmSearchEngine', 'Got a dmSearchEngine instance'); $expected = dmProject::rootify(dmArray::get($helper->get('service_container')->getParameter('search_engine.options'), 'dir')); $t->is($engine->getFullPath(), $expected, 'Current engine full path is ' . $expected); $t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir'); $engine->setDir('cache/testIndex'); foreach ($helper->get('i18n')->getCultures() as $culture) { $user->setCulture($culture); $currentIndex = $engine->getCurrentIndex(); $t->is($currentIndex->getName(), 'dm_page_' . $culture, 'Current index name is ' . $currentIndex->getName()); $t->is($currentIndex->getCulture(), $culture, 'Current index culture is ' . $culture); $t->is($currentIndex->getFullPath(), dmProject::rootify('cache/testIndex/' . $currentIndex->getName()), 'Current index full path is ' . $currentIndex->getFullPath()); } $user->setCulture(sfConfig::get('sf_default_culture')); $currentIndex = $engine->getCurrentIndex(); $t->isa_ok($currentIndex->getLuceneIndex(), 'Zend_Search_Lucene_Proxy', 'The current index is instanceof Zend_Search_Lucene_Proxy'); $t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
* @package symfony.plugins * @subpackage sfDoctrine * @author Pavel Kunc * @author Olivier Verdier <*****@*****.**> * @version SVN: $Id: sfDoctrineColumnTest.php 3438 2007-02-10 15:31:31Z chtito $ */ //We need bootStrap require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; //TODO: add planned tests $t = new lime_test(null, new lime_output_color()); $colName = 'TestColumn'; $column = new sfDoctrineColumnSchema($colName); // ->__construct(), special case without variable parameters $t->diag('->__constuct()'); $t->is($column->getName(), $colName, '->__construct() takes first parameter as Column name'); $t->isa_ok($column->getColumnInfo(), 'sfParameterHolder', '->__construct() sets column infor to sfParameterHolder'); //Construct sets default values, nothing passed $props = $column->getProperties(); $t->is($props['type'], 'string', "->__construct() default type is 'string'"); $t->is($props['name'], $colName, "->__construct() sets property name to column name"); $column = new sfDoctrineColumnSchema($colName, array('foreignClass' => 'other')); $props = $column->getProperties(); $t->is($props['type'], 'integer', 'default foreign key type is integer'); $t->diag('constraints'); $column = new sfDoctrineColumnSchema($colName, array('enum' => true, 'noconstraint' => true)); $props = $column->getProperties(); $t->is($props['enum'], true, 'constraints are stored properly'); $t->ok(!isset($props['notaconstraint']), 'false constraints are not stored'); $t->diag('short syntax'); $type = 'string'; $size = 10;
<?php require_once dirname(__FILE__) . '/../../vendor/lime/lime.php'; require_once dirname(__FILE__) . '/../../lib/TwitterBot.class.php'; $t = new lime_test(12, new lime_output_color()); // Sample data $xmlTweet = DOMDocument::load(dirname(__FILE__) . '/xml/server/statuses/show/2043091669.xml'); // createFromXml() $t->diag('createFromXML()'); try { $tweet = Tweet::createFromXML($xmlTweet); $t->pass('createFromXml() creates a Tweet instance from an XML element without throwing an exception'); } catch (Exception $e) { $t->fail('createFromXml() creates a Tweet instance from an XML element without throwing an exception'); $t->diag(sprintf(' %s: %s', get_class($e), $e->getMessage())); } $t->isa_ok($tweet, 'Tweet', 'createFromXML() creates a Tweet instance'); $t->is($tweet->created_at, 'Fri Jun 05 14:21:23 +0000 2009', 'createFromXML() can retrieve created_at property'); $t->is($tweet->id, 2043091669, 'createFromXML() can retrieve id property'); $t->is($tweet->text, 'foo', 'createFromXML() can retrieve text property'); $t->is($tweet->source, '<a href="http://www.nambu.com">Nambu</a>', 'createFromXML() can retrieve source property'); $t->is($tweet->truncated, false, 'createFromXML() can retrieve truncated property'); $t->is($tweet->in_reply_to_status_id, 2043033723, 'createFromXML() can retrieve in_reply_to_status_id property'); $t->is($tweet->in_reply_to_user_id, 14587759, 'createFromXML() can retrieve in_reply_to_user_id property'); $t->is($tweet->favorited, false, 'createFromXML() can retrieve favorited property'); $t->is($tweet->in_reply_to_screen_name, 'fvsch', 'createFromXML() can retrieve in_reply_to_screen_name property'); $t->isa_ok($tweet->user, 'TwitterUser', 'createFromXML() imports TwitterUser');
<?php include_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; include_once dirname(__FILE__) . '/../../../bootstrap/database.php'; sfContext::createInstance($configuration); sfDoctrineRecord::setDefaultCulture('ja_JP'); $t = new lime_test(5, new lime_output_color()); //------------------------------------------------------------ $t->diag('NotificationMailTable'); $t->diag('NotificationMailTable::getDisabledNotificationNames()'); $result = Doctrine::getTable('NotificationMail')->getDisabledNotificationNames(); $t->is($result, array('name2')); $t->diag('NotificationMailTable::fetchTemplate()'); $result = Doctrine::getTable('NotificationMail')->fetchTemplate('name1'); $t->isa_ok($result, 'NotificationMail'); $result = Doctrine::getTable('NotificationMail')->fetchTemplate('pc_changeMailAddress'); $t->isa_ok($result, 'NotificationMail'); $result = Doctrine::getTable('NotificationMail')->fetchTemplate('aaaaa'); $t->cmp_ok(false, '===', $result); $t->diag('NotificationMailTable::getConfigs()'); $result = Doctrine::getTable('NotificationMail')->getConfigs(); $t->isa_ok($result, 'array');
$databaseManager = new sfDatabaseManager($configuration); $table = Doctrine_Core::getTable('sfGuardUser'); // ->retrieveByUsername() $t->diag('->retrieveByUsername()'); $table->createQuery()->delete()->where('username = ? OR username = ?', array('inactive_user', 'active_user'))->execute(); $inactiveUser = new sfGuardUser(); $inactiveUser->email_address = '*****@*****.**'; $inactiveUser->username = '******'; $inactiveUser->password = '******'; $inactiveUser->is_active = false; $inactiveUser->save(); $activeUser = new sfGuardUser(); $activeUser->email_address = '*****@*****.**'; $activeUser->username = '******'; $activeUser->password = '******'; $activeUser->is_active = true; $activeUser->save(); $t->is($table->retrieveByUsername('invalid'), null, '->retrieveByUsername() returns "null" if username is invalid'); $t->is($table->retrieveByUsername('inactive_user'), null, '->retrieveByUsername() returns "null" if user is inactive'); $t->isa_ok($table->retrieveByUsername('inactive_user', false), 'sfGuardUser', '->retrieveByUsername() returns an inactive user when second parameter is false'); $t->isa_ok($table->retrieveByUsername('active_user'), 'sfGuardUser', '->retrieveByUsername() returns an active user'); $t->is($table->retrieveByUsername('active_user', false), null, '->retrieveByUsername() returns "null" if user is active and second parameter is false'); $t->isa_ok($table->retrieveByUsername('active_user'), 'sfGuardUser', '->retrieveByUsername() can be called non-statically'); try { $table->retrieveByUsername(null); $t->pass('->retrieveByUsername() does not throw an exception if username is null'); } catch (Exception $e) { $t->diag($e->getMessage()); $t->fail('->retrieveByUsername() does not throw an exception if username is null'); } $t->isa_ok(@PluginsfGuardUserTable::retrieveByUsername('active_user'), 'sfGuardUser', '->retrieveByUsername() can be called statically (BC)');
$t->is($exceptionThrown, true, 'select() throws an exception if called with an empty parameter'); /**********************************************/ /* sfPropelFinder::select($string) and find() */ /**********************************************/ $t->diag('sfPropelFinder::select(string) and find()'); ArticlePeer::doDeleteAll(); CategoryPeer::doDeleteAll(); $finder = sfPropelFinder::from('Category')->select('Name'); $categories = $finder->find(); $t->is($finder->getLatestQuery(), propel_sql('SELECT [P12category.ID, ]category.NAME AS Name FROM category'), 'find() called after select(string) selects a single column'); $t->isa_ok($categories, 'array', 'find() called after select(string) returns an array'); $t->is(count($categories), 0, 'find() called after select(string) returns an empty array if no record is found'); $category1 = new Category(); $category1->setName('cat1'); $category1->save(); $category2 = new Category(); $category2->setName('cat2'); $category2->save(); $finder = sfPropelFinder::from('Category')->select('Name'); $categories = $finder->find(); $t->is(count($categories), 2, 'find() called after select(string) returns an array with one row for each record'); $t->is(array_shift($categories), 'cat1', 'find() called after select(string) returns an array of column values'); $t->is(array_shift($categories), 'cat2', 'find() called after select(string) returns an array of column values');
$reflect = new ReflectionClass($className); $method = array(); $testItems = 0; foreach ($reflect->getMethods() as $reflectmethod) { $params = ''; foreach ($reflectmethod->getParameters() as $key => $row) { if ($params != '') { $params .= ', '; } $params .= '$' . $row->name; } $testItems++; $methods[$reflectmethod->getName()] = $params; } $t->diag('class $className'); $t->isa_ok($obj, 'Report', 'class $className created'); $t->is(count($methods), 14, "class {$className} have " . 14 . ' methods.'); //checking method 'generatedReport1' $t->can_ok($obj, 'generatedReport1', 'generatedReport1() is callable'); //$result = $obj->generatedReport1 ( ); //$t->isa_ok( $result, 'NULL', 'call to method generatedReport1 '); $t->todo("call to method generatedReport1 using "); //checking method 'generatedReport1_filter' $t->can_ok($obj, 'generatedReport1_filter', 'generatedReport1_filter() is callable'); //$result = $obj->generatedReport1_filter ( $from, $to, $startedby); //$t->isa_ok( $result, 'NULL', 'call to method generatedReport1_filter '); $t->todo("call to method generatedReport1_filter using {$from}, {$to}, {$startedby} "); //checking method 'descriptionReport1' $t->can_ok($obj, 'descriptionReport1', 'descriptionReport1() is callable'); //$result = $obj->descriptionReport1 ( $PRO_UID); //$t->isa_ok( $result, 'NULL', 'call to method descriptionReport1 ');
<?php include_once dirname(__FILE__) . '/../../bootstrap/unit.php'; include_once dirname(__FILE__) . '/../../bootstrap/database.php'; $t = new lime_test(null, new lime_output_color()); //------------------------------------------------------------ $t->diag('MemberProfilePeer::getProfileListByMemberId()'); $MemberProfileList = MemberProfilePeer::getProfileListByMemberId(1); $t->isa_ok($MemberProfileList, 'array', 'getProfileListByMemberId() returns an array'); foreach ($MemberProfileList as $profile) { $t->isa_ok($profile, 'MemberProfile', 'each profile is a MemberProfile'); $t->cmp_ok($profile->getName(), '==', true, 'Profile::getName() returns value.'); } $t->cmp_ok(MemberProfilePeer::getProfileListByMemberId(2), '===', array(), 'getProfileListByMemberId() returns an empty array if member does not have any profile'); $t->cmp_ok(MemberProfilePeer::getProfileListByMemberId(999), '===', array(), 'getProfileListByMemberId() returns an empty array if member is not exist'); //------------------------------------------------------------ $t->diag('MemberProfilePeer::retrieveByMemberIdAndProfileId()'); $memberProfile = MemberProfilePeer::retrieveByMemberIdAndProfileId(1, 2); $t->isa_ok($memberProfile, 'MemberProfile', 'retrieveByMemberIdAndProfileId() returns a MemberProfile'); $t->is($memberProfile->getValue(), 'よろしくお願いします。', 'MemberProfile::getValue() returns a value'); $t->cmp_ok(MemberProfilePeer::retrieveByMemberIdAndProfileId(1, 999), '===', NULL, 'retrieveByMemberIdAndProfileId() returns NULL if profile does not exist'); $t->cmp_ok(MemberProfilePeer::retrieveByMemberIdAndProfileId(999, 1), '===', NULL, 'retrieveByNameAndMemberId() returns NULL if member does not exist'); //------------------------------------------------------------ $t->diag('MemberProfilePeer::retrieveByMemberIdAndProfileName()'); $memberProfile = MemberProfilePeer::retrieveByMemberIdAndProfileName(1, 'self_intro'); $t->isa_ok($memberProfile, 'MemberProfile', 'retrieveByMemberIdAndProfileName() returns a MemberProfile'); $t->is($memberProfile->getValue(), 'よろしくお願いします。', 'MemberProfile::getValue() returns a value'); $t->cmp_ok(MemberProfilePeer::retrieveByMemberIdAndProfileName(1, 'unknown'), '===', NULL, 'retrieveByMemberIdAndProfileName() returns NULL if profile does not exist'); $t->cmp_ok(MemberProfilePeer::retrieveByMemberIdAndProfileName(999, 'example'), '===', NULL, 'retrieveByNameAndMemberId() returns NULL if member does not exist');
<?php require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; require_once dirname(__FILE__) . '/../../../lib/config/sfDynamicsBaseDefinition.class.php'; require_once dirname(__FILE__) . '/../../../lib/config/sfDynamicsAssetCollectionDefinition.class.php'; $testCount = 4; $jsArray = array('testjs'); $cssArray = array('testcss'); $t = new lime_test($testCount, new lime_output_color()); try { $i = sfDynamicsAssetCollectionDefinition::__set_state(array('javascripts' => $jsArray, 'stylesheets' => $cssArray)); $t->isa_ok($i, 'sfDynamicsAssetCollectionDefinition', '__set_state works and returns an instance of right class'); } catch (Exception $e) { $t->fail('__set_state failed'); } $t->is($i->getJavascripts(), $jsArray, 'Javascripts getter'); $t->is($i->getStylesheets(), $cssArray, 'Stylesheets getter'); try { $i = sfDynamicsAssetCollectionDefinition::__set_state(array('wrong' => $jsArray)); $t->fail('__set_state should fail if wrong initialization data is sen.'); } catch (sfConfigurationException $e) { $t->ok(1, '__set_state failed because of wrong parameters given'); } catch (Exception $e) { $t->fail('__set_state failed, but with wrong exception type'); }
$category1 = new DCategory(); $category1->setName('cat1'); $category1->save(); $article1 = new DArticle(); $article1->setTitle('aaa'); $article1->setCategory($category1); $article1->save(); $article2 = new DArticle(); $article2->setTitle('bbb'); $article2->save(); $article = sfDoctrineFinder::from('DArticle')->leftJoin('DCategory')->with('DCategory')->findLast(); $category = $article->getCategory(); if (is_object($category)) { $t->isa_ok($article->getCategory(), 'Doctrine_Null', 'In a left join using with(), empty related objects are not hydrated'); } else { $t->isa_ok($article->getCategory(), 'NULL', 'In a left join using with(), empty related objects are not hydrated'); } Doctrine_Query::create()->delete()->from('DComment')->execute(); Doctrine_Query::create()->delete()->from('DArticle')->execute(); Doctrine_Query::create()->delete()->from('DCategory')->execute(); Doctrine_Query::create()->delete()->from('DAuthor')->execute(); $t->diag('sfDoctrineFinder::withColumn() on calculated columns with decimals'); $finder = sfDoctrineFinder::from('DArticle'); try {
<?php include dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(3, new lime_output_color()); $t->isa_ok($p = new Feed(), 'Feed', 'constructor works'); $p->setRssUrl(fixture_url('1upShow-rss2.xml')); $t->isa_ok($p->fetch(), 'sfRssFeed', 'fetch() gives us a sfFeed object'); $t->diag("\$p->getLastFetched()\n\t" . $p->getLastFetched()); $t->isa_ok($p->getLastFetched(null), 'DateTime', 'getLastFetched() gives us a DateTime object');
<?php include_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; include_once dirname(__FILE__) . '/../../../bootstrap/database.php'; sfContext::createInstance($configuration); $t = new lime_test(81, new lime_output_color()); $table = Doctrine::getTable('CommunityMember'); $member1 = Doctrine::getTable('Member')->findOneByName('A'); $member2 = Doctrine::getTable('Member')->findOneByName('B'); $member3 = Doctrine::getTable('Member')->findOneByName('C'); $community1 = Doctrine::getTable('Community')->findOneByName('CommunityA'); $community5 = Doctrine::getTable('Community')->findOneByName('CommunityE'); //------------------------------------------------------------ $t->diag('CommunityMemberTable'); $t->diag('CommunityMemberTable::retrieveByMemberIdAndCommunityId()'); $t->isa_ok($table->retrieveByMemberIdAndCommunityId(1, 1), 'CommunityMember', 'retrieveByMemberIdAndCommunityId() returns a CommunityMember if member joins community'); $t->cmp_ok($table->retrieveByMemberIdAndCommunityId(1, 2), '===', false, 'retrieveByMemberIdAndCommunityId() returns NULL if member does not join community'); $t->cmp_ok($table->retrieveByMemberIdAndCommunityId(1000, 1), '===', false, 'retrieveByMemberIdAndCommunityId() returns NULL if member does not exist'); $t->cmp_ok($table->retrieveByMemberIdAndCommunityId(1, 999), '===', false, 'retrieveByMemberIdAndCommunityId() returns NULL if community does not exist'); $t->cmp_ok($table->retrieveByMemberIdAndCommunityId(999, 999), '===', false, 'retrieveByMemberIdAndCommunityId() returns NULL if member and community do not exist'); //------------------------------------------------------------ $t->diag('CommunityMemberTable::isMember()'); $t->cmp_ok($table->isMember(1, 1), '===', true, 'isMember() returns true if member joins community'); $t->cmp_ok($table->isMember(1, 2), '===', false, 'isMember() returns false if member does not join community'); $t->cmp_ok($table->isMember(999, 1), '===', false, 'isMember() returns false if member does not exist'); $t->cmp_ok($table->isMember(1, 999), '===', false, 'isMember() returns false if community does not exist'); $t->cmp_ok($table->isMember(999, 999), '===', false, 'isMember() returns false if member and community do not exist'); //------------------------------------------------------------ $t->diag('CommunityMemberTable::isAdmin()'); $t->cmp_ok($table->isAdmin(1, 1), '===', true, 'isAdmin() returns true if member joins community and position is admin'); $t->cmp_ok($table->isAdmin(2, 1), '===', false, 'isAdmin() returns false if member joins community and position is not admin');
<?php require_once __DIR__ . '/../../bootstrap.php'; use greebo\conveniences\Container; $t = new lime_test(13); $container = new Container(); $t->diag('defaults'); $t->is_deeply($container->vendor, 'greebo', 'default vendor'); $t->is_deeply($container->app, 'conveniences', 'default app'); $t->is_deeply($container->charset, 'utf-8', 'default character set'); $t->is_deeply($container->debug, false, 'default debug mode'); $t->isa_ok($container->event, 'greebo\\essence\\Event', 'default event instance'); $t->isa_ok($container->request, 'greebo\\conveniences\\Request', 'default request instance'); $t->isa_ok($container->response, 'greebo\\conveniences\\Response', 'default response instance'); $t->is_deeply($container->action_name, 'index', 'default action name'); $t->diag('context related instances'); $_GET['action'] = 'assignments'; $container = new Container(); $container->app = 'test'; $t->is_deeply($container->action_name, 'assignments', 'correct action name'); $t->isa_ok($container->action, 'greebo\\test\\ActionSet', 'correct action set instance'); try { $container->template; $t->fail('template getter throws exception if template class not exists'); } catch (\greebo\conveniences\ContainerException $e) { $t->pass('template getter throws exception if template class not exists'); } try { $container->action_name = 'index'; $template = $container->template; $t->isa_ok($template, 'greebo\\test\\Template\\index', 'correct template instance');
$w['authors'][$i]['first_name']->setParent(null); $author_widget_schema['first_name']->setParent(null); $t->ok($w['authors'][$i]['first_name'] == $author_widget_schema['first_name'], '->embedFormForEach() embeds the widget schema'); $t->is($d['authors'][$i]['first_name'], 'Fabien', '->embedFormForEach() merges default values from the embedded forms'); $t->is($v['authors'][$i][sfForm::getCSRFFieldName()], null, '->embedFormForEach() removes the CSRF token for the embedded forms'); $t->is($w['authors'][$i][sfForm::getCSRFFieldName()], null, '->embedFormForEach() removes the CSRF token for the embedded forms'); } $t->is($w['authors'][0]->generateName('first_name'), 'article[authors][0][first_name]', '->embedFormForEach() changes the name format to reflect the embedding'); // bind too many values for embedded forms $t->diag('bind too many values for embedded forms'); $list = new FormTest(); $list->setWidgets(array('title' => new sfWidgetFormInputText())); $list->setValidators(array('title' => new sfValidatorString())); $list->embedFormForEach('items', clone $list, 2); $list->bind(array('title' => 'list title', 'items' => array(array('title' => 'item 1'), array('title' => 'item 2'), array('title' => 'extra item')))); $t->isa_ok($list['items'][0]->getError(), 'sfValidatorErrorSchema', '"sfFormFieldSchema" is given an error schema when an extra embedded form is bound'); // does this trigger a fatal error? $list['items']->render(); $t->pass('"sfFormFieldSchema" renders when an extra embedded form is bound'); // ->getEmbeddedForms() $t->diag('->getEmbeddedForms()'); $article = new FormTest(); $company = new FormTest(); $author = new FormTest(); $article->embedForm('company', $company); $article->embedForm('author', $author); $forms = $article->getEmbeddedForms(); $t->is(array_keys($forms), array('company', 'author'), '->getEmbeddedForms() returns the embedded forms'); $t->is($forms['company'], $company, '->getEmbeddedForms() returns the embedded forms'); $t->isa_ok($article->getEmbeddedForm('company'), 'FormTest', '->getEmbeddedForm() return an embedded form'); try {
$h->launchTests($v, 4, true, 'type', null, array('type' => 'integer')); $h->launchTests($v, 4.1, false, 'type', 'type_error', array('type' => 'integer')); // type is int $t->diag('->execute() - type is int'); $h->launchTests($v, 4, true, 'type', null, array('type' => 'int')); $h->launchTests($v, 4.1, false, 'type', 'type_error', array('type' => 'int')); // type is float $t->diag('->execute() - type is float'); $h->launchTests($v, 4.1, true, 'type', null, array('type' => 'float')); $h->launchTests($v, 4, false, 'type', 'type_error', array('type' => 'float')); // type is decimal $t->diag('->execute() - type is decimal'); $h->launchTests($v, 4.1, true, 'type', null, array('type' => 'decimal')); $h->launchTests($v, 4, false, 'type', 'type_error', array('type' => 'decimal')); // type is any $t->diag('->execute() - type is any'); $h->launchTests($v, 4.1, true, 'type', null, array('type' => 'any')); $h->launchTests($v, 4, true, 'type', 'type_error', array('type' => 'any')); // number is negative $t->diag('->execute() - number is negative'); $h->launchTests($v, -4, true, 'type', 'type_error', array('type' => 'any')); // conversion of value $t->diag('->execute() - conversion of value'); $v->initialize($context, array('type' => 'integer')); $value = '4'; $v->execute($value, $error); $t->isa_ok($value, 'integer', '->excute() converts to integer if type is integer'); $v->initialize($context, array('type' => 'float')); $value = '4.1'; $v->execute($value, $error); $t->isa_ok($value, 'double', '->excute() converts to float if type is float');
$community4 = Doctrine::getTable('Community')->findOneByName('CommunityD'); $community5 = Doctrine::getTable('Community')->findOneByName('CommunityE'); //------------------------------------------------------------ $t->diag('CommunityTable'); $t->diag('CommunityTable::retrievesByMemberId()'); $communities = $table->retrievesByMemberId(1); $t->is(count($communities), 4, 'retrievesByMemberId() returns 4 communities'); $communities = $table->retrievesByMemberId(1, 1); $t->is(count($communities), 1, 'retrievesByMemberId() returns 1 communities'); $communities = $table->retrievesByMemberId(1, 1, true); $t->is(count($communities), 1, 'retrievesByMemberId() returns 1 communities'); $t->ok(!$table->retrievesByMemberId(999), 'retrievesByMemberId() return null'); //------------------------------------------------------------ $t->diag('CommunityTable::getJoinCommunityListPager()'); $pager = $table->getJoinCommunityListPager(1); $t->isa_ok($pager, 'sfDoctrinePager', 'getJoinCommunityListPager() returns a sfDoctrinePager'); $t->is($pager->getNbResults(), 4, 'getNbResults() returns 4'); $pager = $table->getJoinCommunityListPager(999); $t->isa_ok($pager, 'sfDoctrinePager', 'getJoinCommunityListPager() returns a sfDoctrinePager'); $t->is($pager->getNbResults(), 0, 'getNbResults() returns 0'); //------------------------------------------------------------ $t->diag('CommunityTable::getCommunityMemberListPager()'); $pager = $table->getCommunityMemberListPager(1); $t->isa_ok($pager, 'sfDoctrinePager', 'getCommunityMemberListPager() returns a sfDoctrinePager'); $t->is($pager->getNbResults(), 2, 'getNbResults() returns 2'); $pager = $table->getCommunityMemberListPager(999); $t->isa_ok($pager, 'sfDoctrinePager', 'getCommunityMemberListPager() returns a sfDoctrinePager'); $t->is($pager->getNbResults(), 0, 'getNbResults() returns 0'); //------------------------------------------------------------ $t->diag('CommunityTable::getIdsByMemberId()'); $communityIds = $table->getIdsByMemberId(1);
<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; # load fixtures of this plugin $propelData->loadData(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsPlugin/data/fixtures'); $limeTest = new lime_test(12, new lime_output_color()); $fixturesMigrationsDir = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'sfPropelMigrationsPlugin' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'migrations'; sfConfig::set('sf_propelmigrationsplugin_migrationsdir', $fixturesMigrationsDir); $limeTest->is(sfPropelMigrationsPluginConfiguration::getMigrationsDir(), $fixturesMigrationsDir, 'Configured MigrationsDirectory.'); $propelMigrator = new sfPropelMigrator(); $migrations = $propelMigrator->getMigrations(); $limeTest->isa_ok($migrations, 'sfPropelMigrations', 'Got sfPropelMigrations.'); $limeTest->is(count($migrations), 3, 'Three test migrations found.'); // using Iterator to test content of list $migrations->rewind(); $migration = $migrations->current(); $limeTest->isa_ok($migration, 'sfPropelMigration', 'First Valid Migration.'); $limeTest->is($migration->getVersion(), 12755561356551.0, 'Correct Version.'); $limeTest->is($migration->getName(), 'first_test_migration', 'Correct Name.'); $migrations->next(); $migration = $migrations->current(); $limeTest->isa_ok($migration, 'sfPropelMigration', 'Third Valid Migration.'); $limeTest->is($migration->getVersion(), 12755561453219.0, 'Correct Version.'); $limeTest->is($migration->getName(), 'third_test_migration', 'Correct Name.'); $migrations->next(); $migration = $migrations->current(); $limeTest->isa_ok($migration, 'sfPropelMigration', 'Second Valid Migration.'); $limeTest->is($migration->getVersion(), 12755561493219.0, 'Correct Version.'); $limeTest->is($migration->getName(), 'second_test_migration', 'Correct Name.');
require_once PATH_CORE . "config/databases.php"; G::LoadClass('languages'); $obj = new Languages($dbc); $t = new lime_test(5, new lime_output_color()); $className = Languages; $className = strtolower(substr($className, 0, 1)) . substr($className, 1); $reflect = new ReflectionClass($className); $method = array(); $testItems = 0; foreach ($reflect->getMethods() as $reflectmethod) { $params = ''; foreach ($reflectmethod->getParameters() as $key => $row) { if ($params != '') { $params .= ', '; } $params .= '$' . $row->name; } $testItems++; $methods[$reflectmethod->getName()] = $params; } //To change the case only the first letter of each word, TIA $className = ucwords($className); $t->diag("class {$className}"); $t->isa_ok($obj, "languages", "class {$className} created"); $t->is(count($methods), 1, "class {$className} have " . 1 . ' methods.'); //checking method 'importLanguage' $t->can_ok($obj, 'importLanguage', 'importLanguage() is callable'); //$result = $obj->importLanguage ( $sLanguageFile, $bXml); //$t->isa_ok( $result, 'NULL', 'call to method importLanguage '); $t->todo("call to method importLanguage using {$sLanguageFile}, {$bXml} "); $t->todo('review all pendings methods in this class');
$t->diag('Cached results'); $cache->clear(); ArticlePeer::doDeleteAll(); $article1 = new Article(); $article1->setTitle('foo1'); $article1->save(); $article2 = new Article(); $article2->setTitle('foo2'); $article2->save(); $finder = DbFinder::from('Article')->useCache($cache, 10); $finder->where('Title', 'foo1')->findOne(); // normal query $article = $finder->where('Title', 'foo1')->findOne(); // cached query $t->isa_ok($article, 'Article', 'Cached finder queries return Model objects'); $t->is($article->getId(), $article1->getId(), 'find() finder queries can be cached'); $finder->where('Title', 'foo1')->count(); // normal query $nb = $finder->where('Title', 'foo1')->count(); // cached query $t->is($nb, 1, 'count() finder queries can be cached'); $cache->clear(); $finder = DbFinder::from('Article')->useCache($cache, 10); $finder->where('Title', 'foo1')->limit(1)->find(); // normal query $article = $finder->where('Title', 'foo1')->findOne(); // cached query $t->isa_ok($article, 'Article', 'Cached queries return the correct result type'); $t->diag('useCache(true)'); $cache->clear();
$m->setBackgroundColor(new Mapnik\Color(255, 255, 255)); $t->is($m->getBackgroundColor()->toHexString(), '#ffffff', 'Set background to 0xffffff (white)'); // Set the map data $popplaces_style = new Mapnik\FeatureStyle(); $t->isnt($popplaces_style, null, 'Created new feature style'); $popplaces_rule = new Mapnik\Rule(); $t->isnt($popplaces_rule, null, 'Created new rule'); $popplaces_text_symbolizer = new Mapnik\TextSymbolizer('GEONAME', 'DejaVu Sans Book', 10, new Mapnik\Color(0, 0, 0)); $t->isnt($popplaces_text_symbolizer, null, 'Created text symbolizer'); // @todo //$t->is($popplaces_text_symbolizer->getName(), 'GEONAME', 'Text symbolizer name is GEONAME'); //$t->is($popplaces_text_symbolizer->getFontFace(), '', 'Text symbolizer font face is DejaVu Sans Book'); //$t->is($popplaces_text_symbolizer->getTextSize(), 10, 'Text symbolizer text size is 10'); //$t->is($popplaces_text_symbolizer->getColor(), '', 'Text symbolizer text color is black'); $popplaces_text_symbolizer->setHaloFill(new Mapnik\Color(255, 255, 200)); $t->isa_ok($popplaces_text_symbolizer->getHaloFill(), 'Mapnik\\Color', 'halo_fill set to a Color'); $t->is($popplaces_text_symbolizer->getHaloFill()->toHexString(), '#ffffc8', 'halo_fill returns the right color'); $popplaces_text_symbolizer->setHaloRadius(1); $t->is($popplaces_text_symbolizer->getHaloRadius(), 1, 'halo_radius set to 1'); $popplaces_rule->append($popplaces_text_symbolizer); $t->pass('Appended symbolizer to rule'); $result = $popplaces_style->addRule($popplaces_rule); $t->is($result, true, 'Rule added to feature style'); $result = $m->addStyle('popplaces', $popplaces_style); $t->is($result, true, 'Feature style \'popplaces\' added to map'); $p = new Mapnik\Parameters(); $t->isnt($p, null, 'Created parameters to pass to layer'); $p->set('type', 'shape'); $p->set('file', '../mapnik-0.7.1/demo/data/popplaces'); $p->set('encoding', 'latin1'); $lyr = new Mapnik\Layer('Populated places');
<?php include dirname(__FILE__) . '/../../bootstrap/unit.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; sfContext::createInstance($configuration); sfContext::getInstance()->getUser()->setMemberId(1); $t = new lime_test(13, new lime_output_color()); $conn = Doctrine::getTable('Application')->getConnection(); $conn->beginTransaction(); $application1 = Doctrine::getTable('Application')->findOneByUrl("http://example.com/dummy.xml"); $application2 = Doctrine::getTable('Application')->findOneByUrl("http://gist.github.com/raw/183505/a7f3d824cdcbbcf14c06f287537d0acb0b3e5468/gistfile1.xsl"); $member = Doctrine::getTable('Member')->find(1); // ->addToMember() $t->diag('->addToMember()'); $memberApplication1 = $application2->addToMember($member); $t->isa_ok($memberApplication1, 'MemberApplication', '->addToMember() return MemberApplication object'); $memberApplication2 = $application2->addToMember($member, array('is_view_home' => true)); $applicationSettings = $memberApplication2->getApplicationSettings(); $t->ok(is_array($applicationSettings) && count($applicationSettings) === 1, '->addToMember() save member Application Settings'); // ->isHadByMember() $t->diag('->isHadByMember()'); $t->ok($application1->isHadByMember(), '->isHadByMember() return true when the member has the application'); $t->ok($application1->isHadByMember(1), '->isHadByMember() return true when the member has the application'); $t->ok(!$application1->isHadByMember(999), '->isHadByMember() return false when the member has not the application'); // ->getMemberListPager() $t->diag('->getMemberListPager()'); $t->isa_ok($application1->getMemberListPager(), 'sfDoctrinePager', '->getMemberListPager() return sfDoctrinePager object'); // ->getPersistentData() $t->diag('->getPersistentData()'); $t->isa_ok($application1->getPersistentData(1, 'test_key'), 'ApplicationPersistentData', '->getPersistentData() return ApplicationPersisetentData object'); // ->getPersistentDatas()
<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; require_once dirname(__FILE__) . '/../../lib/sfDynamics.class.php'; $testCount = 1; class ManagerMock extends sfDynamicsManager { } $t = new lime_test($testCount, new lime_output_color()); $t->comment('::getManager()'); if (!sfContext::hasInstance()) { require_once $_SERVER['SYMFONY'] . '/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); require_once dirname(__FILE__) . '/../fixtures/project/config/ProjectConfiguration.class.php'; sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('frontend', 'test', isset($debug) ? $debug : true)); if (!sfContext::hasInstance()) { $t->error('A context instance is required'); die; } $t->info('A frontend context has been initialized for tests'); } sfConfig::set('app_sfDynamicsPlugin_manager', 'ManagerMock'); $t->isa_ok(sfDynamics::getManager(), 'ManagerMock', '::getManager() the manager class can be customized in app.yml');
G::LoadSystem('xmlform'); G::LoadSystem('xmlDocument'); G::LoadSystem('form'); G::LoadSystem('dbconnection'); G::LoadSystem('dbsession'); G::LoadSystem('dbrecordset'); G::LoadSystem('dbtable'); G::LoadSystem('testTools'); G::LoadClass('appDelegation'); require_once PATH_CORE . '/classes/model/AppDelegation.php'; $dbc = new DBConnection(); $ses = new DBSession($dbc); $obj = new AppDelegation($dbc); $t = new lime_test(1, new lime_output_color()); $t->diag('class AppDelegation'); $t->isa_ok($obj, 'AppDelegation', 'class AppDelegation created'); class AppDel extends unitTest { function CreateEmptyAppDelegation($data, $fields) { $obj = new AppDelegation(); $res = $obj->createAppDelegation($fields); return $res; } function CreateDuplicated($data, $fields) { $obj1 = new AppDelegation(); $res = $obj1->createAppDelegation($fields); $this->domain->addDomainValue('createdAppDel', serialize($fields)); $obj2 = new AppDelegation(); $res = $obj2->createAppDelegation($fields);
<?php include_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; include_once dirname(__FILE__) . '/../../../bootstrap/database.php'; $t = new lime_test(2, new lime_output_color()); $banner1 = Doctrine::getTable('Banner')->findOneByName('banner1'); $banner2 = Doctrine::getTable('Banner')->findOneByName('banner2'); //------------------------------------------------------------ $t->diag('Banner'); $t->diag('Banner::getRandomImage()'); $result = $banner1->getRandomImage(); $t->isa_ok($result, 'BannerImage'); $result = $banner2->getRandomImage(); $t->cmp_ok($result, '===', false);
$form = new DefaultValuesForm($author); $t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object value as a default for existing objects'); $author->delete(); // ->embedRelation() $t->diag('->embedRelation()'); class myArticleForm extends ArticleForm { } $table = Doctrine::getTable('Author'); $form = new AuthorForm($table->create(array('Articles' => array(array('title' => 'Article 1'), array('title' => 'Article 2'), array('title' => 'Article 3'))))); $form->embedRelation('Articles'); $embeddedForms = $form->getEmbeddedForms(); $t->ok(isset($form['Articles']), '->embedRelation() embeds forms'); $t->is(count($embeddedForms['Articles']), 3, '->embedRelation() embeds one form for each related object'); $form->embedRelation('Articles', 'myArticleForm', array(array('test' => true))); $embeddedForms = $form->getEmbeddedForms(); $moreEmbeddedForms = $embeddedForms['Articles']->getEmbeddedForms(); $t->isa_ok($moreEmbeddedForms[0], 'myArticleForm', '->embedRelation() accepts a form class argument'); $t->ok($moreEmbeddedForms[0]->getOption('test'), '->embedRelation() accepts a form arguments argument'); $form = new AuthorForm($table->create(array('Articles' => array(array('title' => 'Article 1'), array('title' => 'Article 2'))))); $form->embedRelation('Articles as author_articles'); $t->is(isset($form['author_articles']), true, '->embedRelation() embeds using an alias'); $t->is(count($form['author_articles']), 2, '->embedRelation() embeds one form for each related object using an alias'); $form = new AuthorForm($table->create(array('Articles' => array(array('title' => 'Article 1'), array('title' => 'Article 2'))))); $form->embedRelation('Articles AS author_articles'); $t->is(isset($form['author_articles']), true, '->embedRelation() embeds using an alias with a case insensitive separator'); $form = new ArticleForm(Doctrine::getTable('Article')->create(array('Author' => array('name' => 'John Doe')))); $form->embedRelation('Author'); $t->is(isset($form['Author']), true, '->embedRelation() embeds a ONE type relation'); $t->is(isset($form['Author']['name']), true, '->embedRelation() embeds a ONE type relation'); $t->is($form['Author']['name']->getValue(), 'John Doe', '->embedRelation() uses values from the related object');
{ } class frontendConfiguration extends sfApplicationConfiguration { } */ // use functional project configruration require_once realpath(__DIR__ . '/../../functional/fixtures/config/ProjectConfiguration.class.php'); $frontend_context = sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true)); $frontend_context_prod = sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false)); $i18n_context = sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('i18n', 'test', true)); $cache_context = sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('cache', 'test', true)); // ::getInstance() $t->diag('::getInstance()'); $t->isa_ok($frontend_context, 'sfContext', '::createInstance() takes an application configuration and returns application context instance'); $t->isa_ok(sfContext::getInstance('frontend'), 'sfContext', '::createInstance() creates application name context instance'); $context = sfContext::getInstance('frontend'); $context1 = sfContext::getInstance('i18n'); $context2 = sfContext::getInstance('cache'); $t->is(sfContext::getInstance('i18n'), $context1, '::getInstance() returns the named context if it already exists'); // ::switchTo(); $t->diag('::switchTo()'); sfContext::switchTo('i18n'); $t->is(sfContext::getInstance(), $context1, '::switchTo() changes the default context instance returned by ::getInstance()'); sfContext::switchTo('cache'); $t->is(sfContext::getInstance(), $context2, '::switchTo() changes the default context instance returned by ::getInstance()'); // ->get() ->set() ->has() $t->diag('->get() ->set() ->has()'); $t->is($context1->has('object'), false, '->has() returns false if no object of the given name exist'); $object = new stdClass();
<?php include dirname(__FILE__) . '/../../bootstrap/unit.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; sfContext::createInstance($configuration); $t = new lime_test(1, new lime_output_color()); $conn = Doctrine::getTable('ApplicationInvite')->getConnection(); $conn->beginTransaction(); $invite = Doctrine::getTable('ApplicationInvite')->find(1); $memberApplication = $invite->accept(); $t->isa_ok($memberApplication, 'MemberApplication', '->accept() returns object of MemberApplication'); $conn->rollback();
$reflect = new ReflectionClass($className); $method = array(); $testItems = 0; foreach ($reflect->getMethods() as $reflectmethod) { $params = ''; foreach ($reflectmethod->getParameters() as $key => $row) { if ($params != '') { $params .= ', '; } $params .= '$' . $row->name; } $testItems++; $methods[$reflectmethod->getName()] = $params; } $t->diag('class $className'); $t->isa_ok($obj, $className, 'class $className created'); $t->is(count($methods), 13, "class {$className} have " . 13 . ' methods.'); //checking method '__construct' $t->can_ok($obj, '__construct', '__construct() is callable'); //$result = $obj->__construct ( ); //$t->isa_ok( $result, 'NULL', 'call to method __construct '); $t->todo("call to method __construct using "); //checking method 'setServer' $t->can_ok($obj, 'setServer', 'setServer() is callable'); //$result = $obj->setServer ( $sServer); //$t->isa_ok( $result, 'NULL', 'call to method setServer '); $t->todo("call to method setServer using {$sServer} "); //checking method 'setPort' $t->can_ok($obj, 'setPort', 'setPort() is callable'); //$result = $obj->setPort ( $iPort); //$t->isa_ok( $result, 'NULL', 'call to method setPort ');