Пример #1
0
function check_test_tree(lime_test $t, ioMenuItem $menu)
{
    $t->info('### Running checks on the integrity of the test tree.');
    $t->is(count($menu), 2, 'count(rt) returns 2 children');
    $t->is(count($menu['Parent 1']), 3, 'count(pt1) returns 3 children');
    $t->is(count($menu['Parent 2']), 1, 'count(pt2) returns 1 child');
    $t->is(count($menu['Parent 2']['Child 4']), 1, 'count(ch4) returns 1 child');
    $t->is_deeply($menu['Parent 2']['Child 4']['Grandchild 1']->getName(), 'Grandchild 1', 'gc1 has the name "Grandchild 1"');
}
Пример #2
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(7, new lime_output_color());
$t->info("findLinked method");
$conn = Doctrine_Manager::connection();
$staging_ids = array();
$staging_ids_all = $conn->fetchAll("SELECT id FROM staging");
foreach ($staging_ids_all as $staging_id_val) {
    $staging_ids[] = $staging_id_val['id'];
}
$s = Doctrine::getTable("Staging")->findLinked($staging_ids);
$t->is(count($s), 1, 'Number of distinct related template_table_record_ref records is well "1"');
$t->is(2, $s[0]['record_id'], 'Staging record referenced is well "2"...');
$t->is(1, $s[0]['cnt'], '... and is well counted "1" time');
$conn->execute("\n              INSERT INTO staging_people (id, referenced_relation, record_id, formated_name, people_type)\n              VALUES (2, 'staging', 2, 'Bricolux', 'preparator')\n            ");
$conn->execute("\n              INSERT INTO codes (id, referenced_relation, record_id, code)\n              VALUES (1024, 'staging', 1, 'Codex-1')\n            ");
$s = Doctrine::getTable("Staging")->findLinked($staging_ids);
$t->is(count($s), 2, 'Number of distinct related template_table_record_ref records is well "2" now');
$t->is(1, $s[0]['cnt'], 'The first one (record_id "1") is well counted "1" time...');
$t->is(2, $s[1]['cnt'], '... and the second one (record_id "2") is well counted "2" time (two staging_people entries)');
$t->is(2, $s[1]['record_id'], 'Second one is well record_id "2" :)');
$conn->close();
Пример #3
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(14, new lime_output_color());
$taxs = Doctrine::getTable('Taxonomy')->findOneByName('Falco Peregrinus eliticus');
$t->info('findWithParents($id)');
$taxa = Doctrine::getTable('Taxonomy')->findWithParents($taxs->getId());
$t->isnt($taxa, null, 'we got a taxa');
$t->is($taxa->count(), 9, 'we got all parent of the taxa');
$t->is($taxa[7]->getId(), $taxs->getParentRef(), 'Parent is correct');
$t->is($taxa[1]->Level->__toString(), 'kingdom', 'get Level');
$t->is($taxs->getNameWithFormat(), '<i>Falco Peregrinus eliticus</i>', 'get Name without extinct');
$taxs->setExtinct('true');
$t->is($taxs->getNameWithFormat(), '<i>Falco Peregrinus eliticus</i> †', 'get Name without extinct');
$t->is(DarwinTable::getFilterForTable('classification_syonymies'), "ClassificationSyonymiesFormFilter", 'Filter Form name');
$t->is(DarwinTable::getFormForTable('classification_syonymies'), "ClassificationSyonymiesForm", 'Form Name');
$t->is(DarwinTable::getModelForTable('classification_syonymies'), "ClassificationSyonymies", 'Model Name');
$t->is(Doctrine::getTable('Taxonomy')->find(4)->toArray(), true, 'We got the record with find');
$t->is(Doctrine::getTable('Taxonomy')->find(-1)->toArray(), true, 'Record bellow 0 are found  with find');
$keywords = Doctrine::getTable('ClassificationKeywords')->findForTable('taxonomy', 4);
$t->is(count($keywords), 0, 'No KW per default');
$kw_full = ClassificationKeywords::getTags('taxonomy');
$avail_kw = array_keys($kw_full);
$kw = new ClassificationKeywords();
$kw->setReferencedRelation('taxonomy');
$kw->setRecordId(4);
$kw->setKeywordType($avail_kw[1]);
$kw->setKeyword('Falco Peregrinus');
$kw->save();
$keywords = Doctrine::getTable('ClassificationKeywords')->findForTable('taxonomy', 4);
$t->is(count($keywords), 1, 'The new Keyword');
Пример #4
0
<?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');
<?php

$app = 'sympal';
$refresh_assets = true;
require_once dirname(__FILE__) . '/../../../../bootstrap/unit.php';
$t = new lime_test(30);
// initialize some asset objects
$sync = new sfSympalAssetSynchronizer($configuration->getEventDispatcher());
$sync->run();
$asset = Doctrine_Core::getTable('sfSympalAsset')->findOneBySlug('sympal-info')->getAssetObject();
$asset2 = Doctrine_Core::getTable('sfSympalAsset')->findOneBySlug('screens-sympalphp')->getAssetObject();
$t->info('1 - Run some basic functions on the asset');
$t->is($asset->isImage(), false, '->isImage() returns false');
$t->is($asset->getType(), 'text', '->getType() returns "text"');
$t->is($asset->exists(), true, '->exists() returns true as the file does exist');
$t->is($asset->getTypeFromExtension(), 'text', '->getTypeFromExtension() returns text');
$t->is($asset->getIcon(), '/sfSympalAssetsPlugin/images/icons/txt.png', '->getIcon() returns the txt.png icon');
$t->is($asset->getExtension(), 'txt', '->getExtension() returns .txt');
$t->is($asset->getPath(), sfConfig::get('sf_upload_dir') . '/sympal info.txt', '->getPath() returns the correct path');
$t->is($asset->getRelativePath(), '/sympal info.txt', '->getRelativePath() returns the web url for the asset');
$t->is($asset->getRelativePathDirectory(), '', '->getRelativePathDirectory() returns a blank string');
$t->is($asset->getFilePath(), '/sympal info.txt', '->getFilePath() returns /sympal info.txt');
$t->is($asset2->getPath(), sfConfig::get('sf_upload_dir') . '/screens/sympalphp.png', '->getPath() returns the correct path');
$t->is($asset2->getRelativePath(), '/screens/sympalphp.png', '->getRelativePath() returns the web url for the asset');
$t->is($asset2->getRelativePathDirectory(), '/screens', '->getRelativePathDirectory() returns "/screens"');
$t->is($asset2->getFilePath(), '/screens/sympalphp.png', '->getFilePath() returns /sympal info.txt');
$t->like($asset2->getUrl(), '/uploads\\/screens\\/sympalphp\\.png/', '->getFilePath() contains /uploads/screens/sympalphp.png');
$t->like($asset2->getUrl(), '/http\\:\\/\\//', '->getFilePath() contains http://');
$t->is($asset->getName(), 'sympal info.txt', '->getName() return "sympal info.txt"');
$t->is($asset2->getSize(), '275', '->getSize() returns 275 for a 274.7kb file');
$original = $asset->getOriginal();
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(3, new lime_output_color());
$userEvil = Doctrine::getTable('Users')->findOneByFamilyName('Evil')->getId();
$ids_userEvil = Doctrine::getTable('Loans')->getMyLoans($userEvil)->execute();
$t->info('getFromLoans()');
$cat = Doctrine::getTable('LoanStatus')->getFromLoans(getIdsArrayFrom($ids_userEvil));
$t->is(count($cat), 5, '5 last loans status are returnes for evil');
$status = Doctrine::getTable('LoanStatus')->getDistinctStatus();
$t->is(count($status), 6, '6 status for loans are possible');
$allstatus = Doctrine::getTable('LoanStatus')->getallLoanStatus(1);
$t->is(count($allstatus), 3, '3 status exist for loans Dog of Goyet');
/*
   little helper function to construct an array of ids
*/
function getIdsArrayFrom($ids)
{
    $de_ids = array();
    foreach ($ids as $id) {
        $de_ids[] = $id->getId();
    }
    return $de_ids;
}
    public function generateJsHtml()
    {
        return '<script type="text/javascript" src="/dynamics/foo.js"></script>';
    }
}
$t = new lime_test(7, new lime_output_color());
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');
}
$t->comment('->addSfDynamicsTags()');
sfConfig::set('app_sfDynamicsPlugin_manager', 'ManagerMock');
$manager = sfDynamics::getManager();
$t->info('New placeholder system');
$content = <<<END
<html>
  <head>
    <!-- Include sfDynamics css tags -->
    <link rel="stylesheet" type="text/css" media="screen" href="/bar.css" />
  </head>
  <body>
    <p>Lorem ipsum</p>

    <!-- Include sfDynamics js tags -->
<?php

// Bring in functional so we have an application configuration
// This will help us to find layouts etc that are in the application
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(5);
// Setup a cache driver
$cachePath = '/tmp/theme_tookit';
sfToolkit::clearDirectory($cachePath);
$cacheDriver = new sfFileCache(array('cache_dir' => $cachePath));
$toolkit = new sfThemeToolkit($configuration);
$toolkit->setCacheDriver($cacheDriver);
$t->is($toolkit->getCacheDriver(), $cacheDriver, '->getCacheDriver() returns the correct object');
$t->info('1 - Test getLayouts()');
$layouts = array('plugins/sfThemeTestPlugin/templates/plugin_test_layout.php' => 'plugin_test_layout', 'apps/frontend/templates/app_test_layout.php' => 'app_test_layout', 'apps/frontend/templates/layout.php' => 'layout');
$t->is($toolkit->getLayouts(), $layouts, '->getLayouts() returns 2 layouts from the app and 1 from a plugin');
$t->info('  1.1 - Mutate the cache, it should return the mutated version');
$cacheDriver->set('theme.configuration.layouts', serialize(array('/path/to/layout.php' => 'layout')));
// Need to create a new toolkit class, because the layous are "cached" as a property on the object
$toolkit = new sfThemeToolkit($configuration);
$toolkit->setCacheDriver($cacheDriver);
$t->is($toolkit->getLayouts(), array('/path/to/layout.php' => 'layout'), '->getLayouts() returns from cache');
$t->info('2 - Test the createInstance() static method');
$toolkit = sfThemeToolkit::createInstance($configuration);
$t->is(get_class($toolkit), 'sfThemeTestToolkit', 'The toolkit has the class defined in app.yml');
$t->is(get_class($toolkit->getCacheDriver()), 'sfFileCache', 'The cache driver is set correctly');
<?php

// bootstrap in the functional configuration since the theme manager is context-dependent
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(31);
$t->info('1 - Test some basics of getting themes, theme objects');
// we'll use this to test the theme object
$themeConfig = array('layout' => 'testing');
$theme = new sfTheme($themeConfig);
$manager = new sfThemeManager($context);
$t->is($manager->getThemes(), array(), '->getThemes() returns an empty array to start.');
$manager = new sfThemeManager($context, array('test_theme' => $themeConfig));
$t->is($manager->getThemes(), array('test_theme' => $themeConfig), 'Themes can be set via the constructor.');
$manager = new sfThemeManager($context);
$manager->addTheme('test_theme', $themeConfig);
$t->is($manager->getThemes(), array('test_theme' => $themeConfig), 'Themes can be set via addTheme() passing in an array.');
$t->is($manager->getThemeObject('test_theme')->getConfig(), $theme->getConfig(), '->getThemeObject() returns the correct theme object');
$manager = new sfThemeManager($context);
$manager->addTheme('test_theme', $theme);
$t->is($manager->getThemes(), array('test_theme' => $themeConfig), 'Themes can be set via addTheme() passing in an sfTheme object.');
$t->is($manager->getThemeObject('test_theme'), $theme, '->getThemeObject() returns the correct theme object');
$t->info('  1.1 - Trying to retrieve a non-existent theme object throws an exception');
try {
    $manager->getThemeObject('fake');
    $t->fail('No exception thrown');
} catch (sfException $e) {
    $t->pass($e->getMessage());
}
$t->info('  1.2 - Play with the current theme');
$t->is($manager->getCurrentTheme(), false, '->getCurrentTheme() returns false when there is no theme set');
Пример #10
0
$timer = new sfTimer();
// stub class used for testing
class ioMenuItemTest extends ioMenuItem
{
    // resets the isCurrent property so we can test for current repeatedly.
    public function resetIsCurrent()
    {
        $this->_isCurrent = null;
    }
    // resets the userAccess property so we can test for current repeatedly.
    public function resetUserAccess()
    {
        $this->_userAccess = null;
    }
}
$t->info('1 - Test basic getters, setters and constructor');
$menu = new ioMenuItem('test menu', '@homepage', array('title' => 'my menu'));
$t->is($menu->getName(), 'test menu', '->getName() returns the given name.');
$menu->setName('new menu name');
$t->is($menu->getName(), 'new menu name', '->setName() sets the name correctly.');
$t->is($menu->getLabel(), 'new menu name', '->getLabel() returns the name if the label does not exist.');
$menu->setLabel('menu label');
$t->is($menu->getLabel(), 'menu label', 'Once set, ->getLabel() returns the actual label.');
$t->is($menu->getRoute(), '@homepage', '->getRoute() returns the given route.');
$menu->setRoute('http://www.sympalphp.org');
$t->is($menu->getRoute(), 'http://www.sympalphp.org', '->setRoute() sets the route correctly.');
$t->is($menu->getAttributes(), array('title' => 'my menu'), '->getAttributes() returns the attributes array.');
$menu->setAttributes(array('id' => 'unit_test'));
$t->is($menu->getAttributes(), array('id' => 'unit_test'), '->setAttributes() sets the attributes array.');
$t->is($menu->getAttribute('id', 'default'), 'unit_test', '->getAttribute() returns an existing attribute correctly.');
$t->is($menu->getAttribute('fake', 'default'), 'default', '->getAttribute() returns the default for a non-existent attribute.');
<?php

$app = 'sympal';
$refresh_assets = true;
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(6);
$assetNum = 3;
// the number of test assets
$sync = new sfSympalAssetSynchronizer($configuration->getEventDispatcher());
$t->info('1 - Test that the synchronizer loads in the assets');
$assets = Doctrine_Core::getTable('sfSympalAsset')->findAll();
$t->is(count($assets), 0, 'There are 0 assets before the synchronizer is run');
$sync->run();
$assets = Doctrine_Core::getTable('sfSympalAsset')->findAll();
$t->is(count($assets), $assetNum, sprintf('There are %s assets after the synchronizer is run', $assetNum));
$t->info('2 - Test that the assets were loaded with the correct data');
check_asset_values($t, $assets[0], array('name' => 'sympal info.txt', 'path' => '', 'slug' => 'sympal-info'));
check_asset_values($t, $assets[1], array('name' => 'sympalphp.png', 'path' => '/screens', 'slug' => 'screens-sympalphp'));
check_asset_values($t, $assets[2], array('name' => 'symfony-logo.gif', 'path' => '/logos', 'slug' => 'logos-symfony-logo'));
$t->info('3 - Delete a file and rerun the synchronizer');
unlink(sfConfig::get('sf_upload_dir') . '/logos/symfony-logo.gif');
$sync->run();
$assets = Doctrine_Core::getTable('sfSympalAsset')->findAll();
$t->is(count($assets), $assetNum - 1, sprintf('There are %s assets after the synchronizer is run', $assetNum - 1));
function check_asset_values(lime_test $t, sfSympalAsset $asset, $values)
{
    $savedValues = $asset->toArray();
    unset($savedValues['id']);
    $t->is($savedValues, $values, sprintf('The asset "%s" has the correct values', $values['name']));
}
<?php

// Bringing in functional to have context for the createInstance() method
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(4);
$t->info('1 - Test the basics, like getOptions()');
$controller = new sfThemeController(array('test' => 'foo'));
$t->is($controller->getOption('test', 'ignore'), 'foo', '->getOption() returns existent options');
$t->is($controller->getOption('fake', 'default'), 'default', '->getOption() returns the default for nonexistent options');
$t->info('2 - Test the createInstance() method');
$controller = sfThemeController::createInstance();
$t->is(get_class($controller), 'sfThemeTestController', 'Class is sfThemeTestController, as set in app.yml');
$t->is($controller->getOption('default_theme'), 'app_test', 'Controller options were loaded correctly');
<?php

include dirname(__FILE__) . '/../bootstrap/unit.php';
$conn = lyMediaFolderTable::getInstance()->getConnection();
$root = lyMediaFolderTable::getInstance()->createRoot('test_root');
$fs = new lyMediaFileSystem();
$t = new lime_test(30, new lime_output_color());
$t->info('Create first level folder');
$folder = new lyMediaFolder();
$folder->setName('test');
$folder->create($root);
$folder->refresh();
/*
 * test_root
 *  -- test
 */
$t->is($folder->getName(), 'test', '->getName()');
$t->is($folder->getRelativePath(), 'test_root/test/', '->getRelativePath()');
$t->ok($folder->getNode()->isValidNode(), 'Folder is a valid node');
$t->is($folder->getNode()->getPath('/', true), 'test_root/test', 'Folder has right path');
$t->ok($fs->is_dir($folder->getRelativePath()), 'Folder exists in filesystem');
$t->info('Create sub-folder');
$sub = new lyMediaFolder();
$sub->setName('test-sub');
$sub->create($folder);
$sub->refresh();
/*
 * test_root
 *  -- test
 *  -- -- test-sub
 */
Пример #14
0
<?php

require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(10);
// Default sympal theme
$t->info('1 - Test on the default sympal theme');
$theme = $themeManager->getThemeObject('sympal');
$t->is($theme->getLayoutPath(), $dir . '/templates/sympal.php', '->getLayoutPath() returns the correct path to sympal.php');
$t->is($theme->getStylesheets(), array('/sfSympalThemePlugin/css/sympal.css'), '->getStylesheets() returns the correct stylesheets');
$t->is($theme->getJavascripts(), array(), '->getJavascripts() returns no javascripts in this case');
$t->is($theme->getName(), 'sympal', '->getName() returns the correct name of the theme');
// Theme from another plugin
$t->info('2 - Test on a theme that lives inside a plugin');
$theme = $themeManager->getThemeObject('test_theme');
$t->is($theme->getLayoutPath(), $dir . '/test/fixtures/project/plugins/sfSympalThemeTestPlugin/templates/layout_for_testing.php', '->getLayoutPath() returns the custom layout name in the correct path');
$t->is($theme->getStylesheets(), array('/sfSympalThemeTestPlugin/css/test_theme.css'), '->getStylesheets() automatically finds a css file matching the name of the theme');
$t->is($theme->getJavascripts(), array('/sfSympalThemeTestPlugin/js/testing.js'), '->getJavascripts() returns the correct javascript');
// Theme from application
$t->info('3 - Test a plugin that lives inside the app');
$theme = $themeManager->getThemeObject('app_test');
$t->is($theme->getLayoutPath(), $dir . '/test/fixtures/project/apps/frontend/templates/app_test_layout.php', '->getLayoutPath() returns "app_test_layout" - the custom layout name given');
$t->is($theme->getStylesheets(), array('app_test'), '->getStylesheets() finds "app_test" by default as a css to include');
$t->is($theme->getJavascripts(), array(), '->getJavascripts() returns an empty array');
Пример #15
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(15, new lime_output_color());
$t->info('distinct SubGroup()');
$sgroups = Doctrine::getTable('TagGroups')->getDistinctSubGroups('administrative area');
$t->is(count($sgroups), 3, 'Get all administrative sub groups');
$t->is($sgroups['country'], 'country', 'Country is set');
$sgroups = Doctrine::getTable('TagGroups')->getDistinctSubGroups('brol');
$t->is(count($sgroups), 1, 'Get administrative sub groups for this unused');
$t->is($sgroups[''], '', 'thre is only the empty');
$t->info('getPropositions');
$props = Doctrine::getTable('TagGroups')->getPropositions('brussels');
$t->is(count($props), 4, 'We got 4 props');
$props = Doctrine::getTable('TagGroups')->getPropositions('Bruselo');
$t->is(count($props), 2, 'Got 2 prop');
$t->is($props[0]['tag'], 'Brussels', 'Brussels is showed');
$props = Doctrine::getTable('TagGroups')->getPropositions('brussels', 'administrative area', 'city');
$t->is(count($props), 3, 'We got 3 props');
$t->isnt($props[0]['tag'], 'Big White Mountain', 'Purpose from only 1 group');
$t->info('fetchTag');
$gtu = Doctrine::getTable('Gtu')->findOneByCode('irsnb');
$tags = Doctrine::getTable('TagGroups')->fetchTag(array($gtu->getId()));
$t->is(count($tags), 1, 'We got 1 gtu');
$t->is(count($tags[$gtu->getId()]), 2, 'We got 2 group');
$t->is($tags[$gtu->getId()][0]->getGroupName(), 'administrative area', 'administrative is the  group');
$t->is($tags[$gtu->getId()][0]->getSubGroupName(), 'country', 'country is the sub group');
$t->is(count($tags[$gtu->getId()][0]->Tags), 4, 'We got 4 tags');
$t->is(TagGroups::getGroup('populated'), 'Populated Places', 'Get a Tag group');
 * file and the NOTICE file that were distributed with this source code.
 */

$_app = 'mobile_frontend';
include(dirname(__FILE__).'/../../bootstrap/unit.php');
include dirname(__FILE__).'/../../bootstrap/functional.php';
include dirname(__FILE__).'/../../bootstrap/database.php';

$t = new lime_test();
$browser = new opTestFunctional(new opBrowser(), $t);
$browser->setMobile();
$browser->setCulture('en');

$table = Doctrine::getTable('IntroFriend');

$t->info('-- If removed the friend test --');

$t->diag('Before removing friend');
$t->is($table->createQuery()->count(), 6, 'count of intro_friend');
$t->isa_ok($table->find(1), 'IntroFriend', 'introductory of friend is exist(1 > 3)');
$t->isa_ok($table->find(2), 'IntroFriend', 'introductory of friend is exist(3 > 1)');

$browser
  ->info('Login')
  ->login('*****@*****.**', 'password')

  ->info('unlink friend')
  ->get('/friend/unlink/3')
  ->click('Yes')
;
Пример #17
0
    if ($contentTypeModelName) {
        $t->is($contentTypeName, $contentTypeModelName, sprintf('getContentTypeForPlugin() returns the content type "%s"', $contentTypeName));
        $contentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName($contentTypeName);
        $t->is($contentType['name'], $contentTypeName, 'Test content type name set');
        $t->is($contentType['label'], sfInflector::humanize(sfInflector::tableize(str_replace('sfSympal', null, $contentTypeName))), 'Test content type label set');
        $contentList = Doctrine_Core::getTable('sfSympalContentList')->findOneByContentTypeId($contentType['id']);
        $t->is($contentList instanceof sfSympalContentList, true, 'Test sample content list was created.');
        $menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneByContentId($contentList['content_id']);
        $t->is($menuItem instanceof sfSympalMenuItem, true, 'Test menu item to sample content list was created.');
    } else {
        $t->is($contentTypeName, false, '->getContentTypeForPlugin() return false, there is not content type');
    }
}
function uninstallPlugin($name, $t, $delete = true)
{
    $manager = sfSympalPluginManager::getActionInstance($name, 'uninstall');
    $manager->uninstall($delete);
    $t->is(file_exists(sfConfig::get('sf_plugins_dir') . '/' . $name), !$delete, 'Test plugin was was deleted');
    $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/model/doctrine/' . $name), !$delete, 'Test plugin models were deleted');
    $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/form/doctrine/' . $name), !$delete, 'Test plugin forms were deleted');
    $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/filter/doctrine/' . $name), !$delete, 'Test plugin form filters were deleted');
    $t->is(file_exists(sfConfig::get('sf_web_dir') . '/' . $name), !$delete, 'Test plugin assets symlink was removed');
}
$t->info('1 - Uninstalling sfSympalBlogPlugin...');
uninstallPlugin('sfSympalBlogPlugin', $t, false);
$t->info('2 - Installing sfSympalBlogPlugin...');
installPlugin('sfSympalBlogPlugin', $t, 'sfSympalBlogPost');
$t->info('3 - Uninstalling sfSympalCommentsPlugin...');
uninstallPlugin('sfSympalCommentsPlugin', $t, false);
$t->info('4 - Installing sfSympalCommentsPlugin');
installPlugin('sfSympalCommentsPlugin', $t, false);
<?php

require_once dirname(__FILE__) . '/../bootstrap/bootstrap.php';
$t = new lime_test();
$categories = Doctrine::getTable('SortableArticleCategory')->findAll();
$t->info('Create Sortable Sample Set');
Doctrine::getTable('SortableArticleUniqueBy')->createQuery()->delete()->execute();
$a1 = new SortableArticleUniqueBy();
$a1->name = 'First Article';
$a1->Category = $categories[0];
$a1->save();
$a2 = new SortableArticleUniqueBy();
$a2->name = 'Second Article';
$a2->Category = $categories[0];
$a2->save();
$a3 = new SortableArticleUniqueBy();
$a3->name = 'Third Article';
$a3->Category = $categories[1];
$a3->save();
$a4 = new SortableArticleUniqueBy();
$a4->name = 'Fourth Article';
$a4->Category = $categories[1];
$a4->save();
$a5 = new SortableArticleUniqueBy();
$a5->name = 'Fifth Article';
$a5->Category = $categories[1];
$a5->save();
$t->info('Assert articles have the correct position');
$t->is($a1['position'], 1, 'First item saved has position of 1 (first in category 1)');
$t->is($a2['position'], 2, 'Second item saved has position of 2 (second in category 1)');
$t->is($a3['position'], 1, 'Third item saved has position of 1 (first in category 2)');
<?php

require_once dirname(__FILE__) . '/../../../bootstrap/functional.php';
require_once $_SERVER['SYMFONY'] . '/vendor/lime/lime.php';
require_once sfConfig::get('sf_lib_dir') . '/test/unitHelper.php';
$t = new lime_test(188);
$t->info('1 - Test getChildrenIndexedByName().');
extract(create_doctrine_test_tree($t));
// create the tree and make its vars accessible
print_test_tree($t);
$children = $rt->getChildrenIndexedByName();
$t->is(count($children), 2, '->getChildrenIndexedByName() returns 2 for rt');
$t->is(array_keys($children), array('Parent 1', 'Parent 2'), '->getChildrenIndexedByName() has the correct indexes');
$t->is($children['Parent 1']->name, 'Parent 1', '->getChildrenIndexedByName() returns the correct items.');
$t->is(count($pt1->getChildrenIndexedByName()), 3, '->getChildrenIndexedByName() returns 3 item for pt1.');
$t->is(count($pt2->getChildrenIndexedByName()), 1, '->getChildrenIndexedByName() returns 1 item for pt2.');
$t->info('2 - Test persistFromMenuArray() in a varierty of situations.');
$menu = new ioMenuItem('Root li');
$t->info('  2.1 - First try it without any children - should just update root values.');
$t->info('    2.1.1 - Persist a menu with mostly blank fields.');
$rt = create_root('rt');
$menu->setAttributes(array());
// clear the default "root" class attribute
$rt->persistFromMenuArray($menu->toArray(false));
$t->is($rt->getName(), 'Root li', '->getName() returns "Root li".');
$t->is($rt->getLabel(), null, '->getLabel() returns null.');
$t->is($rt->getRoute(), null, '->getRoute() returns null.');
$t->is($rt->getAttributes(), '', '->getAttributes() returns an empty string.');
$t->is($rt->getRequiresAuth(), false, '->getRequiresAuth() returns false.');
$t->is($rt->getRequiresNoAuth(), false, '->getRequiresNoAuth() returns false.');
$t->is(count($rt->Permissions), 0, '->Permissions matches 0 items');
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(5, new lime_output_color());
$t->info('Get informations for User "root"');
$users = Doctrine::getTable('Users')->getUserByPassword("root", "evil");
$userInfo = Doctrine::getTable('UsersLoginInfos')->getInfoForUser($users->getId());
$t->is($userInfo->count(), 1, '"1" Login info');
$t->is($userInfo[0]->getLoginType(), 'local', 'The login type is well "local"');
$t->is($userInfo[0]->getLoginSystem(), '', 'There are "no" login system encoded');
$userInfo[0]->setLoginSystem('local');
$userInfo[0]->save();
$t->is($userInfo[0]->getLoginSystem(), 'local', 'The login system is well "local" now');
$t->info('Test to get users with system brol :)');
$userInfo = Doctrine::getTable('UsersLoginInfos')->getInfoForUser($users->getId(), 'brol');
$t->is($userInfo->count(), 0, '"No" user with system Brol... and it is normal ! :)');
Пример #21
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(3, new lime_output_color());
$userEvil = Doctrine::getTable('Users')->findOneByFamilyName('Evil')->getId();
$t->info('getEncodingRightsForUser( Evil )');
$cat = Doctrine::getTable('LoanRights')->getEncodingRightsForUser($userEvil);
$t->is(count($cat), 5, 'Number of loan rights for user Evil: "5"');
$t->is(Doctrine::getTable('LoanRights')->isAllowed($userEvil, 3), FALSE, 'Evil don\'t have right on loan "3"');
$t->is(Doctrine::getTable('LoanRights')->isAllowed($userEvil, 6), 'view', 'Evil only have read right on loan "6"');
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(2, new lime_output_color());
$t->info('Get languages for person "root"');
$personId = Doctrine::getTable('People')->findOneByFamilyName('Root')->getId();
$personLanguage = new PeopleLanguages();
$personLanguage->setPeopleRef($personId);
$personLanguage->setLanguageCountry('fr_be');
$personLanguage->setPreferredLanguage(true);
$personLanguage->save();
$personLanguages = Doctrine::getTable('PeopleLanguages')->findByPeopleRef($personId);
$t->is($personLanguages[0]->getPreferredLanguage(), true, 'Language "' . $personLanguages[0]->getLanguageCountry() . '" is well the "preferred" language');
$t->info('Reset now preferred languages');
Doctrine::getTable('PeopleLanguages')->removeOldPreferredLang($personId);
$personLanguages = Doctrine::getTable('PeopleLanguages')->findByPeopleRef($personId);
$t->is($personLanguages[0]->getPreferredLanguage(), false, 'Language "' . $personLanguages[0]->getLanguageCountry() . '" is now "preferred" language "no more"');
Пример #23
0
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new lime_test(5);
$t->info('1 - Test that the delete recurses on the application level to the sfSympalContent records');
$site = Doctrine_Core::getTable('sfSympalSite')->findOneBySlug('sympal');
$pages = Doctrine_Core::getTable('sfSympalPage')->createQuery()->execute();
$t->isnt(count($site->Content), 0, 'Sanity check: the sfSympalSite record has at least one Content record');
$t->isnt(count($pages), 0, 'Sanity check: We begin with more than 0 sfSympalPage objects');
$site->delete();
$site->refreshRelated('Content');
$pages = Doctrine_Core::getTable('sfSympalPage')->createQuery()->execute();
$t->is(count($site->Content), 0, 'The site now has no content. This would happen with or without the application-level delete recursion');
$t->is(count($pages), 0, 'All of the sfSympalPage records are gone due to the application-level delete recursion onto sfSympalContent');
$t->info('2 - Quick check on ->deleteApplication');
$site->deleteApplication();
$t->is(file_exists(sfConfig::get('sf_app_dir')), false, 'The application directory no longer exists');
Пример #24
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/functional.php';
require_once $_SERVER['SYMFONY'] . '/vendor/lime/lime.php';
$t = new lime_test(3);
class ioMenuItemTest extends ioMenuItem
{
}
$t->info('1 - Basic checks on the ioMenu object');
$menu = new ioMenu(array('class' => 'root'), 'ioMenuItemTest');
$ch1 = $menu->addChild('ch1');
$t->is($menu->getName(), null, 'The menu item has a null name');
$t->is($menu->getRoute(), null, 'The menu item has a null route');
$t->is(get_class($ch1), 'ioMenuItemTest', 'The children are created with the class passed into the constructor.');
Пример #25
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(6, new lime_output_color());
$t->info('Get autocomplete results');
$entries = Doctrine::getTable('Taxonomy')->completeAsArray('', 'Falco peregrinus', '', 30, '');
$t->info('Get "Falco peregrinus" count');
$t->is(count($entries), 5, 'There is a good number of results');
$t->info('Get "Falco peregrinus tun" count');
$entries = Doctrine::getTable('Taxonomy')->completeAsArray('', 'Falco peregrinus tun', '', 30, '');
$t->is(count($entries), 1, 'There is a good number of results');
$t->info('Get "Falco" entries allowed to be connected as parent for a species count');
$entries = Doctrine::getTable('Taxonomy')->completeAsArray('', 'Falco', '', 30, 48);
$t->is(count($entries), 4, 'There is a good number of results');
$t->info('Get "Falco" entries allowed to be connected as parent for a genus count');
$entries = Doctrine::getTable('Taxonomy')->completeAsArray('', 'Falco', '', 30, 41);
$t->is(count($entries), 3, 'There is a good number of results');
$t->info('Get "Falco Fam" entries allowed to be connected as parent for a genus with exact option activated count');
$entries = Doctrine::getTable('Taxonomy')->completeAsArray('', 'Falco Fam', '1', 30, 41);
$t->is(count($entries), 1, 'There is a good number of results');
$t->info('Test other method: completeWithLevelAsArray');
$entries = Doctrine::getTable('Taxonomy')->completeWithLevelAsArray('', 'Falco Fam', '1', 30, 41);
$t->is(count($entries), 1, 'There is a good number of results');
Пример #26
0
<?php

include_once dirname(__FILE__) . '/../bootstrap/bootstrap.php';
include_once dirname(__FILE__) . '/../../lib/vendor/amazon/sdk.class.php';
$t = new lime_test();
$aws_access_key = sfConfig::get('app_sf_amazon_plugin_access_key');
$aws_secret_key = sfConfig::get('app_sf_amazon_plugin_secret_key');
$t->info($aws_access_key);
$t->info($aws_secret_key);
if (!$aws_access_key || !$aws_secret_key) {
    $t->fail('Set your keys');
    exit;
}
$ec2 = new AmazonEC2($aws_access_key, $aws_secret_key);
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(4, new lime_output_color());
$tools = Doctrine::getTable('CollectingTools')->fetchTools();
$t->is(count($tools), 2, '"2" Tools defined by default');
$t->info('Insert a new value');
$newVal = new CollectingTools();
$newVal->setTool('Bourouche');
$newVal->save();
$newValIndex = $newVal->getId();
$tools = Doctrine::getTable('CollectingTools')->fetchTools();
$t->is(count($tools), 3, '"3" Tools defined now');
$t->is($tools[$newValIndex], 'Bourouche', 'The new value inserted is well "Bourouche"');
$iteration = 1;
foreach ($tools as $value) {
    if ($iteration == 2) {
        $t->is($value, 'Bourouche', 'The new value ("Bourouche") is well the "second" one to be in the list brought by "fetchTools"');
        break;
    }
    $iteration++;
}
<?php

require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
require_once $_SERVER['SYMFONY'] . '/vendor/lime/lime.php';
$dispatcher = $configuration->getEventDispatcher();
$t = new lime_test();
$t->info('1 - Test some basic getters and setters');
$service = new ioEditableContentService($context->getUser(), $dispatcher, array('test_option' => 'test_val'));
$t->is($service->getOption('test_option', 'default'), 'test_val', '->getOption() works for options passed in the constructor');
$service->setOption('new_option', 'foo');
$t->is($service->getOption('new_option'), 'foo', '->setOption() sets the option value correctly');
$t->is($service->getOption('fake_option', 'bar'), 'bar', '->getOption() on a nonexistent option returns the default value.');
$t->info('2 - Test shouldShowEditor()');
$service = new ioEditableContentService($context->getUser(), $dispatcher);
$t->is($service->shouldShowEditor(null, true), false, '->shouldShowEditor() returns false: no credential passed in, but we still require auth.');
$context->getUser()->setAuthenticated(true);
$t->is($service->shouldShowEditor(null, true), true, '->shouldShowEditor() returns true if no credential is passed to require.');
$service->setOption('admin_credential', 'test_edit_credential');
$t->is($service->shouldShowEditor(null, true), false, '->shouldShowEditor() returns false: the user does not have the credential');
$context->getUser()->addCredential('test_edit_credential');
$t->is($service->shouldShowEditor(null, true), true, '->shouldShowEditor() returns true: the user has the proper credential');
$t->info('3 - Test getContent()');
$service = new ioEditableContentService($context->getUser(), $dispatcher);
$blog = new Blog();
$blog->title = 'Unit test blog';
$blog->body = 'Lorem Ipsum';
$blog->save();
$t->info('  3.1 - Test a single-field, no partial rendering');
$result = $service->getContent($blog, array('title'));
$t->is($result, 'Unit test blog', '->getContent() returns the correct value');
$t->info('  3.2 - Test multiple fields, no partial - throws an exception');
Пример #29
0
<?php

include dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(4, new lime_output_color());
$t->info('Get the tags for "Telephone" type');
$tags = Doctrine::getTable('UsersComm')->getTags('phone/fax');
$t->is(count($tags), 7, 'There are well "7" tags');
$t->is($tags['cell'], 'Cell', 'Tags "Cell" is well defined');
$tags = Doctrine::getTable('UsersComm')->getTags('e-mail');
$t->is(count($tags), 4, 'There are well "4" tags');
$t->is($tags['cell'], '', 'Tags "Cell" is not defined... normal :)');
Пример #30
0
<?php

include dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(79, new lime_output_color());
$t->info('FuzzyDateTime instanciation');
$t->isa_ok(new FuzzyDateTime(), 'FuzzyDateTime', 'New creates an object of the right class');
$t->can_ok(new FuzzyDateTime(), 'getDateTimeStringFromArray', 'Object FuzzyDateTime has a method named: getDateTimeStringFromArray');
$t->can_ok(new FuzzyDateTime(), 'checkDateArray', 'Object FuzzyDateTime has a method named: checkDateArray');
$t->can_ok(new FuzzyDateTime(), 'setMask', 'Object FuzzyDateTime has a method named: setMask');
$t->can_ok(new FuzzyDateTime(), 'setStart', 'Object FuzzyDateTime has a method named: setStart');
$t->can_ok(new FuzzyDateTime(), 'setWithTime', 'Object FuzzyDateTime has a method named: setWithTime');
$t->can_ok(new FuzzyDateTime(), 'setdateFormat', 'Object FuzzyDateTime has a method named: setDateFormat');
$t->can_ok(new FuzzyDateTime(), 'setTimeFormat', 'Object FuzzyDateTime has a method named: setTimeFormat');
$t->can_ok(new FuzzyDateTime(), 'getMask', 'Object FuzzyDateTime has a method named: getMask');
$t->can_ok(new FuzzyDateTime(), 'getStart', 'Object FuzzyDateTime has a method named: getStart');
$t->can_ok(new FuzzyDateTime(), 'getWithTime', 'Object FuzzyDateTime has a method named: getWithTime');
$t->can_ok(new FuzzyDateTime(), 'getDateFormat', 'Object FuzzyDateTime has a method named: getDateFormat');
$t->can_ok(new FuzzyDateTime(), 'getTimeFormat', 'Object FuzzyDateTime has a method named: getTimeFormat');
$t->can_ok(new FuzzyDateTime(), 'setMaskFromDate', 'Object FuzzyDateTime has a method named: setMaskFromDate');
$t->can_ok(new FuzzyDateTime(), 'getMaskFromDate', 'Object FuzzyDateTime has a method named: getMaskFromDate');
$t->can_ok(new FuzzyDateTime(), 'getMaskFor', 'Object FuzzyDateTime has a method named: getMaskFor');
$t->can_ok(new FuzzyDateTime(), 'getDateTime', 'Object FuzzyDateTime has a method named: getDateTime');
$t->can_ok(new FuzzyDateTime(), 'getDateTimeAsArray', 'Object FuzzyDateTime has a method named: getDateTimeAsArray');
$t->can_ok(new FuzzyDateTime(), 'getDateMasked', 'Object FuzzyDateTime has a method named: getDateMasked');
$t->can_ok(new FuzzyDateTime(), '__ToString', 'Object FuzzyDateTime has a method named: __ToString');
$fdt = new FuzzyDateTime();
$currentDate = $fdt->format('d/m/Y');
$currentDateTime = $fdt->format('d/m/Y H:i:s');
$t->is($fdt->getDateTime(), $currentDate, 'Get the date coming with the FuzzyDateTime object instanciation');
$t->is($fdt->getDateTime(true), $currentDateTime, 'Get the date and time coming with the FuzzyDateTime object instanciation: ok');
$fdt->setStart(false);