Example #1
0
 /**
  * Test that legacy bootstrap has been autoloaded and
  * stay BC with older test cases
  */
 public function testIsBoostrapped()
 {
     $this->assertInstanceOf(Di\ServiceProvider::class, _elgg_services());
     $this->assertInstanceOf(Application::class, _elgg_testing_application());
     $this->assertInstanceof(Config::class, _elgg_testing_config());
     $this->assertInstanceOf(Http\Request::class, _elgg_testing_request());
 }
Example #2
0
 /**
  * Inspect instances in DI container to get correct classnames for
  * Database API.
  */
 public function setUp()
 {
     $db = _elgg_testing_application()->getDb();
     $this->dbClass = get_class($db);
     // Config class
     $reflectionClass = new ReflectionClass($db);
     $reflectionProperty = $reflectionClass->getProperty('config');
     if (method_exists($reflectionProperty, 'setAccessible')) {
         $reflectionProperty->setAccessible(true);
         $config = $reflectionProperty->getValue($db);
         $this->configClass = get_class($config);
     } else {
         $this->configClass = 'Elgg_Database_Config';
     }
 }
 public function setUp()
 {
     $app = _elgg_testing_application();
     $dataroot = _elgg_testing_config()->getDataPath();
     $session = \ElggSession::getMock();
     _elgg_services()->setValue('session', $session);
     _elgg_services()->session->start();
     $site_secret_mock = $this->getMockBuilder('\\Elgg\\Database\\SiteSecret')->getMock();
     $site_secret_mock->method('init')->willReturn('strongSiteSecret1234567890');
     _elgg_services()->setValue('siteSecret', $site_secret_mock);
     $this->handler = new ServeFileHandler($app);
     $file_mock = $this->getMockBuilder('\\ElggFile')->disableOriginalConstructor()->getMock();
     $file_mock->method('getFileNameOnFilestore')->willReturn("{$dataroot}file_service/foobar.txt");
     $file_mock->method('exists')->willReturn(true);
     $this->file = $file_mock;
 }
Example #4
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);
});
Example #5
0
 public function setUp()
 {
     $this->handler = new CacheHandler(_elgg_testing_application(), _elgg_testing_config(), []);
 }
Example #6
0
 function testElggReturnsApp()
 {
     $app = _elgg_testing_application();
     $this->assertSame($app, elgg());
 }