Ejemplo n.º 1
0
 public function testStatements()
 {
     $this->bladedManager->expects($this->any())->method('getCommand')->will($this->returnValue($this));
     $this->appMock->expects($this->any())->method('make')->will($this->returnCallback(function ($resolvable) {
         switch ($resolvable) {
             case 'view':
                 return $this->viewMock;
             case 'laravel-commode.bladed':
                 return $this->bladedManager;
             case BladedServiceProvider::PROVIDES_STRING_COMPILER:
                 return $this->stringCompiler;
             default:
                 var_dump($resolvable, 'in testStatements');
                 die;
         }
     }));
     foreach (['condition', 'statement', 'templates'] as $file) {
         $this->assertSame(bl_get_contents('templates/results' . ucfirst($file)), $this->bladeCompiler->compileString(bl_get_contents("templates/{$file}.blade._php")));
     }
     $expect = bl_get_contents('templates/resultsIterators');
     $compiled = $this->bladeCompiler->compileString(bl_get_contents("templates/iterators.blade._php"));
     preg_match_all('/(\\$count[\\d\\w]{1,})/is', $compiled, $countVars);
     $countVars = array_values($countVars[0]);
     preg_match_all('/(\\$key[\\d\\w]{1,})/is', $compiled, $keyVars);
     $keyVars = array_values($keyVars[0]);
     $countIteration = 0;
     $keyIteration = 0;
     $expect = preg_replace_callback('/\\{\\{countVar\\}\\}/is', function ($match) use($countVars, &$countIteration) {
         return $countVars[$countIteration++];
     }, $expect);
     $expect = preg_replace_callback('/\\{\\{\\$key\\}\\}/is', function ($match) use($keyVars, &$keyIteration) {
         return $keyVars[$keyIteration++];
     }, $expect);
     $this->assertSame($expect, $compiled);
 }
 public function testLaunching()
 {
     $this->bladedManagerMock->expects($this->exactly(3))->method('registerCommandNamespace');
     $this->appMock->expects($this->any())->method('make')->will($this->returnCallback(function ($resolvable) {
         switch ($resolvable) {
             case BladedServiceProvider::PROVIDES_SERVICE:
                 return $this->bladedManagerMock;
         }
     }));
     $this->testInstance->launching();
 }