prependScript() public method

Prepends a script to the script array.
public prependScript ( string $path, string $type = 'text/javascript' )
$path string Path to the script. It can be relative path to the Public/static folder or a full http path.
$type string Script type, default is 'text/javascript'.
Example #1
0
 public function testScripts()
 {
     $view = new View();
     $scriptOne = 'scriptOne.js';
     $scriptTwo = 'scriptTwo.js';
     $scriptThree = 'scriptThree.js';
     $view->appendScript($scriptOne);
     $view->prependScript($scriptTwo);
     $view->appendScript($scriptThree);
     $scriptArray = $view->getScripts();
     $expectedArray = [['path' => $scriptTwo, 'type' => 'text/javascript'], ['path' => $scriptOne, 'type' => 'text/javascript'], ['path' => $scriptThree, 'type' => 'text/javascript']];
     $this->assertSame($expectedArray, $scriptArray);
     $html = '';
     foreach ($expectedArray as $s) {
         $html .= '<script type="' . $s['type'] . '" src="' . $s['path'] . '"></script>' . "\n";
     }
     $this->assertSame($html, $view->getScriptsHtml());
 }