public function testGetCommand() { $makeMock = $this->getMockForAbstractClass(ABladedCommand::class, [$this->appMock]); $testName = uniqid(); $this->appMock->expects($this->any())->method('bound')->with()->will($this->returnCallback(function ($boundCheck) use($testName) { return $boundCheck === BladedServiceProvider::PROVIDES_SERVICE . '.' . $testName; })); $this->bladedCompilerMock->expects($this->exactly(2))->method('getIocRegistry')->will($this->returnValue(BladedServiceProvider::PROVIDES_SERVICE)); $this->appMock->expects($this->any())->method('make')->will($this->returnCallback(function () use($makeMock) { return $makeMock; })); $this->testInstance->getCommand($testName, $this->viewMock); try { $this->testInstance->getCommand($fake = uniqid('fake'), $this->viewMock); } catch (\Exception $e) { $this->assertSame("Unable to resolve \"{$fake}\" command stack.", $e->getMessage()); } }
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()); } }