Ejemplo n.º 1
0
<?php

include __DIR__ . '/../vendor/autoload.php';
\PMVC\Load::plug();
\PMVC\addPlugInFolders([__DIR__ . '/../../']);
Ejemplo n.º 2
0
<?php

require 'vendor/autoload.php';
use PMVC\PlugIn\pagination as pg;
\PMVC\Load::plug(['pagination' => null], ['../']);
$p = \PMVC\plug('pagination', [pg\TOTAL => 33, pg\BEGIN => 4, pg\PRE_PAGE_NUM => 5]);
$page = $p->process();
var_dump($page);
Ejemplo n.º 3
0
<?php

namespace PMVC\PlugIn\cache_header;

use PHPUnit_Framework_TestCase;
\PMVC\Load::plug(['controller' => null]);
\PMVC\addPlugInFolders(['../']);
class CacheHeaderTest extends PHPUnit_Framework_TestCase
{
    private $_plug = 'cache_header';
    function teardown()
    {
        \PMVC\unplug($this->_plug);
    }
    function testGetCacheHeader()
    {
        $headers = \PMVC\plug($this->_plug)->getCacheHeader(0);
        $expected = 'Cache-Control: no-store, no-cache, must-revalidate';
        $this->assertEquals($expected, $headers[0]);
    }
    function testSetHeader()
    {
        $now = time();
        \PMVC\option('set', _ROUTER, 'fake_router');
        $router = \PMVC\plug('fake_router', [_CLASS => __NAMESPACE__ . '\\fakePlugIn']);
        $pCache = \PMVC\plug($this->_plug, [[10, 'public', $now]]);
        $expected = ['Cache-Control: max-age=10, public', 'Last-Modified: ' . $pCache->getGmt($now), 'Expires: ' . $pCache->getGmt($now + 10)];
        $this->assertEquals($expected, $router['headers']);
    }
}
class fakePlugIn extends \PMVC\PlugIn
Ejemplo n.º 4
0
<?php

namespace PMVC\PlugIn\dev;

use PHPUnit_Framework_TestCase;
use PMVC\PlugIn\debug\DebugDumpInterface;
\PMVC\Load::plug(['debug' => null]);
\PMVC\addPlugInFolders(['../']);
class DevTest extends PHPUnit_Framework_TestCase
{
    private $_plug = 'dev';
    function testPlugin()
    {
        ob_start();
        print_r(\PMVC\plug($this->_plug));
        $output = ob_get_contents();
        ob_end_clean();
        $this->assertContains($this->_plug, $output);
    }
    function testIsDevForUnPlug()
    {
        \PMVC\unplug($this->_plug);
        $this->assertFalse(\PMVC\isDev('trace'));
    }
    function testIsDevForHidden()
    {
        \PMVC\plug($this->_plug);
        $d = \PMVC\plug('debug');
        $d['level'] = 'debug';
        $this->assertFalse(\PMVC\isDev('trace'));
    }
Ejemplo n.º 5
0
<?php

include_once '../vendor/autoload.php';
\PMVC\Load::plug(['controller' => null, 'dispatcher' => null, 'error' => ['all'], 'debug' => null, 'dotenv' => ['../.env'], 'app_action_router' => null]);
$controller = \PMVC\plug('controller');
if ($controller->plugApp()) {
    $controller->process();
}
Ejemplo n.º 6
0
<?php

namespace PMVC\PlugIn\static_map;

use PHPUnit_Framework_TestCase;
\PMVC\Load::plug([], ['../']);
class StaticMapTest extends PHPUnit_Framework_TestCase
{
    private $_plug = 'static_map';
    function testPlugin()
    {
        ob_start();
        print_r(\PMVC\plug($this->_plug));
        $output = ob_get_contents();
        ob_end_clean();
        $this->assertContains($this->_plug, $output);
    }
    public function testToStreet()
    {
        $map = \PMVC\plug($this->_plug);
        $map['center'] = '46.414382,10.013988';
        $expected = 'https://maps.googleapis.com/maps/api/streetview?location=46.414382%2C10.013988&size=640x300';
        $this->assertEquals($expected, $map->toStreet());
    }
}
Ejemplo n.º 7
0
<?php

include_once './vendor/autoload.php';
\PMVC\Load::plug(['dotenv' => ['./.env']]);
\PMVC\addPlugInFolders(['../']);
$algo = \PMVC\plug('algolia');
$park = $algo->getdb('parking');
$result = $park->search('"' . \PMVC\getOption('QUERY') . '"', ['minProximity' => 1, 'minWordSizefor1Typo' => 1, 'advancedSyntax' => true, 'attributes' => 'doc.name,doc.info', 'attributesToHighlight' => 'doc.name', 'restrictSearchableAttributes' => 'doc.name', 'disableTypoToleranceOnAttributes' => 'doc.name', 'queryType' => 'prefixNone', 'distinct' => true, 'typoTolerance' => 'false', 'removeStopWords' => false]);
var_dump($result);
Ejemplo n.º 8
0
<?php

namespace PMVC\PlugIn\debug;

use PHPUnit_Framework_TestCase;
\PMVC\Load::plug(['debug' => null], ['../']);
class DebugConsoleTest extends PHPUnit_Framework_TestCase
{
    private $_plug = 'debug';
    function testDebugConsole()
    {
        ob_start();
        print_r(\PMVC\plug($this->_plug));
        $output = ob_get_contents();
        ob_end_clean();
        $this->assertContains($this->_plug, $output);
    }
    function testGetOutput()
    {
        $debug = \PMVC\plug($this->_plug);
        $debug['output'] = \PMVC\plug('output', [_CLASS => __NAMESPACE__ . '\\fakeOutput']);
        $o = $debug->getOutput();
        $this->assertContains('output', print_r($o, true));
    }
}
class fakeOutput extends \PMVC\PlugIn implements DebugDumpInterface
{
    public function escape($string)
    {
    }
    public function dump($p, $type = 'info')