Exemplo n.º 1
0
 public function test_image_thumb_url()
 {
     Filesystem::shouldReceive('extractName')->once()->with('foo/bar.jpg')->andReturn('bar.jpg');
     Filesystem::shouldReceive('extension')->once()->with('foo/bar.jpg')->andReturn('jpg');
     URL::shouldReceive('asset')->once()->with('foo/bar.jpg')->andReturn('http://www.example.com/foo/bar.jpg');
     $item = new Item('foo/bar.jpg');
     $this->assertEquals('http://www.example.com/foo/bar.jpg', $item->thumb);
 }
Exemplo n.º 2
0
 /** @test */
 public function it_generates_not_rewrite_url_if_config_value_is_false()
 {
     Config::shouldReceive('get')->once()->with("imgproxy::rewrite")->andReturn(false);
     URL::shouldReceive('to')->once()->with("packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg")->andReturn("http://www.example.com/packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg");
     $imgProxy = new Imgproxy();
     $url = $imgProxy->link("image/path/url.jpg", 100, 70);
     $this->assertEquals("http://www.example.com/packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg", $url);
 }
 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);
 }
Exemplo n.º 4
0
 public function test_is_active()
 {
     Route::shouldReceive('currentRouteName')->once()->andReturn('about');
     $this->assertEquals('active', isActive(['faq', 'about']));
     Route::shouldReceive('currentRouteName')->once()->andReturn('home');
     $this->assertEquals('active', isActive('home'));
     URL::shouldReceive('current')->once()->andReturn('http://localhost:8000/about');
     $this->assertEquals('custom-clas-name', isActive('about', 'custom-clas-name'));
     Route::shouldReceive('currentRouteName')->once()->andReturn('news');
     $this->assertEquals('', isActive('home'));
 }
 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');
 }
Exemplo n.º 7
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');
 }
Exemplo n.º 8
0
 function its_created_main_has_a_proper_authentication_form()
 {
     URL::shouldReceive('route');
     $form = new Form();
     $main = $this->create('Title', true, 'Username', 'target', $form)->getWrappedObject();
     /* @var $main Main */
     if ($main->getAuthenticationForm() != $form) {
         throw new \Exception('Created Main has wrong authentication form');
     }
 }