public function testAssetPublishing() { Stylist::registerPaths(Stylist::discover(__DIR__ . '/../Stubs/Themes')); $artisan = $this->app->make('Illuminate\\Contracts\\Console\\Kernel'); File::shouldReceive('exists')->andReturn(true)->times(8); File::shouldReceive('get')->times(6); File::shouldReceive('copyDirectory')->times(3); // Action $artisan->call('stylist:publish'); // Assert // $this->assertTrue($this->app['files']->exists(public_path('themes/child-theme'))); // $this->assertFalse($this->app['files']->exists(public_path('themes/parent-theme'))); }
/** * Do the Artisan commands fire? */ public function testCommands() { $self = $this; $this->prepareSpecify(); $this->specify('Build executes', function () use($self) { $command = $self->getCommand('BuildCommand'); Event::shouldReceive('fire')->once()->with('toolbox.build', [$command]); $self->runCommand($command); }); $this->prepareSpecify(); $this->specify('Controllers executes', function () use($self) { $self->runEvent('toolbox.controllers', 'ControllersCommand'); }); $this->prepareSpecify(); $this->specify('Models executes', function () use($self) { $self->runEvent('toolbox.models', 'ModelsCommand'); }); $this->prepareSpecify(); $this->specify('Routes executes with existing files', function () use($self) { File::shouldReceive('exists')->with(Mockery::anyOf('app/routes.php', 'app/routes.bak.php'))->andReturn(true); File::shouldReceive('delete')->with('app/routes.bak.php'); File::shouldReceive('move')->with('app/routes.php', 'app/routes.bak.php'); File::shouldReceive('put')->with('app/routes.php', Mockery::type('string')); $command = $self->getCommand('RoutesCommand'); Event::shouldReceive('fire')->once()->with('toolbox.routes')->andReturn([]); $self->runCommand($command); }); $this->prepareSpecify(); $this->specify('Routes executes without existing files', function () use($self) { File::shouldReceive('exists')->with(Mockery::anyOf('app/routes.php', 'app/routes.bak.php'))->andReturn(false); File::shouldReceive('put')->with('app/routes.php', Mockery::type('string')); $self->runEvent('toolbox.routes', 'RoutesCommand'); }); $this->prepareSpecify(); $this->specify('BuildCommand executes', function () use($self) { $self->runEvent('toolbox.schema', 'SchemaCommand'); }); $this->prepareSpecify(); $this->specify('BuildCommand executes', function () use($self) { $self->runEvent('toolbox.views', 'ViewsCommand'); }); }
/** * Specs for Generator::execute() */ public function testExecuteMethod() { $class = $this->prepareSpecify(); $this->specify('renders if one class name is passed.', function () use($class) { View::shouldReceive('make->render')->once()->andReturn('test output'); File::shouldReceive('exists')->twice()->with('/\\.php$/')->andReturn(false); File::shouldReceive('put')->once()->with('/\\.php$/', 'test output')->andReturn(true); $params = ['classes' => ['test' => []]]; expect($class->execute($params))->greaterThan(0); }); $this->specify('does not count failed views.', function () use($class) { View::shouldReceive('make->render')->once()->andReturn('test output'); File::shouldReceive('exists')->twice()->with('/\\.php$/')->andReturn(false); File::shouldReceive('put')->once()->with('/\\.php$/', 'test output')->andReturn(false); $params = ['classes' => ['test' => []]]; expect($class->execute($params))->equals(0); }); $this->specify('keeps overridden view.', function () use($class) { View::shouldReceive('make')->once()->with('test::view', Mockery::type('array')); View::shouldReceive('make->render')->once()->andReturn('test output'); File::shouldReceive('exists')->twice()->with('/\\.php$/')->andReturn(false); File::shouldReceive('put')->once()->with('/\\.php$/', 'test output')->andReturn(true); $params = ['classes' => ['test' => []]]; expect($class->execute($params))->greaterThan(0); }); }
public function testWriteFile_Directory() { $content = 'Hello'; $directory = 'testing'; $fileName = 'Test'; File::shouldReceive('put')->once()->andReturn(true); $this->commandStub->setPath('/'); $this->commandStub->writeFile($content, $directory, $fileName); }
/** * @test */ public function it_should_fire_with_config_not_confirmed() { /** * Set * * @var \Mockery\Mock $command */ $command = m::mock('Menthol\\Flexible\\Commands\\PathsCommand')->makePartial(); $command->shouldAllowMockingProtectedMethods(); File::clearResolvedInstance('files'); File::shouldReceive('exists')->once()->andReturn(false); App::shouldReceive('make')->andReturn(true); /** * Expectation */ $command->shouldReceive('getLaravel')->once()->andReturn(true); $command->shouldReceive('argument')->with('model')->once()->andReturn(['Husband']); $command->shouldReceive('option')->with('dir')->once()->andReturn([__DIR__ . '/../../../Support/Stubs']); $command->shouldReceive('option')->with('write-config')->once()->andReturn(true); $command->shouldReceive('confirm')->once()->andReturn(false); $command->shouldReceive('compilePaths', 'error', 'call', 'info')->andReturn(true); /* |------------------------------------------------------------ | Assertion |------------------------------------------------------------ */ $command->fire(); }
public function test_validate_folder_path() { File::shouldReceive('exists')->once()->with('vfs://root/folder')->andReturn(true); File::shouldReceive('isDirectory')->once()->with('vfs://root/folder')->andReturn(true); $check = $this->fs->validatePath('folder'); $this->assertTrue($check); }