Пример #1
0
 public function testPropertiesReturnCorrectClassNames()
 {
     $mgr = $this->getMock('\\Elgg\\AutoloadManager', array(), array(), '', false);
     $sp = new \Elgg\Di\ServiceProvider($mgr);
     $sp->setValue('session', new \ElggSession(new \Elgg\Http\MockSessionStorage()));
     $svcClasses = array('access' => '\\Elgg\\Access', 'accessCache' => '\\ElggStaticVariableCache', 'accessCollections' => '\\Elgg\\Database\\AccessCollections', 'actions' => '\\Elgg\\ActionsService', 'adminNotices' => '\\Elgg\\Database\\AdminNotices', 'annotations' => '\\Elgg\\Database\\Annotations', 'autoP' => '\\ElggAutoP', 'autoloadManager' => '\\Elgg\\AutoloadManager', 'config' => '\\Elgg\\Config', 'configTable' => '\\Elgg\\Database\\ConfigTable', 'datalist' => '\\Elgg\\Database\\Datalist', 'db' => '\\Elgg\\Database', 'entityTable' => '\\Elgg\\Database\\EntityTable', 'events' => '\\Elgg\\EventsService', 'externalFiles' => '\\Elgg\\Assets\\ExternalFiles', 'hooks' => '\\Elgg\\PluginHooksService', 'input' => '\\Elgg\\Http\\Input', 'logger' => '\\Elgg\\Logger', 'metadataCache' => '\\ElggVolatileMetadataCache', 'metadataTable' => '\\Elgg\\Database\\MetadataTable', 'metastringsTable' => '\\Elgg\\Database\\MetastringsTable', 'passwords' => '\\Elgg\\PasswordService', 'plugins' => '\\Elgg\\Database\\Plugins', 'request' => '\\Elgg\\Http\\Request', 'relationshipsTable' => '\\Elgg\\Database\\RelationshipsTable', 'router' => '\\Elgg\\Router', 'session' => '\\ElggSession', 'simpleCache' => '\\Elgg\\Cache\\SimpleCache', 'siteSecret' => '\\Elgg\\Database\\SiteSecret', 'stickyForms' => '\\Elgg\\Forms\\StickyForms', 'subtypeTable' => '\\Elgg\\Database\\SubtypeTable', 'systemCache' => '\\Elgg\\Cache\\SystemCache', 'translator' => '\\Elgg\\I18n\\Translator', 'usersTable' => '\\Elgg\\Database\\UsersTable', 'views' => '\\Elgg\\ViewsService', 'widgets' => '\\Elgg\\WidgetsService');
     foreach ($svcClasses as $key => $class) {
         $obj1 = $sp->{$key};
         $obj2 = $sp->{$key};
         $this->assertInstanceOf($class, $obj1);
         $this->assertSame($obj1, $obj2);
     }
 }
Пример #2
0
    return $inst;
}
/**
 * This is here as a temporary solution only. Instead of adding more global
 * state to this file as we migrate tests, try to refactor the code to be
 * testable without global state.
 */
global $CONFIG;
$CONFIG = (object) ['dbprefix' => 'elgg_', 'boot_complete' => false, 'wwwroot' => 'http://localhost/', 'path' => __DIR__ . '/../../../', 'dataroot' => __DIR__ . '/test_files/dataroot/', 'site_guid' => 1, 'AutoloaderManager_skip_storage' => true, 'simplecache_enabled' => false];
global $_ELGG;
$_ELGG = (object) ['view_path' => __DIR__ . '/../../../views/'];
function _elgg_testing_config(\Elgg\Config $config = null)
{
    static $inst;
    if ($config) {
        $inst = $config;
    }
    return $inst;
}
// PHPUnit will serialize globals between tests, so let's not introduce any globals here.
call_user_func(function () use($CONFIG) {
    $config = new \Elgg\Config($CONFIG);
    _elgg_testing_config($config);
    $sp = new \Elgg\Di\ServiceProvider($config);
    $sp->setValue('mailer', new InMemoryTransport());
    $app = new \Elgg\Application($sp);
    $app->loadCore();
    // persistentLogin service needs this set to instantiate without calling DB
    _elgg_configure_cookies($CONFIG);
    _elgg_testing_application($app);
});