Ejemplo n.º 1
0
 public function createProduct($name)
 {
     $p = new Product();
     $ret = $p->create(array('name' => $name));
     $this->assertTrue($ret->success);
     ok($p->id, 'got created id');
     return $p;
 }
 /**
  *
  * @Route("/add", name="add_product")
  */
 public function addAction()
 {
     $product = new Product();
     $product->setName('pilka3');
     $product->setPrice('29,99');
     $product->setDescription('lalalala');
     $product->save();
     return new Response('Created product ' . $product->getId());
 }
Ejemplo n.º 3
0
 /**
  * Exclude object from result
  *
  * @param   Product $product Object to remove from the list of results
  *
  * @return ProductQuery The current query, for fluid interface
  */
 public function prune($product = null)
 {
     if ($product) {
         $this->addUsingAlias(ProductPeer::ID, $product->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 4
0
 public function testCreateSubActionWithRelationshipAndReloadExistingSubRecord()
 {
     $tmpfile = tempnam('/tmp', 'test_image_') . '.png';
     copy('tests/data/404.png', $tmpfile);
     $files = ['image' => CreateFileArray('404.png', 'image/png', $tmpfile)];
     // new ActionRequest(['title' => 'Test Image'], $files);
     $createImage = new CreateProductImage(['title' => 'Test Image'], ['files' => $files]);
     $this->assertActionInvokeSuccess($createImage);
     $image = $createImage->getRecord();
     $this->assertNotNull($image);
     $this->assertNotNull($image->id);
     $product = new Product();
     $product->create(['name' => 'Test Product']);
     $updateProduct = new UpdateProduct(['name' => 'Updated Product'], ['record' => $product]);
     $relation = clone $updateProduct->getRelation('images');
     $updateImage = $updateProduct->createSubActionWithRelationship($relation, ['id' => $image->id], $files);
     $this->assertInstanceOf('ActionKit\\RecordAction\\UpdateRecordAction', $updateImage);
     $this->assertActionInvokeSuccess($updateImage);
     $relation = clone $updateProduct->getRelation('images');
     $relation['update_action'] = 'ProductBundle\\Action\\UpdateProductImage';
     $updateImage = $updateProduct->createSubActionWithRelationship($relation, ['id' => $image->id], $files);
     $this->assertInstanceOf('ActionKit\\RecordAction\\UpdateRecordAction', $updateImage);
     $this->assertActionInvokeSuccess($updateImage);
 }
Ejemplo n.º 5
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Product $obj A Product object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         ProductPeer::$instances[$key] = $obj;
     }
 }