예제 #1
0
 public function testTranslateReturnsTranslation()
 {
     $button = $this->getButton();
     $translation = 'Test button text';
     Lang::shouldReceive('has')->with('boomcms::buttons.test')->andReturn(true);
     Lang::shouldReceive('get')->with('boomcms::buttons.test')->andReturn($translation);
     $this->assertEquals($translation, $button->translate('test'));
 }
예제 #2
0
 public function testGetPlaceholderTextReturnsDefaultForType()
 {
     Lang::shouldReceive('has')->once()->with('boomcms::chunks.text.test')->andReturn(false);
     Lang::shouldReceive('get')->once()->with('boomcms::chunks.text.default')->andReturn('some text');
     $chunk = $this->getMockBuilder(BaseChunk::class)->setMethods(['show', 'showDefault', 'hasContent', 'getType'])->setConstructorArgs([new Page(), [], 'test', true])->getMock();
     $chunk->expects($this->any())->method('getType')->will($this->returnValue('text'));
     $this->assertEquals('some text', $chunk->getPlaceholderText());
 }
예제 #3
0
 public function test_get_key_with_section()
 {
     $registrationKey = 'mypackage';
     IlluminateLang::shouldReceive('get')->once()->with("{$registrationKey}::section.key")->andReturn('another key value');
     $service = new Lang($registrationKey);
     $config = $service->get('key', 'section');
     $this->assertEquals('another key value', $config);
 }
예제 #4
0
 public function test_l_helper()
 {
     Lang::shouldReceive('has')->once()->with('laravel.welcome')->andReturn(true);
     Lang::shouldReceive('get')->once()->with('laravel.welcome', [])->andReturn("Welcome to Laravel");
     $this->assertEquals('Welcome to Laravel', t('laravel.welcome', 'Welcome to Rails'));
     Lang::shouldReceive('has')->once()->with('laravel.welcome')->andReturn(false);
     $this->assertEquals('Welcome to Rails', t('laravel.welcome', 'Welcome to Rails'));
 }
예제 #5
0
 public function testAddInvalidQuantityWithAssemblyItem()
 {
     $item = $this->newInventory();
     $childItem = $this->newInventory(['name' => 'Child Item', 'metric_id' => $item->metric_id, 'category_id' => $item->category_id]);
     Lang::shouldReceive('get')->once()->andReturn('Invalid Quantity');
     $this->setExpectedException('Stevebauman\\Inventory\\Exceptions\\InvalidQuantityException');
     $item->addAssemblyItem($childItem, 'invalid quantity');
 }
 public function testInventoryTransactionReleaseDefaultReason()
 {
     $transaction = $this->newTransaction();
     Lang::shouldReceive('get')->twice()->andReturn('test');
     $transaction->hold(5)->release(3);
     $stock = $transaction->getStockRecord();
     $this->assertEquals('test', $stock->reason);
 }
 public function testInventoryTransactionCancelledDefaultReason()
 {
     $transaction = $this->newTransaction();
     $transaction->checkout(5);
     $stock = $transaction->getStockRecord();
     Lang::shouldReceive('get')->once()->andReturn('test');
     $transaction->cancel();
     $this->assertEquals('test', $stock->reason);
 }
 function let(AujaConfigurator $aujaConfigurator, AujaRouter $aujaRouter, Model $model)
 {
     $this->beConstructedWith($aujaConfigurator, $aujaRouter);
     URL::shouldReceive('route');
     Lang::shouldReceive('trans')->with('Add')->andReturn('Add');
     Lang::shouldReceive('trans')->with('Model')->andReturn('Model');
     $aujaConfigurator->getModel('Model')->willReturn($model);
     $aujaConfigurator->isSearchable($model, null)->willReturn(false);
 }
 function let(AujaRouter $aujaRouter)
 {
     $this->aujaRouter = $aujaRouter;
     $this->beConstructedWith($aujaRouter);
     Url::shouldReceive('route');
     Lang::shouldReceive('trans')->with('Add')->andReturn('Add');
     Lang::shouldReceive('trans')->with('Username')->andReturn('Username');
     Lang::shouldReceive('trans')->with('Association')->andReturn('Association');
     Lang::shouldReceive('trans')->with('Associations')->andReturn('Associations');
     Lang::shouldReceive('trans')->with('Password')->andReturn('Password');
 }
 function let(AujaRouter $aujaRouter, Relation $relation, Model $left, Model $right)
 {
     $this->beConstructedWith($aujaRouter);
     $this->relation = $relation;
     $relation->getLeft()->willReturn($left);
     $relation->getRight()->willReturn($right);
     $relation->getType()->willReturn('hasMany');
     $left->getName()->willReturn('Model');
     $right->getName()->willReturn('OtherModel');
     URL::shouldReceive('route');
     Lang::shouldReceive('trans')->with('Edit')->andReturn('Edit');
     Lang::shouldReceive('trans')->with('Properties')->andReturn('Properties');
     Lang::shouldReceive('trans')->with('OtherModel')->andReturn('OtherModel');
 }
 function let(AujaConfigurator $aujaConfigurator, AujaRouter $aujaRouter, Relation $relation, Model $left, Model $right)
 {
     $this->beConstructedWith($aujaConfigurator, $aujaRouter);
     $this->relations = [$relation];
     $relation->getLeft()->willReturn($left);
     $relation->getRight()->willReturn($right);
     $relation->getType()->willReturn('hasMany');
     $left->getName()->willReturn('Model');
     $right->getName()->willReturn('OtherModel');
     $aujaConfigurator->getModel('Model')->willReturn($left);
     $aujaConfigurator->getRelationsForModel($left)->willReturn([$relation]);
     $aujaConfigurator->getDisplayField($left)->willReturn('name');
     $aujaConfigurator->getIcon($left)->willReturn(null);
     URL::shouldReceive('route');
     Lang::shouldReceive('trans')->with('Add')->andReturn('Add');
     Lang::shouldReceive('trans')->with('Model')->andReturn('Model');
 }
예제 #12
0
 function let(AujaConfigurator $aujaConfigurator, AujaRouter $aujaRouter, FormItemFactory $formItemFactory, TextFormItem $formItem, Model $model, Column $column1, Column $column2)
 {
     $this->beConstructedWith($aujaConfigurator, $aujaRouter, $formItemFactory);
     $aujaConfigurator->getModel('MyModel')->willReturn($model);
     $aujaConfigurator->getVisibleFields($model, null)->willReturn($this->visibleFields);
     $formItemFactory->getFormItem($model, $column1, null)->willReturn($formItem);
     $formItemFactory->getFormItem($model, $column2, null)->willReturn($formItem);
     $model->getColumn('field1')->willReturn($column1);
     $column1->getName()->willReturn('field1');
     $column1->getType()->willReturn(Type::STRING);
     $model->getColumn('field2')->willReturn($column2);
     $column2->getName()->willReturn('field2');
     $column2->getType()->willReturn(Type::STRING);
     Lang::shouldReceive('trans')->with('field1')->andReturn('field1');
     Lang::shouldReceive('trans')->with('field2')->andReturn('field2');
     Lang::shouldReceive('trans')->with('Submit')->andReturn('Submit');
     Lang::shouldReceive('trans')->with('Delete')->andReturn('Delete');
     Lang::shouldReceive('trans')->with('Are you sure?')->andReturn('Are you sure?');
     URL::shouldReceive('route');
 }
예제 #13
0
 /**
  * @test
  */
 public function delete_ModelException()
 {
     $this->setExpectedException(BaseModelException::class, 'Model could not be found.');
     $mockService = m::mock(CrudServiceBase::class)->makePartial();
     Lang::shouldReceive('get')->once()->andReturn('Model could not be found.');
     $mockService->shouldReceive('read')->once()->andReturnNull();
     $mockService->shouldReceive('throwException')->once()->andThrow(new BaseModelException(Lang::get('support.exceptions.model.read')));
     $mockService->delete(1);
 }
예제 #14
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());
 }
예제 #15
0
 public function testInventoryGetStockFromLocationInvalidLocation()
 {
     $this->newInventoryStock();
     $item = Inventory::find(1);
     Lang::shouldReceive('get')->once();
     try {
         $item->getStockFromLocation('testing');
         $passes = false;
     } catch (\Exception $e) {
         $passes = true;
     }
     $this->assertTrue($passes);
 }
예제 #16
0
 /**
  * @covers LanguageHelper::get()
  */
 public function testHas_returnsFalseIfValueDoesNotExist()
 {
     Lang::shouldReceive('has')->once()->with('Foo')->andReturn(false);
     Lang::shouldReceive('has')->once()->with('translation::Foo')->andReturn(false);
     $this->assertFalse($this->languageHelper->has('Foo'));
 }
예제 #17
0
 /**
  * @test
  */
 public function getValidationOptionsInvalid()
 {
     $this->setExpectedException(ValidateException::class, 'Error');
     $mockClass = m::mock(ValidateStub::class)->makePartial();
     Lang::shouldReceive('get')->once()->andReturn('Error');
     $mockClass->getValidationOptions('omgwtfbbq');
 }
예제 #18
0
 public function testInventoryInvalidQuantityException()
 {
     $item = $this->newInventory();
     $location = $this->newLocation();
     Lang::shouldReceive('get')->once();
     $this->setExpectedException('Stevebauman\\Inventory\\Exceptions\\InvalidQuantityException');
     $item->createStockOnLocation('invalid quantity', $location);
 }
 function let()
 {
     Lang::shouldReceive('trans')->with('Login')->andReturn('Login');
     Lang::shouldReceive('trans')->with('Email address')->andReturn('Email address');
 }