Просмотр исходного кода

Comment blocks in procedures and partials no longer break validation - https://github.com/jonnnnyw/php-phantomjs/issues/103

Jonny Wenmoth 9 лет назад
Родитель
Сommit
50bc19d022
1 измененных файлов с 38 добавлено и 0 удалено
  1. 38 0
      src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php

+ 38 - 0
src/JonnyW/PhantomJs/Tests/Integration/ClientTest.php

@@ -72,6 +72,44 @@ EOF;
         $this->assertSame($content, $response->getContent());
     }
 
+    /**
+     * Test additional procedures can be loaded
+     * through chain loader if procedures
+     * contain comments
+     *
+     * @access public
+     * @return void
+     */
+    public function testAdditionalProceduresCanBeLoadedThroughChainLoaderIfProceduresContainComments()
+    {
+        $content = 'TEST_PROCEDURE';
+
+        $procedure = <<<EOF
+    console.log(JSON.stringify({"content": "$content"}, undefined, 4));
+    phantom.exit(1);
+    var test = function () {
+        // Test comment
+        console.log('test');
+    };
+EOF;
+
+        $this->writeProcedure($procedure);
+
+        $procedureLoaderFactory = $this->getContainer()->get('procedure_loader_factory');
+        $procedureLoader        = $procedureLoaderFactory->createProcedureLoader($this->directory);
+
+        $client = $this->getClient();
+        $client->setProcedure('test');
+        $client->getProcedureLoader()->addLoader($procedureLoader);
+
+        $request  = $client->getMessageFactory()->createRequest();
+        $response = $client->getMessageFactory()->createResponse();
+
+        $client->send($request, $response);
+
+        $this->assertSame($content, $response->getContent());
+    }
+
     /**
      * Test syntax exception is thrown if request
      * procedure contains syntax error.