Inheritance: extends BaseCollection
 private function createCollection($typeName, $title = [], $parent = null)
 {
     // Collection
     $collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $collection->setStyle(json_encode($style));
     // Create Collection Type
     $collectionType = new CollectionType();
     $collectionType->setName($typeName);
     $collectionType->setDescription('Default Collection Type');
     $collection->setType($collectionType);
     // Collection Meta 1
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle(isset($title['en-gb']) ? $title['en-gb'] : 'Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collectionMeta->setCollection($collection);
     $collection->setDefaultMeta($collectionMeta);
     $collection->addMeta($collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle(isset($title['de']) ? $title['de'] : 'Kollection');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($collection);
     $collection->addMeta($collectionMeta2);
     $collection->setParent($parent);
     $this->em->persist($collection);
     $this->em->persist($collectionType);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionMeta2);
     $this->em->flush();
     return $collection;
 }
 private function createCollection($name, $parent, $collectionType)
 {
     $collection = new Collection();
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle($name);
     $collectionMeta->setLocale('en-gb');
     $collection->setType($collectionType);
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     if ($parent !== null) {
         $collection->setParent($this->collections[$parent]);
         $this->collections[$parent]->addChildren($collection);
     }
     $this->em->persist($collection);
     $this->em->persist($collectionMeta);
     return $collection;
 }
 public function testFindByCollectionId()
 {
     $collection = new Collection();
     $collection->setType($this->collectionType);
     $this->em->persist($collection);
     $this->createFile('Old Title 1', 'New Title 1');
     $this->createFile('Old Title 2', 'New Title 2');
     $this->createFile('Old Title 3', 'New Title 3', $collection);
     $this->em->flush();
     $titles = array_map(function (FileVersionMeta $fileVersionMeta) {
         return $fileVersionMeta->getTitle();
     }, $this->fileVersionMetaRepository->findByCollectionId($this->collection->getId()));
     $this->assertContains('New Title 1', $titles);
     $this->assertContains('New Title 2', $titles);
     $this->assertContains('Old Title 1', $titles);
     $this->assertContains('Old Title 2', $titles);
     $this->assertNotContains('New Title 3', $titles);
     $this->assertNotContains('Old Title 3', $titles);
 }
 /**
  * @description Test DELETE
  */
 public function testDeleteById()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('DELETE', '/api/collections/' . $this->collection1->getId());
     $this->assertEquals('204', $client->getResponse()->getStatusCode());
     $client = $this->createAuthenticatedClient();
     $client->request('GET', '/api/collections/' . $this->collection1->getId());
     $this->assertEquals(404, $client->getResponse()->getStatusCode());
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals(5005, $response->code);
     $this->assertTrue(isset($response->message));
 }
 private function createCollection($name, $parent = null)
 {
     $collection = new Collection();
     $collectionType = new CollectionType();
     $collectionType->setName($name);
     $collectionType->setDescription('Default Collection Type');
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle('Test Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collection->setType($collectionType);
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     if ($parent !== null) {
         $collection->setParent($this->collections[$parent]);
         $this->collections[$parent]->addChildren($collection);
     }
     $this->em->persist($collection);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionType);
     return $collection;
 }
Beispiel #6
0
 /**
  * Get or create a media collection.
  *
  * @param string $name Name of collection to get or create
  *
  * @return Collection
  */
 private function getOrCreateMediaCollection($name)
 {
     $manager = $this->getEntityManager();
     $collectionMeta = $manager->getRepository('SuluMediaBundle:CollectionMeta')->findOneByTitle($name);
     if ($collectionMeta) {
         return $collectionMeta->getCollection();
     }
     $collection = new Collection();
     $collection->setType($this->getOrCreateCollectionType('Default'));
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle($name);
     $collectionMeta->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta->setLocale('en');
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     $manager->persist($collection);
     $manager->persist($collectionMeta);
     $manager->flush();
     $this->lastCollection = $collection;
     return $collection;
 }
Beispiel #7
0
 /**
  * Remove collections.
  *
  * @param Collection $collections
  *
  * @return $this
  */
 public function removeCollection(Collection $collections)
 {
     $this->collections->removeElement($collections);
     return $this;
 }
 public function initLogo()
 {
     $collectionType = new CollectionType();
     $collectionType->setName('My collection type');
     $this->em->persist($collectionType);
     $collection = new Collection();
     $collection->setType($collectionType);
     $this->em->persist($collection);
     $imageType = new MediaType();
     $imageType->setName('image');
     $imageType->setDescription('This is an image');
     $this->em->persist($imageType);
     $file = new File();
     $file->setVersion(1);
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName('logo.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setChanged(new \DateTime('1937-04-20'));
     $fileVersion->setCreated(new \DateTime('1937-04-20'));
     $file->addFileVersion($fileVersion);
     $this->em->persist($fileVersion);
     $this->logo = new Media();
     $this->logo->setType($imageType);
     $this->logo->setCollection($collection);
     $this->logo->addFile($file);
     $file->setMedia($this->logo);
     $this->em->persist($this->logo);
     $this->em->persist($file);
 }
Beispiel #9
0
 /**
  * Test move to non existing media.
  */
 public function testMoveNonExistingMedia()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('POST', '/api/media/404?action=move&destination=' . $this->collection->getId());
     $this->assertEquals(404, $client->getResponse()->getStatusCode());
 }
Beispiel #10
0
 protected function setUpCollection()
 {
     $collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $collection->setStyle(json_encode($style));
     // Create Collection Type
     $collectionType = new CollectionType();
     $collectionType->setName('Default Collection Type');
     $collectionType->setDescription('Default Collection Type');
     $collection->setType($collectionType);
     // Collection Meta 1
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle('Test Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle('Test Kollektion');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($collection);
     $collection->addMeta($collectionMeta2);
     $this->em->persist($collection);
     $this->em->persist($collectionType);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionMeta2);
     $this->collections[] = $collection;
     $collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $collection->setStyle(json_encode($style));
     // Create Collection Type
     $collectionType = new CollectionType();
     $collectionType->setName('Default Collection Type');
     $collectionType->setDescription('Default Collection Type');
     $collection->setType($collectionType);
     // Collection Meta 1
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle('Test Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle('Test Kollektion');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($collection);
     $collection->addMeta($collectionMeta2);
     $this->em->persist($collection);
     $this->em->persist($collectionType);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionMeta2);
     $this->collections[] = $collection;
 }