protected function setNewPages() { foreach ($this->differ->newPages() as $page) { Page::create(['name' => $page, 'description' => $this->fileSnapshot->getPageDescription($page)]); } return $this; }
/** *@test */ public function the_writer_will_not_overwrite_or_change_content_that_is_not_removed_in_the_yml_file() { //set up existing content $home = Page::create(['name' => 'home', 'description' => 'The homepage']); $home->addTextblock('intro', 'The homepage intro', false, 'welcome to my homepage'); //set up writer and write new content structure $fileSnapshot = (new ContentSnapshotFactory(new Parser()))->makeSnapshotFromYmlFile('tests/assets/basic.yml'); $databaseSnapshot = (new ContentSnapshotFactory(new Parser()))->makeSnapshotFromRepo(new ContentRepository()); $writer = new ContentWriter($fileSnapshot, $databaseSnapshot); $writer->setContentStructure(); //the content value for the homepage intro should still exist $this->assertEquals('welcome to my homepage', Page::where('name', 'home')->first()->textblocks->where('name', 'intro')->first()->content); }
private function seedDatabaseWithBasicContentStructure() { //build up database content $home = Page::create(['name' => 'home', 'description' => 'The homepage']); $about = Page::create(['name' => 'about', 'description' => 'The about page']); Page::create(['name' => 'contact', 'description' => 'The contact page']); $home->addTextblock('intro', 'The homepage intro'); $home->addTextblock('spiel', 'Company story', true); $home->addGallery('slider', 'Homepage banner slide images'); $about->addTextblock('intro', 'The about page intro'); $about->addTextblock('spiel', 'My story', true); $about->addGallery('slider', 'About page banner slide images'); }
public static function makePage($name, $description = null) { return Page::create(['name' => $name, 'description' => $description]); }
/** *@test */ public function the_content_repo_can_return_a_collection_of_all_page_names_and_urls() { $repo = new ContentRepository(); $home = Page::create(['name' => 'home', 'description' => 'The homepage']); $about = Page::create(['name' => 'about', 'description' => 'The about page']); $expected = collect([['name' => 'home', 'url' => '/package-edible/pages/' . $home->id], ['name' => 'about', 'url' => '/package-edible/pages/' . $about->id]]); $this->assertEquals($expected, $repo->getPageListWithUrls()); }