Example #1
0
 public function testHelperSingleWithFailedCompile()
 {
     \App::instance('gcc', Mockery::mock('GCCompiler')->shouldReceive('reset')->once()->shouldReceive('setFiles')->with('file1.js')->once()->shouldReceive('compile')->once()->andReturn(false)->shouldReceive('getJsDir')->once()->andReturn('js')->shouldReceive('getFiles')->once()->andReturn(array('file1.js' => ''))->mock());
     \Config::set('laravel-gcc::env', array('testing'));
     \File::shouldReceive('lastModified')->once()->andReturn(12345);
     $scriptTag = javascript_compiled('file1.js');
     $this->assertEquals("<script src=\"http://localhost/js/file1.js?12345\"></script>\n", $scriptTag);
 }
 public function testMulitipleRequireDevSection()
 {
     $helper = M::mock('Syncle\\Helpers');
     $helper->shouldReceive('base_path')->andReturn(realpath(__DIR__ . '/../../../'));
     File::shouldReceive('get')->andReturn(json_encode(array('require-dev' => array('vendor10/package100' => 'dev-master', 'vendor20/package200' => 'dev-develop', 'vendor30/package300' => '4.3.2'))));
     $repo = new ComposerJsonRepository($helper);
     $this->assertEquals(array('vendor10/package100' => 'dev-master', 'vendor20/package200' => 'dev-develop', 'vendor30/package300' => '4.3.2'), $repo->get());
 }
Example #3
0
 public function testInstallCommandThrowsExceptionWhenConfigFilesNotWritable()
 {
     $this->setExpectedException('Netson\\L4gettext\\ConfigFilesNotWritableException');
     File::shouldReceive('isDirectory')->once()->andReturn(true);
     File::shouldReceive('isFile')->times(6)->andReturn(true);
     File::shouldReceive('isWritable')->once()->andReturn(false);
     $commandTester = new CommandTester(new InstallCommand());
     $commandTester->execute(array());
 }
Example #4
0
 public function testCompileCommandSuccessWhenOutputDirDoesNotExist()
 {
     BladeCompiler::shouldReceive('setCachePath')->once()->shouldReceive('compile')->once();
     // same amount of times as files provided by glob()
     File::shouldReceive("isDirectory")->once()->andReturn(false)->shouldReceive('makeDirectory')->once()->andReturn(true)->shouldReceive('glob')->once()->andReturn(array("test.php"));
     $commandTester = new CommandTester(new CompileCommand());
     $commandTester->execute(array());
     $expected = "blade templates found and successfully compiled\n";
     $this->assertStringEndsWith($expected, $commandTester->getDisplay());
 }
Example #5
0
 public function testKeepOnlyS3()
 {
     $s3Mock = m::mock();
     $s3Mock->shouldReceive('putObject')->andReturn(true);
     AWS::shouldReceive('get')->once()->with('s3')->andReturn($s3Mock);
     File::shouldReceive('delete')->once()->andReturn(true);
     $this->databaseMock->shouldReceive('getFileExtension')->once()->andReturn('sql');
     $this->databaseMock->shouldReceive('dump')->once()->andReturn(true);
     $this->tester->execute(array('--upload-s3' => 'bucket-title', '--keep-only-s3' => true));
 }
Example #6
0
 public function testCompileGetsFileContents()
 {
     $testPath = "/test";
     BladeCompiler::setCachePath($testPath);
     $contents = 'file contents';
     $mock = File::shouldReceive('get')->once()->andReturn($contents)->shouldReceive('put')->once()->getMock();
     $expected = BladeCompiler::getCompiledPath($testPath);
     BladeCompiler::setFiles($mock);
     $this->assertEquals($expected, BladeCompiler::compile($testPath));
 }
Example #7
0
 public function testRouteCache()
 {
     GCCompiler::cleanup();
     $this->_mockRemoteCompiler();
     $gcc = new GCCompiler($this->app['config']);
     $gcc->compile('file1.js');
     $time = time();
     \File::shouldReceive('exists')->once()->andReturn(true)->shouldReceive('lastModified')->twice()->andReturn($time);
     $this->call('GET', $gcc->getCompiledJsURL(), array(), array(), array('HTTP_If-Modified-Since' => gmdate('D, d M Y H:i:s \\G\\M\\T', $time)));
     $this->assertResponseStatus(304);
 }
Example #8
0
 public function testBuildCommand()
 {
     // mock gccompiler
     \App::instance('gcc', Mockery::mock('GCCompiler')->shouldReceive('reset')->times(4)->shouldReceive('compile')->andReturn(true)->shouldReceive('getCompiledJsURL')->times(4)->andReturn('http://url/compiled1.js', 'http://url/compiled2.js', 'http://url/compiled1.js', 'http://url/compiled2.js')->mock());
     // mock all filesystem calls
     \File::shouldReceive('allFiles')->once()->andReturn(array('file.blade.php'))->shouldReceive('get')->once()->andReturn("<html>\n    <head>\n        {{ javascript_compiled('file1.js') }}\n        <?php echo javascript_compiled(array(\n            'file1.js',\n            'file2.js'\n        )); ?>\n    </head>\n    <body>\n        <h1>Header</h1>                        \n        <?php echo javascript_compiled(\"file1.js\"); ?>\n        {{ javascript_compiled([\n            'file2.js',\n            'file1.js'\n        ]) }}\n    </body>\n</html>");
     // start the actual test
     $tester = new Symfony\Component\Console\Tester\CommandTester(new Jboysen\LaravelGcc\Commands\Build());
     $tester->execute(array());
     $output = $tester->getDisplay();
     $this->assertEquals("Searching files...\n.Done!\nCompiling bundle:\n  file1.js\n-> http://url/compiled1.js\nCompiling bundle:\n  file1.js\n  file2.js\n-> http://url/compiled2.js\nCompiling bundle:\n  file1.js\n-> http://url/compiled1.js\nCompiling bundle:\n  file2.js\n  file1.js\n-> http://url/compiled2.js\nAll bundles are now compiled.\n", $output);
 }
Example #9
0
 public function testExtractCommandSuccessfullWithAdditionalInputFolders()
 {
     File::shouldReceive('glob')->times(3)->andReturn(array("test.php"));
     File::shouldReceive('isDirectory')->once()->andReturn(true);
     $proc = m::mock("Symfony\\Component\\Process\\Process");
     $procBuilder = m::mock("Symfony\\Component\\Process\\ProcessBuilder");
     $proc->shouldReceive('run')->once();
     $proc->shouldReceive('isSuccessful')->once()->andReturn(true);
     $proc->shouldReceive('stop')->once();
     $procBuilder->shouldReceive('setArguments')->once()->andReturn(m::self());
     $procBuilder->shouldReceive('getProcess')->once()->andReturn($proc);
     $commandTester = new CommandTester(new ExtractCommand($procBuilder));
     $proc->__destruct();
     // invoke the stop() call
     $commandTester->execute(array('-d' => array("valid_folder")));
     $this->assertStringEndsWith("xgettext successfully executed\n", $commandTester->getDisplay());
 }
Example #10
0
 public function testFetchCommandThrowsExceptionWhenProcessFailed()
 {
     $this->setExpectedException('Netson\\L4gettext\\CannotFetchInstalledLocalesException');
     File::shouldReceive('isDirectory')->once()->andReturn(true);
     File::shouldReceive('isFile')->times(2)->andReturn(true);
     File::shouldReceive('isWritable')->twice()->andReturn(true);
     $proc = m::mock("Symfony\\Component\\Process\\Process");
     $procBuilder = m::mock("Symfony\\Component\\Process\\ProcessBuilder");
     $proc->shouldReceive('run')->once();
     $proc->shouldReceive('isSuccessful')->once()->andReturn(false);
     $proc->shouldReceive('stop')->once();
     $procBuilder->shouldReceive('setPrefix')->once()->andReturn(m::self());
     $procBuilder->shouldReceive('setArguments')->once()->andReturn(m::self());
     $procBuilder->shouldReceive('getProcess')->once()->andReturn($proc);
     $commandTester = new CommandTester(new FetchCommand($procBuilder));
     $proc->__destruct();
     // invoke the stop() call
     $commandTester->execute(array());
 }
Example #11
0
 public function testExecutablePathIsAddedToCommand()
 {
     File::shouldReceive('isDirectory')->once()->andReturn(true);
     Log::shouldReceive('info')->twice();
     $command = L4shell::setCommand("ls");
     $command->setExecutablePath("/");
     $expected = "/ls";
     $this->assertEquals($expected, $command->getCommand());
 }
Example #12
0
 public function testSetTextDomainShouldReturnObject()
 {
     File::shouldReceive('isDirectory')->twice()->andReturn(true)->shouldReceive('makeDirectory')->never();
     $this->assertInstanceOf("Netson\\L4gettext\\L4gettext", L4gettext::createFolder('/test'));
 }
 public function testCreatesFile()
 {
     File::shouldReceive('put')->once();
     $this->call('GET', 'foo');
 }