/**
  * Do the Artisan commands fire?
  */
 public function testCommands()
 {
     $self = $this;
     $this->prepareSpecify();
     $this->specify('Boots', function () use($self) {
         $target = $self->getProvider(['package']);
         $target->shouldReceive('package');
         $target->boot();
     });
     $this->prepareSpecify();
     $this->specify('Identifies provisions', function () use($self) {
         $target = $self->getProvider();
         verify($target->provides())->notEmpty();
     });
     $this->prepareSpecify();
     $this->specify('Binds to application', function () use($self) {
         App::shouldReceive('bind')->with('/^toolbox\\.commands\\./', Mockery::on(function ($closure) {
             $command = $closure();
             verify_that('is a command', is_a($command, 'Illuminate\\Console\\Command'));
             return true;
         }));
         Event::shouldReceive('listen')->with('toolbox.build', Mockery::on(function ($closure) {
             $app = Mockery::mock('Illuminate\\Console\\Application[call]');
             $app->shouldReceive('call');
             $command = $closure($app);
             return true;
         }));
         $target = $self->getProvider(['commands']);
         $target->shouldReceive('commands')->with(Mockery::type('array'));
         $target->register();
     });
 }
 public function testPerformValidation()
 {
     $this->model->shouldReceive('isValid')->once()->andReturn(true);
     Event::shouldReceive('fire')->once();
     $response = $this->observer->creating($this->model);
     $this->assertNotFalse($response);
 }
 public function setUp()
 {
     $this->model = Mockery::mock('Illuminate\\Database\\Eloquent\\Model');
     $this->observer = new ValidatingObserver();
     // Enable validation on mock
     $this->model->shouldReceive('getValidating')->andReturn(true);
     Event::shouldReceive('until')->once();
     Event::shouldReceive('fire')->once();
 }
 public function testMakeAssembly()
 {
     $item = $this->newInventory();
     DB::shouldReceive('beginTransaction')->once()->andReturn(true);
     DB::shouldReceive('commit')->once()->andReturn(true);
     Event::shouldReceive('fire')->once()->andReturn(true);
     $item->makeAssembly();
     $this->assertTrue($item->is_assembly);
 }
 public function testStockMove()
 {
     $stock = $this->newInventoryStock();
     $newLocation = Location::create(['name' => 'New Location']);
     DB::shouldReceive('beginTransaction')->once()->shouldReceive('commit')->once();
     Event::shouldReceive('fire')->once();
     $stock->moveTo($newLocation);
     $this->assertEquals(2, $stock->location_id);
 }
 public function testPublishQueue()
 {
     $store = Mockery::mock(EventStore::class)->makePartial();
     $payload = [Mockery::mock('stdClass')];
     $event_name = 'testEvent';
     $event = ['event' => $event_name, 'payload' => $payload];
     EventBus::shouldReceive('fire')->with('publish:' . $event_name, $payload)->once();
     $this->setPropertyValue($store, 'queue', [$event]);
     expect_not($store->publishQueue());
     $queue = $this->getPropertyValue($store, 'queue');
     expect($queue)->equals([]);
 }
 public function testChildrenAreReparented()
 {
     $page = $this->validPage();
     $newParent = $this->validPage(2);
     $child = m::mock(PageModel::class);
     $child->shouldReceive('setParent')->with($newParent);
     $job = new Jobs\DeletePage($page, ['reparentChildrenTo' => $newParent->getId()]);
     Page::shouldReceive('delete')->zeroOrMoreTimes();
     Event::shouldReceive('fire')->zeroOrMoreTimes();
     Page::shouldReceive('find')->with($newParent->getId())->andReturn($newParent);
     Page::shouldReceive('findByParentId')->with($page->getId())->andReturn([$child]);
     Page::shouldReceive('save')->with($child);
     $job->handle();
 }
 public function test_auth_passes($credentials = null)
 {
     $credentials = $credentials ?: ['email' => '*****@*****.**', 'password' => '12345'];
     $user = $this->getMockUser(['cn' => '', 'mail' => '*****@*****.**', 'samaccountname' => 'jdoe', 'objectsid' => 'S-1-5-32-544']);
     $connection = $this->getMockConnection();
     $connection->expects($this->exactly(1))->method('isBound')->willReturn(true);
     $connection->expects($this->exactly(1))->method('search')->willReturn('resource');
     $connection->expects($this->exactly(1))->method('getEntries')->willReturn(['count' => 1, $user->getAttributes()]);
     $connection->expects($this->exactly(2))->method('bind')->with($this->logicalOr($this->equalTo('jdoe'), $this->equalTo('admin')))->willReturn(true);
     Event::shouldReceive('fire')->atLeast()->times(4)->withAnyArgs();
     $this->assertTrue(Auth::attempt($credentials));
     $user = Auth::user();
     $this->assertInstanceOf(User::class, $user);
     $this->assertEquals($credentials['email'], $user->mail[0]);
 }
 public function testGetTotalVariantStock()
 {
     $this->newCategory();
     $this->newMetric();
     $coke = Inventory::create(['name' => 'Coke', 'description' => 'Delicious Pop', 'metric_id' => 1, 'category_id' => 1]);
     $cherryCoke = $coke->createVariant('Cherry Coke');
     $cherryCoke->makeVariantOf($coke);
     $vanillaCherryCoke = $cherryCoke->createVariant('Vanilla Cherry Coke');
     $vanillaCherryCoke->makeVariantOf($cherryCoke);
     DB::shouldReceive('beginTransaction')->once()->andReturn(true);
     DB::shouldReceive('commit')->once()->andReturn(true);
     Event::shouldReceive('fire')->once()->andReturn(true);
     $location = $this->newLocation();
     // Allow duplicate movements configuration option
     Config::shouldReceive('get')->twice()->andReturn(true);
     // Stock change reasons (one for create, one for put, for both items)
     Lang::shouldReceive('get')->times(4)->andReturn('Default Reason');
     $cherryCoke->createStockOnLocation(20, $location);
     $vanillaCherryCoke->createStockOnLocation(20, $location);
     $this->assertEquals(40, $coke->getTotalVariantStock());
 }
 /**
  * Run Event
  *
  * Common method to set Event facade to listen for an event before triggering
  * an Artisan command.
  * @param  string $event       Name of Event to listen for
  * @param  string $commandName Class name of the command to instantiate
  */
 public function runEvent($event, $commandName)
 {
     $command = $this->getCommand($commandName);
     Event::shouldReceive('fire')->once()->with($event)->andReturn([1]);
     $this->runCommand($command);
 }