Beispiel #1
0
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()->
  with('response')->begin()->
    matches('/ok/')->
  end()
;

$b->test()->ok(file_exists($uploadedFile), 'file is uploaded');
$b->test()->is(file_get_contents($uploadedFile), file_get_contents($fileToUpload), 'file is correctly uploaded');

$c = new Criteria();
$c->add(AttachmentPeer::NAME, $name);
$attachments = AttachmentPeer::doSelect($c);

$b->test()->is(count($attachments), 1, 'the attachment has been saved in the database');
$b->test()->ok($attachments[0]->getArticleId(), 'the attachment is tied to an article');
$b->test()->is($attachments[0]->getFile(), 'uploaded.yml', 'the attachment filename has been saved in the database');

// sfValidatorPropelUnique

// create a category with a unique name
$b->
  get('/unique/category')->
  with('request')->begin()->
    isParameter('module', 'unique')->
    isParameter('action', 'category')->
  end()->
  with('response')->isStatusCode(200)->
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(AttachmentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(AttachmentPeer::DATABASE_NAME);
         $criteria->add(AttachmentPeer::ID, $pks, Criteria::IN);
         $objs = AttachmentPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Beispiel #3
0
 /**
  * Gets an array of Attachment objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this Article has previously been saved, it will retrieve
  * related Attachments from storage. If this Article is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array Attachment[]
  * @throws     PropelException
  */
 public function getAttachments($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ArticlePeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collAttachments === null) {
         if ($this->isNew()) {
             $this->collAttachments = array();
         } else {
             $criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
             AttachmentPeer::addSelectColumns($criteria);
             $this->collAttachments = AttachmentPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
             AttachmentPeer::addSelectColumns($criteria);
             if (!isset($this->lastAttachmentCriteria) || !$this->lastAttachmentCriteria->equals($criteria)) {
                 $this->collAttachments = AttachmentPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastAttachmentCriteria = $criteria;
     return $this->collAttachments;
 }
Beispiel #4
0
 public function getAttachments($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ArticlePeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collAttachments === null) {
         if ($this->isNew()) {
             $this->collAttachments = array();
         } else {
             $criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
             AttachmentPeer::addSelectColumns($criteria);
             $this->collAttachments = AttachmentPeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
             AttachmentPeer::addSelectColumns($criteria);
             if (!isset($this->lastAttachmentCriteria) || !$this->lastAttachmentCriteria->equals($criteria)) {
                 $this->collAttachments = AttachmentPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastAttachmentCriteria = $criteria;
     return $this->collAttachments;
 }