public function testGetSetApplicationAndEnv() { $this->assertSame($this->appMock, $this->testInstance->getApplication()); $this->appMock->expects($this->once())->method('make')->with('view')->will($this->returnValue($this->viewMock)); $this->assertSame($this->viewMock, $this->testInstance->getEnvironment()); $this->testInstance->setEnvironment($this->viewMock); $this->assertSame($this->viewMock, $this->testInstance->getEnvironment()); }
public function testRegister() { $this->appMock->expects($this->any())->method('singleton')->will($this->returnCallback(function ($bindTo, $bound) { switch ($bindTo) { case UtilsServiceProvider::PROVIDES_META_MANAGER: $this->assertTrue($bound() instanceof MetaManager); break; } })); $this->testInstance->registering(); }
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(); }
public function testExtend() { $commandMock = $this->getMockForAbstractClass(ABladedCommand::class, [$this->appMock]); $testName = uniqid(); $methodName = uniqid('method'); $extendCallback = function () { }; $this->appMock->expects($this->any())->method('bound')->will($this->returnValue(true)); $this->appMock->expects($this->any())->method('make')->will($this->returnValue($commandMock)); $this->testInstance->extendCommand($testName, $methodName, $extendCallback, false); }
public function testRegister() { $this->applicationMock->expects($this->any())->method('make')->will($this->returnCallback(function ($toMake) { switch ($toMake) { case 'request': return $this->requestMock; } })); $this->applicationMock->expects($this->atLeastOnce())->method('resolving')->with($this->callback(function ($callable) { $callable(new ViewModel()); $callable(new RequestBag()); $callable(new FileViewModel()); return $callable instanceof \Closure; })); $this->requestMock->expects($this->atLeastOnce())->method('only')->will($this->returnValue([])); $this->requestMock->expects($this->atLeastOnce())->method('all')->will($this->returnValue([])); $this->testInstance->registering(); }
public function testLookUp() { $this->appMock->expects($this->any())->method('make')->will($this->returnCallback(function ($make) { switch ($make) { case 'translator': return $this->tranlator; default: var_dump($make); die('testLookUp'); } })); $this->tranlator->expects($this->any())->method('trans')->will($this->returnCallback(function ($trans) { switch ($trans) { case 'validation.attributes.login': return 'Login'; case 'validation.attributes.not_existent': return $trans; } })); $this->assertSame('Login', $this->testInstance->login); $this->assertSame('not_existent', $this->testInstance->not_existent); }
public function testRegistration() { $test = ['command' => '\\stdClass', 'command1' => '\\stdClass']; $this->appMock->expects($this->any())->method('singleton')->will($this->returnCallback(function ($command, $callback) use($test) { $commandName = str_replace($this->testInstance->getIoCRegistry() . ".", '', $command); $this->assertArrayHasKey($commandName, $test); $this->assertTrue($callback($this->appMock) instanceof $test[$commandName]); })); $this->testInstance->registerNamespaces($test); $this->appMock->expects($this->any())->method('make')->will($this->returnValue($this)); $this->assertSame($this, $this->testInstance->getNamespace('command')); try { $this->testInstance->getNamespace($command = uniqid('not_existent')); } catch (\Exception $e) { $this->assertTrue($e instanceof \UnexpectedValueException); $this->assertSame("Unknown blade command namespace - {$command}.", $e->getMessage()); } }