public function testLoadAggregateWithDocuments()
 {
     $user = phpillowUserDocument::createNew();
     $user->login = '******';
     $group = phpillowGroupDocument::createNew();
     $group->name = 'users';
     try {
         $group->userDocs = array($user);
         $groupID = $group->save();
         $this->fail('Expected phpillowValidationException.');
     } catch (phpillowValidationException $e) {
         /* Expected */
     }
 }
 public function testDocumentArrayValidatorSpecifiedInvalid()
 {
     $validator = new phpillowDocumentArrayValidator('phpillowUserDocument');
     $doc1 = phpillowGroupDocument::createNew();
     $doc1->name = 'Maintainer';
     $doc1->save();
     $doc2 = phpillowUserDocument::createNew();
     $doc2->login = '******';
     $doc2->save();
     try {
         $validator->validate(array($doc1, $doc2));
         $this->fail('Expected phpillowValidationException.');
     } catch (phpillowValidationException $e) {
         $this->assertSame('Invalid document type provided.', $e->getText());
     }
 }
 public function testDocumentFetchByIdWithCorrectType()
 {
     $doc = phpillowUserDocument::createNew();
     $doc->login = '******';
     $doc->save();
     $user = new phpillowUserDocument();
     $user->fetchById($doc->_id);
     $this->assertSame('kore', $user->login);
 }
 public static function createNew($docType = null)
 {
     return parent::createNew($docType === null ? __CLASS__ : $docType);
 }
 public function testCheckRequirements()
 {
     $doc = phpillowUserDocument::createNew();
     $this->assertSame(array('login'), $doc->checkRequirements());
 }
 public function testManuallySetContentType()
 {
     $doc = phpillowUserDocument::createNew();
     $doc->login = '******';
     $doc->attachFile($file = dirname(__FILE__) . '/data/image_png.png', 'image_png.png', 'image/png');
     $doc->save();
     $doc = phpillowManager::fetchDocument('user', 'user-kore');
     $response = $doc->getFile('image_png.png');
     $this->assertSame(file_get_contents($file), $response->data);
     $this->assertSame('image/png', $response->contentType);
 }