public function testStreamConnection()
 {
     $config = array('type' => 'Http', 'socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
     Connections::add('stream-test', $config);
     $result = Connections::get('stream-test');
     $this->assertTrue($result instanceof Http);
     Connections::config(array('stream-test' => false));
 }
 /**
  * Tests Collection accessors (getters/setters).
  */
 public function testAccessorMethods()
 {
     Connections::config(array('mock-source' => array('type' => 'lithium\\tests\\mocks\\data\\MockSource')));
     $model = $this->_model;
     $model::config(array('connection' => false, 'key' => 'id'));
     $collection = new DocumentSet(compact('model'));
     $this->assertEqual($model, $collection->model());
     $this->assertEqual(compact('model'), $collection->meta());
 }
Exemple #3
0
 public function testStreamConnection()
 {
     $config = array('type' => 'Http', 'socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
     Connections::add('stream-test', $config);
     $result = Connections::get('stream-test');
     $this->assertInstanceOf('lithium\\data\\source\\Http', $result);
     Connections::config(array('stream-test' => false));
 }
Exemple #4
0
 public function tearDown()
 {
     Connections::reset();
     Connections::config($this->_configs);
 }
Exemple #5
0
    if (!empty($solution)) {
        $default = array('id' => 'help-' . $checkName, 'title' => $checkName, 'content' => null);
        if (is_array($solution['content'])) {
            $solution['content'] = join("\n<br />", $solution['content']);
        }
        $solutions[$checkName] = $solution += $default;
    }
    return "<div class=\"test-result test-result-{$status}\">{$message}</div>";
};
$sanityChecks = array('resourcesWritable' => function () use($notify) {
    if (is_writable($path = realpath(LITHIUM_APP_PATH . '/resources'))) {
        return $notify(true, 'Resources directory is writable.');
    }
    return $notify(false, array("Your resource path (<code>{$path}</code>) is not writeable. " . "To fix this on *nix and Mac OSX, run the following from the command line:", "<code>chmod -R 0777 {$path}</code>"));
}, 'database' => function () use($notify) {
    $config = Connections::config();
    $boot = realpath(LITHIUM_APP_PATH . '/config/bootstrap.php');
    $connections = realpath(LITHIUM_APP_PATH . '/config/bootstrap/connections.php');
    if (empty($config)) {
        return $notify('notice', array('No database connections defined.'), array('title' => 'Database Connections', 'content' => array('To create a database connection, edit the file <code>' . $boot . '</code>, ', 'and uncomment the following line:', '<pre><code>require __DIR__ . \'/bootstrap/connections.php\';</code></pre>', 'Then, edit the file <code>' . $connections . '</code>.')));
    }
    return $notify(true, 'Database connection(s) configured.');
}, 'magicQuotes' => function () use($notify) {
    if (get_magic_quotes_gpc() === 0) {
        return;
    }
    return $notify(false, array("Magic quotes are enabled in your PHP configuration. Please set <code>" . "magic_quotes_gpc = Off</code> in your <code>php.ini</code> settings."));
}, 'registerGlobals' => function () use($notify) {
    if (!ini_get('register_globals')) {
        return;
    }
Exemple #6
0
    if (!ini_get('register_globals')) {
        return;
    }
    return $notify('error', 'Register globals is enabled in your PHP configuration', 'Please set <code>register_globals = Off</code> in your <code>php.ini</code> settings.');
}, 'curlwrappers' => function () use($notify, $compiled) {
    if (!$compiled('with-curlwrappers')) {
        return;
    }
    return $notify('error', 'Curlwrappers are enabled, some things might not work as expected.', "This is an expiremental and usually broken feature of PHP.\n\t\t\tPlease recompile your PHP binary without using the <code>--with-curlwrappers</code>\n\t\t\tflag or use a precompiled binary that was compiled without the flag.");
}, 'shortOpenTag' => function () use($notify, $compiled) {
    if (!ini_get('short_open_tag')) {
        return;
    }
    return $notify('warning', 'Short open tags are enabled, you may want to disable them.', "It is recommended to not rely on this option being enabled.\n\t\t\tTo increase the portability of your code disable this option by setting\n\t\t\t<code>short_open_tag = Off</code> in your <code>php.ini</code>.");
}, 'database' => function () use($notify) {
    if ($config = Connections::config()) {
        return $notify('success', 'Database connection(s) configured');
    }
    return $notify('warning', 'No database connection defined', "To create a database connection:\n\t\t\t<ol>\n\t\t\t\t<li>Edit the file <code>config/bootstrap.php</code>.</li>\n\t\t\t\t<li>\n\t\t\t\t\tUncomment the line having\n\t\t\t\t\t<code>require __DIR__ . '/bootstrap/connections.php';</code>.\n\t\t\t\t</li>\n\t\t\t\t<li>Edit the file <code>config/bootstrap/connections.php</code>.</li>\n\t\t\t</ol>");
}, 'change' => function () use($notify, $self) {
    $template = $self->html->link('template', 'http://li3.me/docs/lithium/template');
    return $notify('warning', "You're using the application's default home page", "To change this {$template}, edit the file\n\t\t\t<code>views/pages/home.html.php</code>.\n\t\t\tTo change the layout,\n\t\t\t(that is what's wrapping content)\n\t\t\tedit the file <code>views/layouts/default.html.php</code>.");
}, 'dbSupport' => function () use($support) {
    $paths = array('data.source', 'adapter.data.source.database', 'adapter.data.source.http');
    $list = array();
    foreach ($paths as $path) {
        $list = array_merge($list, Libraries::locate($path, null, array('recursive' => false)));
    }
    $list = array_filter($list, function ($class) {
        return method_exists($class, 'enabled');
    });
Exemple #7
0
 public function testRelationshipGeneration()
 {
     Connections::add('mock-source', $this->_testConfig);
     $from = 'lithium\\tests\\mocks\\data\\MockComment';
     $to = 'lithium\\tests\\mocks\\data\\MockPost';
     $from::config(array('connection' => 'mock-source'));
     $to::config(array('connection' => 'mock-source'));
     $result = $this->db->relationship($from, 'belongsTo', 'MockPost');
     $expected = compact('from', 'to') + array('name' => 'MockPost', 'type' => 'belongsTo', 'keys' => array('mockComment' => '_id'), 'link' => 'contained', 'conditions' => null, 'fields' => true, 'fieldName' => 'mockPost', 'init' => true);
     $this->assertEqual($expected, $result->data());
     Connections::config(array('mock-source' => false));
 }
Exemple #8
0
 public function tearDown()
 {
     Connections::config(array('mock-source' => false));
     Connections::config($this->_configs);
 }
 public function tearDown()
 {
     Connections::reset();
     Connections::config($this->_backup['connections']);
 }