public function testSimpleFirst()
 {
     //$this->app['db']->connection()->getSchemaBuilder()->getColumnListing('contents');
     $model = $this->content->create(['enable' => 1]);
     $this->assertFalse($this->checkerAttribute->check($model, 'name'));
     $this->assertTrue($this->checkerAttribute->check($model, 'id'));
     $this->assertfalse($this->checkerAttribute->check($model, 'notexist'));
     $this->assertTrue($this->checkerAttribute->check($model, 'visible'));
     $this->assertTrue($this->checkerAttribute->check($model, 'created_at'));
 }
 public function createContentSoftDelete($n)
 {
     for ($i = 0; $i < $n; $i++) {
         ContentSoftDelete::create(['enable' => '1', 'visible' => 2])->save();
     }
     return Content::all()->count() === $n;
 }
Exemple #3
0
 public function testWarapperWithRelations()
 {
     $this->assertCount(5, $this->createImages());
     $content = $this->content->all()->last();
     $this->assertInstanceOf('Muratsplat\\Multilang\\Tests\\Model\\Content', $content);
     $wrapper = $this->wrapper->createNew($content);
     $this->assertEquals(1, $wrapper->enable);
     $this->assertEquals(1, $wrapper->visible);
     $this->assertEquals($content->Images, $wrapper->Images);
     $this->assertCount(5, $content->Images);
     $this->assertCount(5, $wrapper->Images);
 }
 public function testMultilangAndWrapperIssueOfMakedBeEmptySelf()
 {
     $mockedConfig = $this->getMockedConfig();
     $mockedConfig->shouldReceive('get')->with('multilang::prefix')->andReturn('@');
     $mockedConfig->shouldReceive('get')->with('multilang::reservedAttribute')->andReturn('__lang_id__');
     $messageBag = $this->getMockedMessageBag();
     $validator = $this->getMockedValid();
     $mockedConfig->shouldReceive('get')->andReturn('Lang');
     $validator->shouldReceive('make')->andReturn(true);
     $multiLang = new MultiLang(new Picker(new Collection(), new Element(), $mockedConfig), $mockedConfig, $messageBag, $validator, new Wrapper($mockedConfig, $this->getCheckerAttribute(), $this->app['cache.store']), $this->app['cache.store']);
     $this->createContentWithLanguages();
     $collection = Content::all();
     $count = $collection->count();
     $wrapperCollection = $multiLang->makeWrapper($collection, 2, 1);
     $this->assertInstanceOf('Illuminate\\Support\\Collection', $wrapperCollection);
     foreach ($wrapperCollection as $v) {
         $v->enable;
         $v->visible;
         $v->title;
         $v->content;
     }
     // fixed !!!
     $this->assertCount($count, $collection);
     // Collection is empty by self!!
 }
Exemple #5
0
 public function testJsonableInterfaceImplementWithDifferentLang()
 {
     $this->assertTrue($this->createContent(3));
     /* first */
     $content = Content::find(1);
     $postFirst = ['__lang_id__' => 1, 'title' => 'First Title', 'content' => 'First Content'];
     $lang1 = $content->ContentLangs()->create($postFirst);
     $wrapper = $this->wrapper->createNew($content, 2);
     $attributes = array_merge($content->getAttributes(), $lang1->getAttributes());
     $this->assertEquals($attributes, $wrapper->toArray());
     $wrapper->toJson();
     // not need to check!!
     // fixed!!
 }