Пример #1
0
 public function testCommand()
 {
     $command = $this->getMockBuilder('PSX\\Console\\Generate\\BootstrapCacheCommand')->setMethods(array('makeDir', 'writeFile', 'getFiles'))->getMock();
     $command->expects($this->at(0))->method('getFiles')->will($this->returnValue(array(__DIR__ . '/BootstrapCache/Bar.php', __DIR__ . '/BootstrapCache/Foo.php')));
     $command->expects($this->at(1))->method('writeFile')->with($this->equalTo('cache/bootstrap.cache.php'), $this->callback(function ($source) {
         Assert::assertStringMatchIgnoreWhitespace($this->getExpectedSource(), $source);
         return true;
     }));
     $commandTester = new CommandTester($command);
     $commandTester->execute(array());
 }
Пример #2
0
    public function testTraverseTextLong()
    {
        $visitor = new TextWriterVisitor();
        $record = new Record('foo', array('title' => 'Lorem ipsum dolor' . "\n" . 'sit amet, consetetur sadipscin'));
        $graph = new GraphTraverser();
        $graph->traverse($record, $visitor);
        $except = <<<TEXT
Object(foo){
    title = Lorem ipsum dolor sit amet, cons (...)
}

TEXT;
        Assert::assertStringMatchIgnoreWhitespace($except, $visitor->getOutput());
    }
Пример #3
0
    public function testExceptionHtml()
    {
        Environment::getService('config')->set('psx_debug', false);
        //Environment::getService('template')->set(null);
        $response = $this->sendRequest('http://127.0.0.1/error', 'GET', ['Accept' => 'text/html']);
        $body = (string) $response->getBody();
        $expect = <<<HTML
<!DOCTYPE>
<html>
<head>
\t<title>Internal Server Error</title>
\t<style type="text/css">
\tbody
\t{
\t\tmargin:0px;
\t\tfont-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
\t\tfont-size:14px;
\t\tline-height:1.42857143;
\t}

\t.title
\t{
\t\tbackground-color:#f2dede;
\t\tcolor:#a94442;
\t\tpadding:8px;
\t\tpadding-left:32px;
\t}

\t.title h1
\t{
\t\tmargin:0px;
\t}

\t.message
\t{
\t\tbackground-color:#333;
\t\tcolor:#fff;
\t\tpadding:8px;
\t\tpadding-left:32px;
\t}

\t.trace
\t{
\t\tbackground-color:#ececec;
\t\tpadding:8px;
\t\tpadding-left:32px;
\t\tmargin-bottom:8px;
\t}

\t.trace pre
\t{
\t\tmargin:0px;
\t}

\t.context
\t{
\t\tbackground-color:#ececec;
\t\tpadding:8px;
\t\tpadding-left:32px;
\t}

\t.context pre
\t{
\t\tmargin:0px;
\t}
\t</style>
</head>

<body>

<div class="title">
\t<h1>Internal Server Error</h1>
</div>

<div class="message">
\tThe server encountered an internal error and was unable to complete your request.</div>



</body>
</html>

HTML;
        $this->assertEquals(null, $response->getStatusCode(), $body);
        Assert::assertStringMatchIgnoreWhitespace($expect, $body);
    }