Ejemplo n.º 1
0
function dm_test_this_layout(DmLayout $layout, lime_test $t)
{
    $layout->refresh(true);
    $areaTop = $layout->getArea('top');
    $areaLeft = $layout->getArea('left');
    $areaBottom = $layout->getArea('bottom');
    $areaOther = $layout->getArea('other');
    $areaTop->refresh(true);
    $t->is($layout->Areas->count(), 4, 'Layout has 4 Areas');
    $t->is($areaTop['Zones']->count(), 2, 'area top has 2 Zones');
    $t->is($areaTop['Zones'][0]->Widgets->count(), 2, 'area top Zones[0] has 2 Widgets');
    $t->is($areaTop['Zones'][1]->Widgets->count(), 1, 'area Zones[1] has 1 Widgets');
    $t->is($areaLeft->Zones->count(), 1, 'Layout->Areas[1] has 1 Zone');
    $t->is($areaLeft->Zones[0]->Widgets->count(), 0, 'Layout->Areas[1]->Zones[0] has 0 Widgets');
    $t->is($areaBottom->Zones->count(), 1, 'Layout->Areas[2] has 1 Zone');
    $t->is($areaBottom->Zones[0]->Widgets->count(), 0, 'Layout->Areas[2]->Zones[0] has 0 Widgets');
    $t->is($areaOther->Zones->count(), 1, 'Layout->Areas[3] has 1 Zone');
    $t->is($areaOther->Zones[0]->Widgets->count(), 0, 'Layout->Areas[3]->Zones[0] has 0 Widgets');
    $t->is($areaTop['Zones'][0]->Widgets[0]->getModuleAction(), 'dmWidgetContent/title', 'found first widget');
    $t->ok($areaTop['Zones'][0]->Widgets[0]->getCurrentTranslation()->exists(), 'first widget has a current translation');
    $t->is($areaTop['Zones'][0]->Widgets[0]->value, 'widget value 1', 'first widget value is "widget value 1"');
    $t->is($areaTop['Zones'][0]->Widgets[1]->getModuleAction(), 'dmWidgetContent/link', 'found second widget');
    $t->is($areaTop['Zones'][0]->Widgets[1]->value, 'widget value 2', 'second widget value is "widget value 2"');
    $t->is($areaTop['Zones'][1]->Widgets[0]->getModuleAction(), 'dmWidgetContent/image', 'found third widget');
    $t->is($areaTop['Zones'][1]->Widgets[0]->value, 'widget value 3', 'third widget value is "widget value 3"');
}
Ejemplo n.º 2
0
 public function ok($exp, $msg = '')
 {
     if (!$this->report_passes && $exp) {
         ++$this->passed;
         return true;
     }
     return parent::ok($exp, $msg);
 }
 /**
  * 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');
 }
Ejemplo n.º 4
0
/**
 *
 * @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;
}
Ejemplo n.º 5
0
 public function testNestedTree(lime_test $t)
 {
     $t->diag('Test nested tree');
     $table = dmDb::table('DmPage');
     $tree = $table->getTree();
     $root = $tree->fetchRoot();
     $b = $this->createPage('main', 'b');
     $b->getNode()->insertAsLastChildOf($root);
     $a = $this->createPage('main', 'a');
     $a->getNode()->insertAsLastChildOf($root);
     $a->refresh();
     $b->refresh();
     $t->is($a->rgt + 1, $b->lft, '$a->rgt+1 == $b->lft');
     $t->ok($a->getNode()->getParent() == $root, '$root parent of $a');
     $t->ok($b->getNode()->getParent() == $root, '$root parent of $b');
     $b->getNode()->moveAsLastChildOf($a);
     $a->refresh();
     $t->is($a->lft + 1, $b->lft, '$a->lft+1 == $b->lft');
     $t->is($a->rgt - 1, $b->rgt, '$a->rgt-1 == $b->rgt');
     $t->ok($a->getNode()->getParent() == $root, '$root parent of $a');
     $t->ok($b->getNode()->getParent() == $a, '$a parent of $b');
     $t->is($b->getNode()->getParent()->id, $a->id, '$b->getNode()->getParent()->id == $a->id');
     $t->is($b->getNodeParentId(), $a->id, '$b->getNodeParentId() == $a->id');
 }
Ejemplo n.º 6
0
function dm_test_this_layout(DmLayout $layout, lime_test $t)
{
    $layout->refresh(true);
    $layout->Areas[0]->refresh(true);
    $t->is($layout->Areas->count(), 4, 'Layout has 4 Areas');
    $t->is($layout->Areas[0]->Zones->count(), 2, 'Layout->Areas[0] has 2 Zones');
    $t->is($layout->Areas[0]->Zones[0]->Widgets->count(), 2, 'Layout->Areas[0]->Zones[0] has 2 Widgets');
    $t->is($layout->Areas[0]->Zones[1]->Widgets->count(), 1, 'Layout->Areas[0]->Zones[1] has 1 Widgets');
    $t->is($layout->Areas[1]->Zones->count(), 1, 'Layout->Areas[1] has 1 Zone');
    $t->is($layout->Areas[1]->Zones[0]->Widgets->count(), 0, 'Layout->Areas[1]->Zones[0] has 0 Widgets');
    $t->is($layout->Areas[2]->Zones->count(), 1, 'Layout->Areas[2] has 1 Zone');
    $t->is($layout->Areas[2]->Zones[0]->Widgets->count(), 0, 'Layout->Areas[2]->Zones[0] has 0 Widgets');
    $t->is($layout->Areas[3]->Zones->count(), 1, 'Layout->Areas[3] has 1 Zone');
    $t->is($layout->Areas[3]->Zones[0]->Widgets->count(), 0, 'Layout->Areas[3]->Zones[0] has 0 Widgets');
    $t->is($layout->Areas[0]->Zones[0]->Widgets[0]->getModuleAction(), 'dmWidgetContent/title', 'found first widget');
    $t->ok($layout->Areas[0]->Zones[0]->Widgets[0]->getCurrentTranslation()->exists(), 'first widget has a current translation');
    $t->is($layout->Areas[0]->Zones[0]->Widgets[0]->value, 'widget value 1', 'first widget value is "widget value 1"');
    $t->is($layout->Areas[0]->Zones[0]->Widgets[1]->getModuleAction(), 'dmWidgetContent/link', 'found second widget');
    $t->is($layout->Areas[0]->Zones[0]->Widgets[1]->value, 'widget value 2', 'second widget value is "widget value 2"');
    $t->is($layout->Areas[0]->Zones[1]->Widgets[0]->getModuleAction(), 'dmWidgetContent/image', 'found third widget');
    $t->is($layout->Areas[0]->Zones[1]->Widgets[0]->value, 'widget value 3', 'third widget value is "widget value 3"');
}
Ejemplo n.º 7
0
$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');
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');
Ejemplo n.º 8
0
    {
    }
}
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()
$t->diag('->serialize() ->unserialize()');
$t->ok(new myResponse($dispatcher) instanceof Serializable, 'sfResponse implements the Serializable interface');
// new methods via sfEventDispatcher
require_once $_test_dir . '/unit/sfEventDispatcherTest.class.php';
$dispatcherTest = new sfEventDispatcherTest($t);
$dispatcherTest->launchTests($dispatcher, $response, 'response');
// ->__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;
$shortTypeSize = "{$type}({$size})";
$column = new sfDoctrineColumnSchema($colName, array('type' => $shortTypeSize));
$t->is($column->getProperty('size'), $size, 'short array syntax for size');
$t->is($column->getProperty('type'), $type, 'short array syntax for type');
$column = new sfDoctrineColumnSchema($colName, $shortTypeSize);
$t->is($column->getProperty('size'), $size, 'short string syntax for size');
$t->is($column->getProperty('type'), $type, 'short string syntax for type');
$column = new sfDoctrineColumnSchema($column, 'boolean');
$t->is($column->getProperty('type'), 'boolean', 'short string syntax without size');
$t->diag('PHP output');
$type = 'integer';
$size = 456;
Ejemplo n.º 10
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$mode = '644';
$folder = nbConfig::get('nb_sandbox_dir') . '/folder';
$fs = nbFileSystem::getInstance();
if (php_uname('s') == 'Linux') {
    $fs->mkdir($folder);
    $t = new lime_test(1);
    $cmd = new nbChangeModeCommand();
    $commandLine = sprintf('%s %s', $folder, $mode);
    $t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'Folder mode changed successfully');
    $fs->rmdir($folder);
} else {
    $t = new lime_test(0);
    $t->comment('No tests under Windows');
}
Ejemplo n.º 11
0
$t->is($v->getMimeType($tmpDir . '/foo.txt', 'text/plain'), 'text/plain', '->getMimeType() returns the default type if the file type is not guessable');
$v->setOption('mime_type_guessers', array_merge(array(array($v, 'guessFromNothing')), $v->getOption('mime_type_guessers')));
$t->is($v->getMimeType($tmpDir . '/test.txt', 'image/png'), 'nothing/plain', '->getMimeType() takes all guessers from the mime_type_guessers option');
// ->clean()
$t->diag('->clean()');
$v = new testValidatorFile();
try {
    $v->clean(array('test' => true));
    $t->fail('->clean() throws an sfValidatorError if the given value is not well formatted');
    $t->skip('', 1);
} catch (sfValidatorError $e) {
    $t->pass('->clean() throws an sfValidatorError if the given value is not well formatted');
    $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');
}
$f = $v->clean(array('tmp_name' => $tmpDir . '/test.txt'));
$t->ok($f instanceof sfValidatedFile, '->clean() returns a sfValidatedFile instance');
$t->is($f->getOriginalName(), '', '->clean() returns a sfValidatedFile with an empty original name if the name is not passed in the initial value');
$t->is($f->getSize(), strlen($content), '->clean() returns a sfValidatedFile with a computed file size if the size is not passed in the initial value');
$t->is($f->getType(), 'text/plain', '->clean() returns a sfValidatedFile with a guessed content type');
class myValidatedFile extends sfValidatedFile
{
}
$v->setOption('validated_file_class', 'myValidatedFile');
$f = $v->clean(array('tmp_name' => $tmpDir . '/test.txt'));
$t->ok($f instanceof myValidatedFile, '->clean() can take a "validated_file_class" option');
foreach (array(UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION) as $error) {
    try {
        $v->clean(array('tmp_name' => $tmpDir . '/test.txt', 'error' => $error));
        $t->fail('->clean() throws an sfValidatorError if the error code is not UPLOAD_ERR_OK (0)');
        $t->skip('', 1);
    } catch (sfValidatorError $e) {
Ejemplo n.º 12
0
require_once __DIR__ . '/../../bootstrap/unit.php';
ob_start();
$plan = 14;
$t = new lime_test($plan);
if (!extension_loaded('SQLite') && !extension_loaded('pdo_SQLite')) {
    $t->skip('SQLite needed to run these tests', $plan);
    return;
}
// initialize the storage
$database = new sfPDODatabase(array('dsn' => 'sqlite::memory:'));
$connection = $database->getConnection();
$connection->exec('CREATE TABLE session (sess_id, sess_data, sess_time)');
ini_set('session.use_cookies', 0);
$session_id = "1";
$storage = new sfPDOSessionStorage(array('db_table' => 'session', 'session_id' => $session_id, 'database' => $database));
$t->ok($storage instanceof sfStorage, 'sfPDOSessionStorage is an instance of sfStorage');
$t->ok($storage instanceof sfDatabaseSessionStorage, 'sfPDOSessionStorage is an instance of sfDatabaseSessionStorage');
// regenerate()
$oldSessionData = 'foo:bar';
$storage->sessionWrite($session_id, $oldSessionData);
$storage->regenerate(false);
$newSessionData = 'foo:bar:baz';
$storage->sessionWrite(session_id(), $newSessionData);
$t->isnt(session_id(), $session_id, 'regenerate() regenerated the session with a different session id');
// checking if the old session record still exists
$result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', $session_id));
$data = $result->fetchAll();
$t->is(count($data), 1, 'regenerate() has kept destroyed old session');
// checking if the new session record has been created
$result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', session_id()));
$data = $result->fetchAll();
Ejemplo n.º 13
0
$t->is($option->isParameterRequired(), true, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode');
$t->is($option->isParameterOptional(), false, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode');
$option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_OPTIONAL);
$t->is($option->acceptParameter(), true, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode');
$t->is($option->isParameterRequired(), false, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode');
$t->is($option->isParameterOptional(), true, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode');
try {
    $option = new sfCommandOption('foo', 'f', 'ANOTHER_ONE');
    $t->fail('__construct() throws an sfCommandException if the mode is not valid');
} catch (sfCommandException $e) {
    $t->pass('__construct() throws an sfCommandException if the mode is not valid');
}
// ->isArray()
$t->diag('->isArray()');
$option = new sfCommandOption('foo', null, sfCommandOption::IS_ARRAY);
$t->ok($option->isArray(), '->isArray() returns true if the option can be an array');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE | sfCommandOption::IS_ARRAY);
$t->ok($option->isArray(), '->isArray() returns true if the option can be an array');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE);
$t->ok(!$option->isArray(), '->isArray() returns false if the option can not be an array');
// ->getHelp()
$t->diag('->getHelp()');
$option = new sfCommandOption('foo', 'f', null, 'Some help');
$t->is($option->getHelp(), 'Some help', '->getHelp() returns the help message');
// ->getDefault()
$t->diag('->getDefault()');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_OPTIONAL, '', 'default');
$t->is($option->getDefault(), 'default', '->getDefault() returns the default value');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED, '', 'default');
$t->is($option->getDefault(), 'default', '->getDefault() returns the default value');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED);
if (class_exists('SimpleXMLElement')) {
    $element = new SimpleXMLElement('<foo>bar</foo>');
    $escaped = sfOutputEscaper::escape('esc_entities', $element);
    $t->is((string) $escaped, (string) $element, '->__toString() is compatible with SimpleXMLElement');
} else {
    $t->skip('->__toString() is compatible with SimpleXMLElement');
}
class Foo
{
}
class FooCountable implements Countable
{
    public function count()
    {
        return 2;
    }
}
// implements Countable
$t->diag('implements Countable');
$foo = sfOutputEscaper::escape('esc_entities', new Foo());
$fooc = sfOutputEscaper::escape('esc_entities', new FooCountable());
$t->is(count($foo), 1, '->count() returns 1 if the embedded object does not implement the Countable interface');
$t->is(count($fooc), 2, '->count() returns the count() for the embedded object');
// ->__isset()
$t->diag('->__isset()');
$raw = new stdClass();
$raw->foo = 'bar';
$esc = sfOutputEscaper::escape('esc_entities', $raw);
$t->ok(isset($esc->foo), '->__isset() asks the wrapped object whether a property is set');
unset($raw->foo);
$t->ok(!isset($esc->foo), '->__isset() asks the wrapped object whether a property is set');
Ejemplo n.º 15
0
$t->isa_ok($context['foo'], 'sfContext', '->offsetGet() returns attribute by name');
$context['foo2'] = $i18n_context;
$t->isa_ok($context['foo2'], 'sfContext', '->offsetSet() sets object by name');
unset($context['foo2']);
$t->is(isset($context['foo2']), false, '->offsetUnset() unsets object by name');
$t->diag('->__call()');
$context->setFoo4($i18n_context);
$t->is($context->has('foo4'), true, '->__call() sets context objects by name using setName()');
$t->isa_ok($context->getFoo4(), 'sfContext', '->__call() returns context objects by name using getName()');
try {
    $context->unknown();
    $t->fail('->__call() throws an sfException if factory / method does not exist');
} catch (sfException $e) {
    $t->pass('->__call() throws an sfException if factory / method does not exist');
}
$t->diag('->getServiceContainer() test');
$sc = $frontend_context->getServiceContainer();
$t->ok(file_exists(sfConfig::get('sf_cache_dir') . '/frontend/test/config/config_services.yml.php'), '->getServiceContainer() creates a cache file in /cache/frontend/test/config');
$t->ok(class_exists('frontend_testServiceContainer'), '->getServiceContainer() creates and loads the frontend_testServiceContainer class');
$t->ok($sc instanceof frontend_testServiceContainer, '->getServiceContainer() returns an instance of frontend_testServiceContainer');
$t->ok($sc->hasService('my_app_service'), '->getServiceContainer() contains app/config/service.yml services');
$t->ok($sc->hasService('my_project_service'), '->getServiceContainer() contains /config/service.yml services');
$t->ok($sc->hasService('my_plugin_service'), '->getServiceContainer() contains plugin/config/service.yml services');
$t->ok($sc->getParameter('sf_root_dir'), '->getServiceContainer() sfConfig parameters are accessibles');
$t->ok($sc->hasParameter('my_app_test_param'), '->getServiceContainer() contains env specifiv parameters');
$t->diag('->getServiceContainer() prod');
$sc = $frontend_context_prod->getServiceContainer();
$t->ok(file_exists(sfConfig::get('sf_cache_dir') . '/frontend/prod/config/config_services.yml.php'), '->getServiceContainer() creates a cache file in /cache/frontend/prod/config');
$t->ok(class_exists('frontend_prodServiceContainer'), '->getServiceContainer() creates and loads the frontend_prodServiceContainer class');
$t->ok($sc instanceof frontend_prodServiceContainer, '->getServiceContainer() returns an instance of frontend_prodServiceContainer');
$t->ok(false === $sc->hasParameter('my_app_test_param'), '->getServiceContainer() does not contain other env specifiv parameters');
Ejemplo n.º 16
0
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()
$t->diag('->getPersistentDatas()');
$persistentDatas1 = $application1->getPersistentDatas(2, array());
$t->isa_ok($persistentDatas1, 'Doctrine_Collection', '->getPersistentDatas() return Doctrine_Collection object');
Ejemplo n.º 17
0
<?php

require_once realpath(dirname(__FILE__) . '/../../..') . '/unit/helper/dmModuleUnitTestHelper.php';
$helper = new dmModuleUnitTestHelper();
$helper->boot();
$t = new lime_test();
$table = dmDb::table('DmPage');
$page1 = $table->create(array('name' => 'name1', 'slug' => 'slug1', 'module' => 'test', 'action' => 'test1'));
$page1->Node->insertAsFirstChildOf($table->getTree()->fetchRoot());
$t->ok($page1->exists(), 'Created a page');
$t->is('slug1', $page1->slug, 'Page slug is slug1');
$t->comment('Saving page with existing slug');
$page2 = $table->create(array('name' => 'name2', 'slug' => 'slug1', 'module' => 'test', 'action' => 'test2'));
$page2->Node->insertAsFirstChildOf($table->getTree()->fetchRoot());
$t->ok($page2->exists(), 'Created a page');
$t->is($page2->slug, 'slug1-' . $page2->id, 'Page2 slug is slug1-' . $page2->id);
$page1->slug = 'slug1-' . $page2->id;
$page1->save();
$t->is($page1->slug, 'slug1-' . $page2->id . '-' . $page1->id, 'Page1 slug is now slug1-' . $page2->id . '-' . $page1->id);
$page2->slug = 'slug1';
$page2->save();
$t->is($page2->slug, 'slug1', 'Page2 slug is now slug1');
$page2->slug = '';
$page2->save();
$t->is($page2->slug, '/' . $page2->id, 'Page2 slug is now /' . $page2->id);
$page1->Node->moveAsFirstChildOf($page2);
$page2->refresh();
$page1->slug = $page2->slug;
$page1->save();
$t->is($page1->slug, $page2->slug . '/' . $page1->id, 'Page1 slug is now ' . $page2->slug . '/' . $page1->id);
//$helper->get('page_tree_watcher')->connect();
/*
 * 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(2);

// __construct()
$t->diag('__construct()');
$e = new sfI18nYamlValidateExtractor();
$t->ok($e instanceof sfI18nExtractorInterface, 'sfI18nYamlValidateExtractor implements the sfI18nExtractorInterface interface');

// ->extract();
$t->diag('->extract()');

$content = <<<EOF
fields:
  name:
    required:
      msg: Name is required
    sfStringValidator:
      min_error: The name is too short

validators:
  myStringValidator:
    class: sfStringValidator
Ejemplo n.º 19
0
        return true;
    }
}
class InValidModel
{
    public static function getTable()
    {
        return new self();
    }
    public function hasTemplate($template)
    {
        return false;
    }
}
$t->diag('::isTaggable');
$t->ok(TaggableToolkit::isTaggable('ValidModel'), 'valid model name');
$t->ok(TaggableToolkit::isTaggable(new ValidModel('ValidModel')), 'valid model object');
$t->ok(!TaggableToolkit::isTaggable('InValidModel'), 'invalid model name');
$t->ok(!TaggableToolkit::isTaggable(new InValidModel('InValidModel')), 'invalid model object');
try {
    TaggableToolkit::isTaggable('MyClass');
    $t->fail('no exception for no doctrine model name');
} catch (Exception $e) {
    $t->pass('no doctrine model name');
}
class MyClass
{
}
try {
    TaggableToolkit::isTaggable(new MyClass());
    $t->fail('no exception for no doctrine model class');
Ejemplo n.º 20
0
}
class NumericFieldsForm extends sfForm
{
    public function configure()
    {
        $this->setWidgets(array('5' => new sfWidgetFormInputText()));
        $this->setValidators(array('5' => new sfValidatorString()));
        $this->widgetSchema->setLabels(array('5' => 'label' . $this->getOption('salt')));
        $this->widgetSchema->setHelps(array('5' => 'help' . $this->getOption('salt')));
    }
}
sfForm::disableCSRFProtection();
// __construct()
$t->diag('__construct');
$f = new FormTest();
$t->ok($f->getValidatorSchema() instanceof sfValidatorSchema, '__construct() creates an empty validator schema');
$t->ok($f->getWidgetSchema() instanceof sfWidgetFormSchema, '__construct() creates an empty widget form schema');
$f = new sfForm(array('first_name' => 'Fabien'));
$t->is($f->getDefaults(), array('first_name' => 'Fabien'), '__construct() can take an array of default values as its first argument');
$f = new FormTest(array(), array(), 'secret');
$v = $f->getValidatorSchema();
$t->ok($f->isCSRFProtected(), '__construct() takes a CSRF secret as its second argument');
$t->is($v[sfForm::getCSRFFieldName()]->getOption('token'), '*secret*', '__construct() takes a CSRF secret as its second argument');
sfForm::enableCSRFProtection();
$f = new FormTest(array(), array(), false);
$t->ok(!$f->isCSRFProtected(), '__construct() can disable the CSRF protection by passing false as the second argument');
$f = new FormTest();
$t->ok($f->isCSRFProtected(), '__construct() uses CSRF protection if null is passed as the second argument and it\'s enabled globally');
// ->getOption() ->setOption() ->getOptions()
$t->diag('->getOption() ->setOption()');
$f = new FormTest(array(), array('foo' => 'bar'));
$myfoo = 'bar';
$ph->setByRef('myfoo', $myfoo, 'symfony/mynamespace');
$t->is($ph->get('myfoo', null, 'symfony/mynamespace'), $myfoo, '->setByRef() takes a namespace as its third parameter');
// ->add()
$t->diag('->add()');
$foo = 'bar';
$parameters = array('foo' => $foo, 'bar' => 'bar');
$myparameters = array('myfoo' => 'bar', 'mybar' => 'bar');
$ph = new sfNamespacedParameterHolder();
$ph->add($parameters);
$ph->add($myparameters, 'symfony/mynamespace');
$t->is($ph->getAll(), $parameters, '->add() adds an array of parameters');
$t->is($ph->getAll('symfony/mynamespace'), $myparameters, '->add() takes a namespace as its second argument');
$foo = 'mybar';
$t->is($ph->getAll(), $parameters, '->add() adds an array of parameters, not a reference');
// ->addByRef()
$t->diag('->addByRef()');
$foo = 'bar';
$parameters = array('foo' => &$foo, 'bar' => 'bar');
$myparameters = array('myfoo' => 'bar', 'mybar' => 'bar');
$ph = new sfNamespacedParameterHolder();
$ph->addByRef($parameters);
$ph->addByRef($myparameters, 'symfony/mynamespace');
$t->is($parameters, $ph->getAll(), '->add() adds an array of parameters');
$t->is($myparameters, $ph->getAll('symfony/mynamespace'), '->add() takes a namespace as its second argument');
$foo = 'mybar';
$t->is($parameters, $ph->getAll(), '->add() adds a reference of an array of parameters');
// ->serialize() ->unserialize()
$t->diag('->serialize() ->unserialize()');
$t->ok($ph == unserialize(serialize($ph)), 'sfNamespacedParameterHolder implements the Serializable interface');
 * 
 * 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 . '/unit/sfContextMock.class.php';
require_once $_test_dir . '/unit/sfValidatorTestHelper.class.php';
$t = new lime_test(53, new lime_output_color());
$context = new sfContext();
$v = new sfNumberValidator();
$v->initialize($context);
// ->execute()
$t->diag('->execute()');
$number = 12;
$error = null;
$t->ok($v->execute($number, $error), '->execute() returns true if you don\'t define any parameter');
foreach (array('not a number', '0xFE') as $number) {
    $error = null;
    $t->ok(!$v->execute($number, $error), '->execute() returns "nan_error" if value is not a number');
    $t->is($error, 'Input is not a number', '->execute() changes "$error" with a default message if it returns false');
}
foreach (array('any', 'decimal', 'float', 'int', 'integer') as $type) {
    $t->ok($v->initialize($context, array('type' => $type)), sprintf('->execute() can take "%s" as a type argument', $type));
}
try {
    $v->initialize($context, array('type' => 'another type'));
    $t->fail('->initialize() throws an sfValidatorException if "type" is invalid');
} catch (sfValidatorException $e) {
    $t->pass('->initialize() throws an sfValidatorException if "type" is invalid');
}
$h = new sfValidatorTestHelper($context, $t);
 */
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');
}
// strict parameter
$t->diag('->execute() - strict parameter');
$v->initialize($context, array('strict' => false));
foreach ($validEmailsNotStrict 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');
}
Ejemplo n.º 24
0
    public static $isSecure = false;
    public function isSecure()
    {
        return self::$isSecure;
    }
}
$context = sfContext::getInstance();
$context->configuration = ProjectConfiguration::getApplicationConfiguration('mobile_frontend', 'test', true);
$context->inject('request', 'myRequest');
$filter = new myFilter($context);
sfConfig::set('op_ssl_required_applications', array('secure_application'));
sfConfig::set('op_ssl_required_actions', array('insecure_application' => array('secure/login', 'secure/logout'), 'mobile_frontend' => array()));
sfConfig::set('op_ssl_selectable_actions', array('insecure_application' => array('selectable/login'), 'mobile_frontend' => array('member/register', 'member/registerInput', 'member/registerEnd', 'member/login', 'member/configUID')));
// ---
$t->diag('->needToRetrieveMobileUID()');
$t->ok($filter->callNeedToRetrieveMobileUID('member', 'configUID'), 'member/configUID redirects user to HTTP');
$t->ok($filter->callNeedToRetrieveMobileUID('member', 'configUID', 0), 'member/configUID does not redirects user to HTTP when it does not retrieve uid');
$t->ok(!$filter->callNeedToRetrieveMobileUID('member', 'home'), 'member/home does not redirect user to HTTP');
$t->ok(!$filter->callNeedToRetrieveMobileUID('member', 'login'), 'member/login does not redirect user to HTTP');
$t->ok($filter->callNeedToRetrieveMobileUID('member', 'login', 1, array('authMode' => 'MobileUID')), 'member/login redirect user to HTTP when the authMode is MobileUID');
$t->diag('->handleSsl()');
sfConfig::set('op_use_ssl', true);
myRequest::$isSecure = false;
sfConfig::set('sf_app', 'secure_application');
$t->ok($filter->callHandleSsl('anything', 'anything'), 'ssl-required-application redirects user HTTP to HTTPS');
sfConfig::set('sf_app', 'insecure_application');
$t->ok($filter->callHandleSsl('secure', 'login'), 'ssl-required-action redirects user HTTP to HTTPS');
$t->ok(!$filter->callHandleSsl('selectable', 'login'), 'ssl-selectable-action does not redirect user HTTP to HTTPS');
sfConfig::set('sf_app', 'mobile_frontend');
$t->ok(!$filter->callHandleSsl('member', 'configUID'), 'member/configUID does not redirect user HTTP to HTTPS');
$t->ok(!$filter->callHandleSsl('anything', 'anything'), 'no ssl providable action does not redirect user HTTP to HTTPS');
Ejemplo n.º 25
0
$t->is($uri, '/myotherlink', '->click() can take a third argument to tell the position of the link to click on');
list($method, $uri, $parameters) = $b->click('image link');
$t->is($uri, '/myimagelink', '->click() clicks on image links');
list($method, $uri, $parameters) = $b->click('submit');
$t->is($method, 'post', '->click() gets the form method');
$t->is($uri, '/myform', '->click() clicks on form submit buttons');
$t->is($parameters['text_default_value'], 'default', '->click() uses default form field values (input)');
$t->is($parameters['text'], '', '->click() uses default form field values (input)');
$t->is($parameters['textarea'], 'content', '->click() uses default form field values (textarea)');
$t->is($parameters['select'], 'selected', '->click() uses default form field values (select)');
$t->is($parameters['select_multiple'], array('selected', 'last'), '->click() uses default form field values (select - multiple)');
$t->is($parameters['article']['title'], 'title', '->click() recognizes array names');
$t->is($parameters['article']['category'], array('2', '3'), '->click() recognizes array names');
$t->is($parameters['article']['or']['much']['longer'], 'very long!', '->click() recognizes array names');
$t->is($parameters['submit'], 'submit', '->click() populates button clicked');
$t->ok(!isset($parameters['mybutton']), '->click() do not populate buttons not clicked');
$t->is($parameters['myarray'], array('value1', 'value2', 'value3'), '->click() recognizes array names');
$t->is($parameters['checkbox1'], 'checkboxvalue', '->click() returns the value of the checkbox value attribute');
$t->is($parameters['checkbox2'], '1', '->click() returns 1 if the checkbox has no value');
list($method, $uri, $parameters) = $b->click('mybuttonvalue');
$t->is($uri, '/myform', '->click() clicks on form buttons');
$t->is($parameters['text_default_value'], 'default', '->click() uses default form field values');
$t->is($parameters['mybutton'], 'mybuttonvalue', '->click() populates button clicked');
$t->ok(!isset($parameters['submit']), '->click() do not populate buttons not clicked');
list($method, $uri, $parameters) = $b->click('submit1');
$t->is($uri, '/myform1?text_default_value=default&submit=submit1', '->click() clicks on form buttons');
$t->is($method, 'get', '->click() gets the form method');
list($method, $uri, $parameters) = $b->click('submit2');
$t->is($method, 'get', '->click() defaults to get method');
list($method, $uri, $parameters) = $b->click('submit3');
$t->is($uri, '/myform3?key=value&text_default_value=default&submit=submit3', '->click() concatenates fields values with existing action parameters');
Ejemplo n.º 26
0
require 'util/xfException.class.php';
require 'document/xfDocument.class.php';
require 'document/xfField.class.php';
require 'document/xfFieldValue.class.php';
require 'result/xfDocumentHit.class.php';
require 'result/xfResultException.class.php';
require 'mock/result/xfMockRetort.class.php';
$t = new lime_test(11, new lime_output_color());
$document = new xfDocument('guid');
$document->addField(new xfFieldValue(new xfField('_service', xfField::STORED), 'foo-service'));
$hit = new xfDocumentHit($document, array('score' => 0.2));
$t->diag('->getOption(), ->getOptions(), hasOption(), setOption()');
$t->is($hit->getOption('score'), 0.2, '->getOption() returns the option value');
$t->is($hit->getOption('foobar'), null, '->getOption() returns null for unset options');
$t->is($hit->getOption('foobar', 42), 42, '->getOption() returns the default for unset options');
$t->ok($hit->hasOption('score'), '->hasOption() returns true for options that exist');
$t->ok(!$hit->hasOption('foobar'), '->hasOption() returns false for options that do not exist');
$hit->setOption('foobar', 'baz');
$t->is($hit->getOption('foobar'), 'baz', '->getOption() returns the option value');
$t->is($hit->getOptions(), array('score' => 0.2, 'foobar' => 'baz'), '->getOptions() returns all options');
$t->diag('->getDocument(), ->getServiceName()');
$t->is($hit->getDocument(), $document, '->getDocument() returns the wrapped document');
$t->is($hit->getServiceName(), 'foo-service', '->getServiceName() returns the service name');
$t->diag('->__call()');
$retort = new xfMockRetort();
$retort->can = false;
$hit->setRetorts(array($retort));
try {
    $msg = '->__call() throws exception when a retort is not found';
    $hit->getWhatever();
    $t->fail($msg);
$author = new Author();
$author->name = 'Jacques Doe';
$author->save();
$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');
Ejemplo n.º 28
0
//$t->is(£link('app:admin/main/test')->getHref(), $adminUrl2, $adminUrl2);
//
//$adminUrl3 = 'http://symfony/admin.php?var1=val2';
//$t->is(£link('app:admin?var1=val2')->getHref(), $adminUrl3, $adminUrl3);
$t->diag('blank');
$blankLink = sprintf('<a class="link" href="%s" target="%s">%s</a>', 'http://diem-project.org', '_blank', 'http://diem-project.org');
$t->is((string) £link('http://diem-project.org')->target('blank'), $blankLink, 'blank link is ' . $blankLink);
$blankLink = sprintf('<a class="link" href="%s">%s</a>', 'http://diem-project.org', 'http://diem-project.org');
$t->is((string) £link('http://diem-project.org')->target('blank')->target(false), $blankLink, 'canceled blank link is ' . $blankLink);
$t->diag('media links');
dmDb::table('DmMediaFolder')->checkRoot();
$t->comment('Create a test image media');
$mediaFileName = 'test_image_' . dmString::random() . '.jpg';
copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data/image/defaultMedia.jpg'), dmOs::join(sfConfig::get('sf_upload_dir'), $mediaFileName));
$media = dmDb::create('DmMedia', array('file' => $mediaFileName, 'dm_media_folder_id' => dmDb::table('DmMediaFolder')->checkRoot()->id))->saveGet();
$t->ok($media->exists(), 'A test media has been created');
$mediaLink = sprintf('<a class="link" href="%s">%s</a>', $helper->get('request')->getAbsoluteUrlRoot() . '/' . $media->webPath, $media->file);
$t->is((string) £link($media), $mediaLink, '$media -> ' . $mediaLink);
$t->is((string) £link('media:' . $media->id), $mediaLink, 'media:' . $media->id . ' -> ' . $mediaLink);
$t->is((string) £link('/' . $media->webPath)->text($media->file), $expected = str_replace($helper->get('request')->getAbsoluteUrlRoot(), '', $mediaLink), $media->webPath . ' -> ' . $expected);
sfConfig::set('sf_debug', true);
$badSource = dmString::random() . '/' . dmString::random();
$errorText = '[EXCEPTION] ' . $badSource . ' is not a valid link resource';
$expr = '_^<a class="link" href="\\?dm\\_debug=1" title="[^"]+">' . preg_quote($errorText, '_') . '</a>$_';
$errorLink = (string) £link($badSource);
$t->like($errorLink, $expr, $errorLink);
sfConfig::set('sf_debug', false);
$badSource = dmString::random() . '/' . dmString::random();
$errorLink = '<a class="link"></a>';
$t->is($errorLink, $errorLink, $errorLink);
$media->delete();
<?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);
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'test');
define('SF_DEBUG', true);
include dirname(__FILE__) . '/../bootstrap/unit.php';
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$t = new lime_test(2, new lime_output_color());
$t->diag('unit test to verify the mechanisms to upgrade the opp_atto.n_interventi field');
$t->diag('Tests beginning');
$atto_id = 12066;
$carica_id = 801;
$atto = OppAttoPeer::retrieveByPK($atto_id);
$n_interventi = $atto->getNInterventi();
$t->diag("L'atto {$atto_id} ha {$n_interventi} interventi");
$t->diag("Creato nuovo un intervento per la carica {$carica_id}");
$int_new = new OppIntervento();
$int_new->setAttoId($atto_id);
$int_new->setCaricaId($carica_id);
$int_new->setTipologia('Assemblea');
$int_new->setSedeId('36');
$int_new->setData('2009-02-06');
$int_new->setUrl('http://pippo.it');
$int_new->setNumero(2);
$int_new->save();
$atto = OppAttoPeer::retrieveByPK($atto_id);
$t->ok($atto->getNInterventi() == $n_interventi + 1, "L'atto ha ora un intervento in più (" . $atto->getNInterventi() . ")");
$t->diag("Rimosso l'intervento");
$int_new->delete();
$atto = OppAttoPeer::retrieveByPK($atto_id);
$t->ok($atto->getNInterventi() == $n_interventi, "L'atto ha ora di nuovo lo stesso n. di interventi (" . $atto->getNInterventi() . ")");