public function setUp() { parent::setUp(); \DvsPage::create(['id' => 9999, 'language_id' => 45, 'title' => 'Some title', 'is_admin' => 0, 'dvs_admin' => 0, 'route_name' => 'some-route-name', 'slug' => 'some/route']); \DvsPageVersion::create(['id' => 9999, 'page_id' => 9999, 'created_by_user_id' => 0, 'name' => 'Default', 'starts_at' => '2015-01-02 00:00:00', 'ends_at' => '2015-01-03 00:00:00']); $this->Framework = new \Devise\Support\Framework(); $this->Framework->URL = m::mock('MockedURL'); $this->Framework->URL->shouldReceive('route')->andReturn('admin/calendar/sources/page-versions/id'); $this->PageVersionSource = new PageVersionSource(new \DvsPageVersion(), $this->Framework); }
public function test_it_gets_page_versions_by_ab() { $page = \DvsPage::find(1); $version = \DvsPageVersion::find(1); $version->ab_testing_amount = 50; $version->save(); $newVersion = \DvsPageVersion::create(['page_id' => 1, 'created_by_user_id' => 1, 'name' => 'New Version', 'starts_at' => new \DateTime('yesterday'), 'ends_at' => null, 'ab_testing_amount' => 50]); $versions = $this->PagesRepository->getPageVersionsByAB($page); assertCount(2, $versions); }
public function test_it_updates_page_version_view() { $this->PageVersionManager->updatePageVersionView(1, 'some.view'); $version = \DvsPageVersion::find(1); assertEquals('some.view', $version->view); }
public function test_it_finds_collections_for_page_version() { $this->CollectionFieldsFactory->shouldReceive('createFromCollectionInstance')->times(2); $output = $this->CollectionsRepository->findCollectionsForPageVersion(\DvsPageVersion::find(1)); }
/** * Returns a list of all the unscheduled page versions * in this system * * @return Collection */ public function getUnscheduledPageVersions() { $versions = $this->PageVersion->with('page')->where('starts_at', '=', null)->get(); return $this->wrapPageDataAroundVersions($versions); }
/** * Get the list of collections for this page * * @param DvsPageVersion $page * @return array($collectionName => array(CollectionFields)) */ public function findCollectionsForPageVersion(\DvsPageVersion $pageVersion) { $collections = array(); // get a list of instances for this page // we order it by sort so that they are in order in our $collections array already $collectionInstances = $pageVersion->collectionInstances()->with('collectionSet')->orderBy('sort', 'ASC')->get(); // loop over the instances and add it to the collections array foreach ($collectionInstances as $index => $collectionInstance) { // we want to add a dynamically created key name to the instance? // not being used in this context as far as I know of... but I'm // leaving this here just in case we need to bring it back at some point // $keyName = ($index + 1) . ') ' .$collectionInstance->name; $keyName = $collectionInstance->collectionSet->name; // make this an array if it is not already set $collections[] = isset($collections[$keyName]) ? $collections[$keyName] : []; // add these collection fields to this array $collections[$keyName][] = $this->CollectionFieldsFactory->createFromCollectionInstance($collectionInstance); } // put these instances into a Laravel collection foreach ($collections as $keyName => $collectionInstances) { $collections[$keyName] = new Collection($collectionInstances); } return $collections; }