public function createContentSoftDelete($n) { for ($i = 0; $i < $n; $i++) { ContentSoftDelete::create(['enable' => '1', 'visible' => 2])->save(); } return Content::all()->count() === $n; }
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!! }
public function testCachedFeatureFirst() { $this->createContent(10); $this->createContentLang(10); $this->assertCount(10, Content::all()); $this->assertCount(100, Model\ContentLang::all()); $collection = new \Illuminate\Support\Collection(); \DB::flushQueryLog(); Content::all()->each(function ($item) use($collection) { $wrapper = $this->wrapper->createNew($item, 1); $collection->push($wrapper); }); Content::all()->each(function ($item) use($collection) { $wrapper = $this->wrapper->createNew($item, 2); $collection->push($wrapper); }); $this->assertCount(20, $collection); for ($i = 0; $i < 10; $i++) { foreach ($collection as $one) { $one->title; $one->content; $one->enable; $one->visible; } } $this->assertCount(5, \DB::getQueryLog()); }