/** * Tests that this input fails * * @param string $input * @param string $message */ public function fail($input, $message = null, $encoding = 'utf-8') { $this->lime->diag($input); try { $this->lexer->tokenize($input, $encoding); $this->lime->fail('exception not thrown'); if ($message) { $this->lime->skip(''); } } catch (Exception $e) { $this->lime->pass('exception caught: ' . $e->getMessage()); if ($message) { $this->lime->is($e->getMessage(), $message, 'exception message matches'); } } }
/** * Test launcher * * @param string $schema Path to schema file */ function launchTests($schema) { $this->t->diag('->load()'); $this->load($schema); $this->t->diag('->getTables()'); $tables = $this->tables; $this->t->is(count($tables), 2, "->getTables() should return 2 table from fixture."); $this->t->ok(in_array('testTable', array_keys($tables)), "->getTables() should return 'testTable' from fixture."); $this->t->diag('->classes'); $this->t->is(count($this->classes), 2, "->classes should have 2 class from fixture"); $this->t->ok($this->getClass('TestTable'), "->classes should have 'TestTable' from fixture."); $this->t->ok($this->getClass('TestTable')->getColumn('dummy_id')->hasRelation(), 'foreign relation is properly imported'); #$this->t->diag('->asDoctrineYml()'); #$yml = $this->asDoctrineYml(); #$this->t->cmp_ok(strlen($yml['source']), '>', 0, "->asDoctrineYml() doctrine YAML shoudl not be empty."); $this->t->diag('->findClassByTableName()'); $this->t->is($this->findClassByTableName('testTable')->getPhpName(), 'TestTable', "->findClassByTableName() returns 'TestTable' class for 'testTable' table."); $yml = $this->asDoctrineYml(); $yml = $yml['source']; $this->t->like($yml, '@cascadeDelete: 1@', 'onDelete is generated'); }
protected function checkEachFolder(lime_test $t) { $errors = 0; if (!($root = $this->folderTable->getTree()->fetchRoot())) { $t->diag('Tree has no root !'); $errors++; } elseif ($root->relPath != '') { $t->diag(sprintf('Root relPath != "" (%s)', $root->relPath)); $errors++; } elseif ($root->getNodeParentId() !== null) { $t->diag(sprintf('Root->getNodeParentId() = %d', $root->getNodeParentId())); $errors++; } $folders = $this->folderTable->findAll(); foreach ($folders as $folder) { $folder->refresh(); if ($folder->getNode()->isRoot()) { continue; } if (!($parent = $folder->getNode()->getParent())) { $t->diag(sprintf('$folder->getNode()->getParent() == NULL (folder : %s)', $folder)); $errors++; } elseif ($parent->id != $folder->getNodeParentId()) { $t->diag(sprintf('$folder->getNode()->getParent()->id != $folder->getNodeParentId() (%d, %d) (folder : %s)', $folder->getNode()->getParent()->id, $folder->getNodeParentId(), $folder)); $errors++; if ($parent->lft >= $folder->lft || $parent->rgt <= $folder->rgt) { $t->diag(sprintf('bad folder / parent lft|rgt (folder %d : %d, %d) (parent %d : %d, %d)', $folder->id, $folder->lft, $folder->rgt, $parent->id, $parent->lft, $parent->rgt)); $errors++; } } if ($folder->lft >= $folder->rgt) { $t->diag(sprintf('$folder->lft >= $folder->rgt (%d, %d) (folder : %s)', $folder->lft, $folder->rgt, $folder)); $errors++; } if (!$folder->lft || !$folder->rgt) { $t->diag(sprintf('!$folder->lft || !$folder->rgt (%d, %d) (folder : %s)', $folder->lft, $folder->rgt, $folder)); $errors++; } } $t->is($errors, 0, "All folders are sane ({$errors} errors)"); }
/** * Test launcher * * @param string $schema Path to schema file */ function launchTests($schema) { $this->t->diag('->load()'); $this->load($schema); $this->process(); $yml = $this->asDoctrineYml(); $this->t->diag('->getClasses()'); $classes = $this->getClasses(); $nbClasses = 12; $this->t->is(count($classes), $nbClasses, "->getClasses() should return {$nbClasses} classes from fixture."); $this->t->diag('->getClass()'); $class = $this->getClass('TestClass'); #$this->t->ok($class->isTable(),"->getClass() should return return class instance."); $this->t->diag('->parentTable()'); $table = $this->parentTable($class); $this->t->is(get_class($table), 'sfDoctrineTableSchema', "->parentTable() should return table instance."); $this->t->is($this->getClass('ColAggregation')->getTableName(), 'parent_table', 'inheritance gets the right parent table'); #$this->t->ok($this->getClass('SeparateTable')->isTable(), '"SeparateTable" is a table-class'); $this->t->is($this->getClass('BookI18n')->getColumn('culture')->getProperty('type'), 'string', 'culture field is defined (as a string)'); $rel = $this->getClass('BookI18n')->getRelation('id'); $this->t->is($rel->get('localName'), 'BookI18n', 'i18n relation name is not a plural'); $this->t->is($this->getClass('ColAggregation')->getTable()->getColumn('class_key')->getProperty('type'), 'integer', 'inheritance field is defined (as an integer)'); $c = $this->getClass('SeparateTable'); $SeparateTablePhp = $c->asPhp(); $SeparateTableSource = $SeparateTablePhp[0]['source']; $this->t->like($SeparateTableSource, '/extends Parent/', 'The class "SeparateTable" extends Parent without having any class key field'); $this->t->like($SeparateTableSource, '@setTableName\\(\'separate_table\'\\)@', 'class "SeparateTable" has both a table and inheritance'); $this->t->like($SeparateTableSource, '@parent::setTableDefinition\\(\\);@', 'class "SeparateTable" calls parent::setTableDefinition'); $colAggregationPhp = $this->getClass('ColAggregation')->asPhp(); $this->t->like($colAggregationPhp[0]['source'], "@setInheritanceMap\\(array\\('class_key'=>1\\)\\)@", 'setInheritanceMap is properly set'); $this->t->diag('relationships'); $yangPhp = $this->getClass('Yin')->asPhp(); $this->t->like($yangPhp[0]['source'], "#hasOne\\('Yang as Yang', 'Yin.yang_id', 'id'\\)#", 'one to one relationships is properly declared'); $userPhp = $this->getClass('User')->asPhp(); $this->t->like($userPhp[0]['source'], "#hasMany\\('Book as Books', 'Book.author_id'\\)#", 'hasMany is properly declared'); $this->t->like($userPhp[0]['source'], "#hasMany\\('Group as Groups', 'User2Group.group_id'\\)#", 'has many to many properly declared'); $userGroupPhp = $this->getClass('User2Group')->asPhp(); $this->t->like($userGroupPhp[0]['source'], "#ownsOne\\('User as User', 'User2Group.group_id', 'id'\\)#", 'has many to many with cascade properly defined'); }
<?php require dirname(__FILE__) . '/setup.php'; require dirname(__FILE__) . '/db_init.php'; $pdo = new PDO('mysql:host=localhost; dbname=hermit_test', 'root', 'password'); db_init($pdo); $test = new lime_test(); $test->diag(basename(__FILE__)); $dbmeta = new HermitMySQLDatabaseMeta($pdo); $test->diag(basename(__FILE__) . '::parameter[in:out]'); $procedureInfo = $dbmeta->getProcedureInfo('PROC_IN_OUT'); $test->ok($procedureInfo !== null); $parameters = array_map('strtolower', $procedureInfo->getParamNames()); $expect = array('sales', 'tax'); $test->is(count(array_diff($parameters, $expect)), 0); $test->is($procedureInfo->typeofIn('sales'), true); $test->is($procedureInfo->typeofOut('sales'), false); $test->is($procedureInfo->typeofInOut('sales'), false); $test->is($procedureInfo->typeofIn('tax'), false); $test->is($procedureInfo->typeofOut('tax'), true); $test->is($procedureInfo->typeofInOut('tax'), false); $procedureInfo2 = $dbmeta->getProcedureInfo('PROC_IN_OUT'); $test->ok($procedureInfo === $procedureInfo2, 'same instance'); $test->diag(basename(__FILE__) . '::parameter[in:out:out]'); $procedureInfo = $dbmeta->getProcedureInfo('PROC_IN_OUT_OUT'); $parameters = array_map('strtolower', $procedureInfo->getParamNames()); $expect = array('sales', 'tax', 'total'); $test->is(count(array_diff($parameters, $expect)), 0); $test->is($procedureInfo->typeofIn('sales'), true); $test->is($procedureInfo->typeofOut('sales'), false); $test->is($procedureInfo->typeofInOut('sales'), false);
$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'); dmConfig::set('search_stop_words', 'un le les de,du , da, di ,do ou '); $t->is($currentIndex->getStopWords(), array('un', 'le', 'les', 'de', 'du', 'da', 'di', 'do', 'ou'), 'stop words retrieved from site instance : ' . implode(', ', $currentIndex->getStopWords())); $t->diag('Cleaning text'); $html = '<ol><li><a class="link dm_parent" href="symfony">Accueil</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines">Domaines</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines/77-cursus-proin1i471j0u">cursus. Proin1i471j0u</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1">trices interdum risus. Duisgpcinqn1</a></li><li>></li><li><span class="link dm_current">Info : t, auctor ornare, risus. Donec lo</span></li></ol><span class="link dm_current">Info : t, auctor ornare, risus. Donec lo</span><div class="info_tag list_by_info"><ul class="elements"><li class="element clearfix"><a class="link" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1/t-auctor-ornare-risus-donec-lo-79/t-donec">t. Donec</a></li><li class="element clearfix"><a class="link" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1/t-auctor-ornare-risus-donec-lo-79/em-ipsu">em ipsu</a></li></ul></div>'; $expected = 'accueil domaines cursus proin1i471j0u trices interdum risus duisgpcinqn1 info t auctor ornare risus donec lo info t auctor ornare risus donec lo t donec em ipsu'; $t->is($currentIndex->cleanText($html), $expected, 'cleaned text : ' . $expected); $html = '<div>some content<a href="url">a link text é àî</a>... end</div>'; $expected = 'some content a link text e ai end'; $t->is($currentIndex->cleanText($html), $expected, 'cleaned text : ' . $expected); // for now this doesn't work on windows if ('/' !== DIRECTORY_SEPARATOR) { return; } $t->diag('Populate all indices'); $t->ok($engine->populate(), 'Indices populated'); $t->is($user->getCulture(), sfConfig::get('sf_default_culture'), 'User\'s culture has not been changed'); $t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir'); $t->diag('Optimize all indices');
<?php // test/unit/renderer/sympal/mySympalMarkdownRendererTest.php // あらかじめパーサー定数を変更しておく define('MARKDOWN_PARSER_CLASS', 'myMarkdownExtra_Parser'); require_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; $t = new lime_test(3); // markdownテスト $t->diag('markdown機能自体をテスト'); $data = "test"; $t->is(mySympalMarkdownRenderer::enhanceHtml(Markdown($data), $data), "<p>test</p>\n", 'markdownレンダリング'); $data = "# test\n## test2"; $t->is(mySympalMarkdownRenderer::enhanceHtml(Markdown($data), $data), "<h1 id=\"" . md5('test') . "\">test</h1>\n\n<h2 id=\"" . md5('test2') . "\">test2</h2>\n", 'markdownレンダリング'); $data = <<<EOT [php] echo "Hello, World!"; EOT; $t->is(mySympalMarkdownRenderer::enhanceHtml(Markdown($data), $data), "<pre class=\"php\"><span class=\"kw3\">echo</span> <span class=\"st0\">"Hello, World!"</span>;\n </pre>\n", 'markdownレンダリング(php)');
<?php $app = 'frontend'; include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new lime_test(13); // ->__construct() $t->diag('->__construct()'); class NumericFieldForm extends ArticleForm { public function configure() { $this->widgetSchema[1] = new sfWidgetFormInputText(); $this->validatorSchema[1] = new sfValidatorPass(); $this->setDefault(1, '==DEFAULT_VALUE=='); } } $form = new NumericFieldForm(); $defaults = $form->getDefaults(); $t->is($defaults[1], '==DEFAULT_VALUE==', '->__construct() allows ->configure() to set defaults on numeric fields'); class DefaultValuesForm extends AuthorForm { public function configure() { $this->setDefault('name', 'John Doe'); } } $author = new Author(); $form = new DefaultValuesForm($author); $t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form defaults for new objects'); $author = new Author(); $author->name = 'Jacques Doe';
class myResponse extends sfResponse { function serialize() { } function unserialize($serialized) { } } class fakeResponse { } $t = new lime_test(7, new lime_output_color()); $dispatcher = new sfEventDispatcher(); // ->initialize() $t->diag('->initialize()'); $response = new myResponse($dispatcher, array('foo' => 'bar')); $options = $response->getOptions(); $t->is($options['foo'], 'bar', '->initialize() takes an array of options as its second argument'); // ->getContent() ->setContent() $t->diag('->getContent() ->setContent()'); $t->is($response->getContent(), null, '->getContent() returns the current response content which is null by default'); $response->setContent('test'); $t->is($response->getContent(), 'test', '->setContent() sets the response content'); // ->sendContent() $t->diag('->sendContent()'); ob_start(); $response->sendContent(); $content = ob_get_clean(); $t->is($content, 'test', '->sendContent() output the current response content'); // ->serialize() ->unserialize()
/* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../lib/lime/lime.php'; require_once dirname(__FILE__) . '/../../lib/sfServiceContainerAutoloader.php'; sfServiceContainerAutoloader::register(); require_once dirname(__FILE__) . '/../lib/yaml/sfYaml.php'; $t = new lime_test(4); $dir = dirname(__FILE__) . '/fixtures/yaml'; // ->dump() $t->diag('->dump()'); $dumper = new sfServiceContainerDumperYaml($container = new sfServiceContainerBuilder()); $t->is($dumper->dump(), file_get_contents($dir . '/services1.yml'), '->dump() dumps an empty container as an empty YAML file'); $container = new sfServiceContainerBuilder(); $dumper = new sfServiceContainerDumperYaml($container); // ->addParameters() $t->diag('->addParameters()'); $container = (include dirname(__FILE__) . '/fixtures/containers/container8.php'); $dumper = new sfServiceContainerDumperYaml($container); $t->is($dumper->dump(), file_get_contents($dir . '/services8.yml'), '->dump() dumps parameters'); // ->addService() $t->diag('->addService()'); $container = (include dirname(__FILE__) . '/fixtures/containers/container9.php'); $dumper = new sfServiceContainerDumperYaml($container); $t->is($dumper->dump(), str_replace('%path%', dirname(__FILE__) . '/fixtures/includes', file_get_contents($dir . '/services9.yml')), '->dump() dumps services'); $dumper = new sfServiceContainerDumperYaml($container = new sfServiceContainerBuilder());
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once __DIR__ . '/../../../bootstrap/unit.php'; $t = new lime_test(8); $dom = new DomDocument('1.0', 'utf-8'); $dom->validateOnParse = true; // ->configure() $t->diag('->configure()'); try { new sfWidgetFormI18nChoiceCountry(array('culture' => 'en', 'countries' => array('EN'))); $t->fail('->configure() throws an InvalidArgumentException if a country does not exist'); } catch (InvalidArgumentException $e) { $t->pass('->configure() throws an InvalidArgumentException if a country does not exist'); } $v = new sfWidgetFormI18nChoiceCountry(array('culture' => 'en', 'countries' => array('FR', 'GB'))); $t->is(array_keys($v->getOption('choices')), array('FR', 'GB'), '->configure() can restrict the number of countries with the countries option'); // ->render() $t->diag('->render()'); $w = new sfWidgetFormI18nChoiceCountry(array('culture' => 'fr')); $dom->loadHTML($w->render('country', 'FR')); $css = new sfDomCssSelector($dom); $t->is($css->matchSingle('#country option[value="FR"]')->getValue(), 'France', '->render() renders all countries as option tags'); $t->is(count($css->matchAll('#country option[value="FR"][selected="selected"]')->getNodes()), 1, '->render() renders all countries as option tags'); // Test for ICU Upgrade and Ticket #7988
<?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 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');
id: ~ name: varchar(255) comment: id: ~ content: varchar(255) article_id: ~ author_id: ~ Beware that the tables for these models will be emptied by the tests, so use a test database connection. */ include dirname(__FILE__).'/../../bootstrap.php'; $t = new lime_test(34, new lime_output_color()); $t->diag('getUniqueIdentifier()'); $id1 = DbFinder::from('Article')->where('Title', 'foo')->getUniqueIdentifier(); $id2 = DbFinder::from('Article')->where('Title', 'foo')->getUniqueIdentifier(); $t->is($id1, $id2, 'Similar queries get the same unique identifier'); $id1 = DbFinder::from('Article')->where('Title', 'foo')->getUniqueIdentifier(); $id2 = DbFinder::from('Article')->where('Title', 'bar')->getUniqueIdentifier(); $t->isnt($id1, $id2, 'Different queries get a different unique identifier'); $id1 = DbFinder::from('Article')->getUniqueIdentifier(); $id2 = DbFinder::from('Comment')->getUniqueIdentifier(); $t->isnt($id1, $id2, 'unique identifier takes main model class into account'); $id1 = DbFinder::from('Article')->where('Title', 'foo')->with('Category')->getUniqueIdentifier(); $id2 = DbFinder::from('Article')->where('Title', 'foo')->getUniqueIdentifier();
<?php $app = 'frontend'; $fixtures = 'fixtures/fixtures.yml'; include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new lime_test(4); // ->getChoices() $t->diag('->getChoices()'); $validator = new sfWidgetFormDoctrineChoice(array('model' => 'Author')); $author = Doctrine_Core::getTable('Author')->createQuery()->limit(1)->fetchOne(); $t->is_deeply($validator->getChoices(), array(1 => 'Jonathan H. Wage', 2 => 'Fabien POTENCIER'), '->getChoices() returns choices'); $validator->setOption('order_by', array('name', 'asc')); $t->cmp_ok($validator->getChoices(), '===', array(2 => 'Fabien POTENCIER', 1 => 'Jonathan H. Wage'), '->getChoices() returns ordered choices'); $validator->setOption('table_method', 'testTableMethod'); $t->is_deeply($validator->getChoices(), array(1 => 'Jonathan H. Wage', 2 => 'Fabien POTENCIER'), '->getChoices() returns choices for given "table_method" option'); $validator = new sfWidgetFormDoctrineChoice(array('model' => 'Author', 'query' => Doctrine_Core::getTable('Author')->createQuery()->limit(1))); $t->is_deeply($validator->getChoices(), array(1 => 'Jonathan H. Wage'), '->getChoices() returns choices for given "query" option');
G::LoadSystem('error'); 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();
*/ /** * @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');
<?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 /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(54, new lime_output_color()); // ->click() $t->diag('->click()'); class myClickBrowser extends sfBrowser { public function setHtml($html) { $this->dom = new DomDocument('1.0', 'UTF-8'); $this->dom->validateOnParse = true; $this->dom->loadHTML($html); } public function getFiles() { $f = $this->files; $this->files = array(); return $f; } public function call($uri, $method = 'get', $parameters = array(), $changeStack = true) { $uri = $this->fixUri($uri); $this->fields = array();
<?php /* * This file is part of the symfony package. * * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../lib/lime/lime.php'; require_once dirname(__FILE__) . '/../../lib/sfTemplateAutoloader.php'; sfTemplateAutoloader::register(); $t = new lime_test(2); $renderer = new sfTemplateRendererPhp(); // ->evaluate() $t->diag('->evaluate()'); $template = new sfTemplateStorageString('<?php echo $foo ?>'); $t->is($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of sfTemplateStorageString'); $template = new sfTemplateStorageFile(dirname(__FILE__) . '/fixtures/templates/foo.php'); $t->is($renderer->evaluate($template, array('foo' => 'bar')), 'bar', '->evaluate() renders templates that are instances of sfTemplateStorageFile');
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(18, new lime_output_color()); $v1 = new sfValidatorString(array('max_length' => 3)); $v2 = new sfValidatorString(array('min_length' => 3)); $v = new sfValidatorOr(array($v1, $v2)); // __construct() $t->diag('__construct()'); $v = new sfValidatorOr(); $t->is($v->getValidators(), array(), '->__construct() can take no argument'); $v = new sfValidatorOr($v1); $t->is($v->getValidators(), array($v1), '->__construct() can take a validator as its first argument'); $v = new sfValidatorOr(array($v1, $v2)); $t->is($v->getValidators(), array($v1, $v2), '->__construct() can take an array of validators as its first argument'); try { $v = new sfValidatorOr('string'); $t->fail('_construct() throws an exception when passing a non supported first argument'); } catch (InvalidArgumentException $e) { $t->pass('_construct() throws an exception when passing a non supported first argument'); } // ->addValidator() $t->diag('->addValidator()'); $v = new sfValidatorOr();
<?php // initializes testing framework $sf_root_dir = realpath(dirname(__FILE__) . '/../../../../'); // initialize database manager require_once $sf_root_dir . '/test/bootstrap/unit.php'; // start tests $t = new lime_test(31); // these tests check for the tags attachement consistency $t->diag('::cleanTagName'); $tag = TaggableToolkit::cleanTagName(''); $t->is($tag, '', 'empty string'); $tag = TaggableToolkit::cleanTagName('test'); $t->is($tag, 'test', 'single tag'); $tag = TaggableToolkit::cleanTagName('test1,test2'); $t->is($tag, 'test1 test2', 'double tag whitespace'); $tag = TaggableToolkit::cleanTagName('test1, test2'); $t->is($tag, 'test1 test2', 'double tag with whitespace'); $t->todo('test optional option parameter'); $t->diag('::explodeTagString'); $tag = TaggableToolkit::explodeTagString(''); $t->is($tag, '', 'empty string'); $tag = TaggableToolkit::explodeTagString('test1'); $t->is($tag, 'test1', 'single tag'); $tag = TaggableToolkit::explodeTagString('test1 test2'); $t->is($tag, 'test1 test2', 'single tag with whitespace'); $tag = TaggableToolkit::explodeTagString('test1,test2'); $t->is($tag, array('test1', 'test2'), 'double tag'); $tag = TaggableToolkit::explodeTagString(' test1 , test2'); $t->is($tag, array('test1', 'test2'), 'double dirty tag'); $tag = TaggableToolkit::explodeTagString(' test1 ,
<?php require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot(); $t = new lime_test(33); $v = new dmValidatorCssIdAndClasses(); $t->diag('->clean()'); foreach (array('a', 'a_b', 'a-c', 'qieurgfbqoiuzbfvoqiuzZFZGPSOZDNZKFjflzkh986875OoihzyfvbxoquyfvxqozufyxqzUEFV', '9', '_', ' bla rebla ', '- _ 8', '.class', '.a b.c.d', '#myid.a b.c.d', '#myid class1 class2', 'class1 class2 #myid', '.a b#myid.c.d', '.a b#myid.c.d#myid', '.a b#myid.c.d #myid', '#my_id', '#my-id', ' #my-id ') as $classes) { try { $t->comment('"' . $classes . '" -> "' . $v->clean($classes) . '"'); $t->pass('->clean() checks that the value is a valid css class name + id'); } catch (sfValidatorError $e) { $t->fail('->clean() checks that the value is a valid css class name + id'); } } foreach (array('.zegze$g.zegf', '/', 'a/f', 'a^', 'a # @', 'é', '-{') as $nonClass) { $t->comment($nonClass); try { $v->clean($nonClass); $t->fail('->clean() throws an sfValidatorError if the value is not a valid css class name + id'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('->clean() throws an sfValidatorError if the value is not a valid css class name + id'); $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); } }
<?php // test/unit/renderer/RendererTest.php require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(0); $t->diag('no tests');
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; $t = new lime_test(1, new lime_output_color()); $dom = new DomDocument('1.0', 'utf-8'); $dom->validateOnParse = true; // ->configure() $t->diag('->configure()'); $w = new sfWidgetFormI18nDateTime(array('culture' => 'fr')); $t->is($w->getOption('format'), '%date% %time%', '->configure() automatically changes the date format for the given culture');
} public function guessFromMimeContentType($file) { return parent::guessFromMimeContentType($file); } public function guessFromFileBinary($file) { return parent::guessFromFileBinary($file); } public function getMimeTypesFromCategory($category) { return parent::getMimeTypesFromCategory($category); } } // ->getMimeTypesFromCategory() $t->diag('->getMimeTypesFromCategory()'); $v = new testValidatorFile(); try { $t->is($v->getMimeTypesFromCategory('non_existant_category'), ''); $t->fail('->getMimeTypesFromCategory() throws an InvalidArgumentException if the category does not exist'); } catch (InvalidArgumentException $e) { $t->pass('->getMimeTypesFromCategory() throws an InvalidArgumentException if the category does not exist'); } $categories = $v->getOption('mime_categories'); $t->is($v->getMimeTypesFromCategory('web_images'), $categories['web_images'], '->getMimeTypesFromCategory() returns an array of mime types for a given category'); $v->setOption('mime_categories', array_merge($v->getOption('mime_categories'), array('text' => array('text/plain')))); $t->is($v->getMimeTypesFromCategory('text'), array('text/plain'), '->getMimeTypesFromCategory() returns an array of mime types for a given category'); // ->guessFromFileinfo() $t->diag('->guessFromFileinfo()'); if (!function_exists('finfo_open')) { $t->skip('finfo_open is not available', 2);
$t->skip('PEAR must be installed', 5); return; } require_once __DIR__ . '/sfPearDownloaderTest.class.php'; require_once __DIR__ . '/sfPearRestTest.class.php'; require_once __DIR__ . '/sfPluginTestHelper.class.php'; // setup $temp = tempnam('/tmp/sf_plugin_test', 'tmp'); unlink($temp); mkdir($temp, 0777, true); define('SF_PLUGIN_TEST_DIR', $temp); $options = array('plugin_dir' => $temp . '/plugins', 'cache_dir' => $temp . '/cache', 'preferred_state' => 'stable', 'rest_base_class' => 'sfPearRestTest', 'downloader_base_class' => 'sfPearDownloaderTest'); $dispatcher = new sfEventDispatcher(); $environment = new sfPearEnvironment($dispatcher, $options); $environment->registerChannel('pear.example.com', true); $rest = $environment->getRest(); // ->getPluginVersions() $t->diag('->getPluginVersions()'); $t->is($rest->getPluginVersions('sfTestPlugin'), array('1.1.3', '1.0.3', '1.0.0'), '->getPluginVersions() returns an array of stable versions for a plugin'); $t->is($rest->getPluginVersions('sfTestPlugin', 'stable'), array('1.1.3', '1.0.3', '1.0.0'), '->getPluginVersions() accepts stability as a second parameter and returns an array of versions for a plugin based on stability'); $t->is($rest->getPluginVersions('sfTestPlugin', 'beta'), array('1.0.4', '1.1.4', '1.1.3', '1.0.3', '1.0.0'), '->getPluginVersions() accepts stability as a second parameter and returns an array of versions for a plugin based on stability cascade (beta includes stable)'); // ->getPluginDependencies() $t->diag('->getPluginDependencies()'); $dependencies = $rest->getPluginDependencies('sfTestPlugin', '1.1.4'); $t->is($dependencies['required']['package']['min'], '1.1.0', '->getPluginDependencies() returns an array of dependencies'); // ->getPluginDownloadURL() $t->diag('->getPluginDownloadURL()'); $t->is($rest->getPluginDownloadURL('sfTestPlugin', '1.1.3', 'stable'), 'http://pear.example.com/get/sfTestPlugin/sfTestPlugin-1.1.3.tgz', '->getPluginDownloadURL() returns a plugin URL'); // teardown sfToolkit::clearDirectory($temp); rmdir($temp);
<?php /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once __DIR__ . '/../../bootstrap/unit.php'; $t = new lime_test(50); // ->clear() $t->diag('->clear()'); $ph = new sfNamespacedParameterHolder(); $ph->clear(); $t->is($ph->getAll(), null, '->clear() clears all parameters'); $ph->set('foo', 'bar'); $ph->clear(); $t->is($ph->getAll(), null, '->clear() clears all parameters'); // ->get() $t->diag('->get()'); $ph = new sfNamespacedParameterHolder(); $ph->set('foo', 'bar'); $t->is($ph->get('foo'), 'bar', '->get() returns the parameter value for the given key'); $t->is($ph->get('bar'), null, '->get() returns null if the key does not exist'); $ph = new sfNamespacedParameterHolder(); $t->is('default_value', $ph->get('foo1', 'default_value'), '->get() takes the default value as its second argument'); $ph = new sfNamespacedParameterHolder(); $ph->set('myfoo', 'bar', 'symfony/mynamespace'); $t->is('bar', $ph->get('myfoo', null, 'symfony/mynamespace'), '->get() takes an optional namespace as its third argument'); $t->is(null, $ph->get('myfoo'), '->get() can have the same key for several namespaces');
<?php /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once __DIR__ . '/../../bootstrap/unit.php'; require_once __DIR__ . '/sfCacheDriverTests.class.php'; $t = new lime_test(65); // setup sfConfig::set('sf_logging_enabled', false); $temp = tempnam('/tmp/cache_dir', 'tmp'); unlink($temp); mkdir($temp); // ->initialize() $t->diag('->initialize()'); try { $cache = new sfFileCache(); $t->fail('->initialize() throws an sfInitializationException exception if you don\'t pass a "cache_dir" parameter'); } catch (sfInitializationException $e) { $t->pass('->initialize() throws an sfInitializationException exception if you don\'t pass a "cache_dir" parameter'); } $cache = new sfFileCache(array('cache_dir' => $temp)); sfCacheDriverTests::launch($t, $cache); // teardown sfToolkit::clearDirectory($temp); rmdir($temp);
<?php /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; require_once $_test_dir . '/../../../../test/unit/sfContextMock.class.php'; $t = new lime_test(28); $context = sfContext::getInstance(); $v = new sfEmailValidator($context); // ->execute() $t->diag('->execute()'); $validEmails = array('*****@*****.**', '*****@*****.**', '*****@*****.**'); $invalidEmails = array('example', 'example@', 'example@localhost', 'example@example.com@example.com'); $validEmailsNotStrict = array('*****@*****.**', '*****@*****.**', '*****@*****.**', 'example@localhost'); $invalidEmailsNotStrict = array('example', 'example@', 'example@example.com@example.com'); $v->initialize($context); foreach ($validEmails as $value) { $error = null; $t->ok($v->execute($value, $error), sprintf('->execute() returns true for a valid email "%s"', $value)); $t->is($error, null, '->execute() doesn\'t change "$error" if it returns true'); } foreach ($invalidEmails as $value) { $error = null; $t->ok(!$v->execute($value, $error), sprintf('->execute() returns false for an invalid email "%s"', $value)); $t->isnt($error, null, '->execute() changes "$error" with a default message if it returns false'); }