public function testUpdateWithAndMultilangEmptyElements() { $mockedConfig = $this->getMockedConfig(); $mockedConfig->shouldReceive('get')->with('multilang::prefix')->andReturn('@'); $mockedConfig->shouldReceive('get')->with('multilang::reservedAttribute')->andReturn('__lang_id__'); $wrapper = $this->getWrapper(); $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, $wrapper, $this->app['cache.store']); $this->createContentWithLanguages(); $this->assertCount(5, Content::all()); $this->assertCount(50, ContentLang::all()); $updated = Content::find(4); $post = ['title@1' => 'Foo Update', 'visible' => '', 'enable' => '']; $this->assertTrue($multiLang->update($post, $updated)); $updatedLang = ContentLang::query()->where('content_id', 4)->where('__lang_id__', 1)->get()->first(); $this->assertEquals($post['title@1'], $updatedLang->title); $post2 = ['title@1' => 'Foo Update İki', 'content@1' => 'Content Bla bla', 'visible' => '', 'enable' => '']; $this->assertTrue($multiLang->update($post2, $updated)); $updatedLang1 = ContentLang::query()->where('content_id', 4)->where('__lang_id__', 1)->get()->first(); $this->assertEquals($post2['title@1'], $updatedLang1->title); $this->assertEquals($post2['content@1'], $updatedLang1->content); }
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()); }