protected function assertDataInIndex($validator, array $data)
 {
     // pre
     $this->assertArrayHasKey('label', $data, 'Pre-Condition: Data hat kein Label gesetzt');
     $this->assertArrayHasKey('identifier', $data, 'Pre-Condition: Data hat keinen Identifier gesetzt');
     try {
         $validator->process($data);
         $this->fail('Es war eine UniqueConstraintException erwartet, aber keine wurde gecatched: ' . Code::varInfo($data));
     } catch (UniqueConstraintException $e) {
         $this->assertEquals($e->uniqueConstraint, 'tag_label', 'unique constraint name ist falsch gesetzt');
         $this->assertEquals($e->duplicateKey, array('label' => $data['label']), 'duplikate key daten sind falsch gesetzt');
         $this->assertEquals($e->duplicateIdentifier, $data['identifier'], 'identifier ist falsch gesetzt');
         return $e;
     }
 }
Beispiel #2
0
 /**
  * Lädt eine Datei aus der Datenbank
  * 
  * @params $input
  * 
  * @param int    $input die ID des Entities
  * //@param string $input der gespeicherte sourcePath des Entities (muss / oder \ enthalten)
  * @param string $input der sha1 hash des Contents der Datei
  * @return Psc\CMS\UploadedFile
  * @throws Psc\CMS\UploadedFileNotFoundException
  */
 public function load($input)
 {
     try {
         if ($input instanceof File) {
             $input = $input->getSha1();
         }
         if (is_numeric($input)) {
             $uplFile = $this->getRepository()->hydrate((int) $input);
             /*
             } elseif (is_string($input) && (mb_strpos($input,'/') !== FALSE || mb_strpos($input,'\\') !== FALSE)) {
               $uplFile = $this->repository->hydrateBy(array('sourcePath'=>(string) $input));
             */
         } elseif (is_string($input)) {
             // hash
             $uplFile = $this->getRepository()->hydrateBy(array('hash' => (string) $input));
         } elseif ($input instanceof UploadedFile) {
             $uplFile = $input;
         } else {
             throw new \Psc\Exception('Input kann nicht analyisiert werden: ' . Code::varInfo($input));
         }
         $this->doAttach($uplFile);
         return $uplFile;
     } catch (\Psc\Doctrine\EntityNotFoundException $e) {
         throw UploadedFileNotFoundException::fromEntityNotFound($e, $input);
     }
 }