コード例 #1
0
ファイル: CoreTest.php プロジェクト: sebardo/core
 public function createBrandModel($uid, Brand $brand)
 {
     //index
     $crawler = $this->client->request('GET', '/admin/models/', array(), array(), array('PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'admin'));
     //Asserts
     $this->assertTrue($this->client->getResponse()->isSuccessful());
     $this->assertGreaterThan(0, $crawler->filter('html:contains("Modelos")')->count());
     ///////////////////////////////////////////////////////////////////////////////////////////
     //Click new ///////////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////////////////////
     $link = $crawler->filter('a:contains("Añadir nueva")')->eq(0)->link();
     $crawler = $this->client->click($link);
     // and click it
     //Asserts
     $this->assertTrue($this->client->getResponse()->isSuccessful());
     $this->assertGreaterThan(0, $crawler->filter('html:contains("Nuevo modelo")')->count());
     //fill form
     $form = $crawler->selectButton('Guardar')->form();
     $form['brand_model[name]'] = 'brandmodel ' . $uid;
     if ($brand instanceof Brand) {
         $form['brand_model[brand]']->select($brand->getId());
     }
     $form['brand_model[available]']->tick();
     $crawler = $this->client->submit($form);
     // submit the form
     //Asserts
     $this->assertTrue($this->client->getResponse() instanceof RedirectResponse);
     $crawler = $this->client->followRedirect();
     $this->assertTrue($this->client->getResponse()->isSuccessful());
     $this->assertGreaterThan(0, $crawler->filter('html:contains("brandmodel ' . $uid . '")')->count());
     $this->assertGreaterThan(0, $crawler->filter('html:contains("Se ha creado el modelo satisfactoriamente")')->count());
     return $crawler;
 }
コード例 #2
0
ファイル: BrandController.php プロジェクト: sebardo/ecommerce
 /**
  * Creates a form to delete a Brand entity.
  *
  * @param Brand $brand The Brand entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Brand $brand)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('ecommerce_brand_delete', array('id' => $brand->getId())))->setMethod('DELETE')->getForm();
 }