-
-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #840 allowing the user to choose a controller class for make:…
…crud (weaverryan) This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- allowing the user to choose a controller class for make:crud Hi! This adds a 2nd question to `make:crud`: <img width="1140" alt="Screen Shot 2021-03-15 at 10 41 58 AM" src="https://user-images.githubusercontent.com/121003/111171192-12558c00-857b-11eb-8b6e-0a11bc028b9f.png"> Very simple - I have hit a few cases where I wanted this :). Cheers! Commits ------- 8bb6788 allowing the user to choose a controller class for make:crud
- Loading branch information
Showing
4 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/fixtures/MakeCrudCustomController/src/Entity/SweetFood.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity() | ||
*/ | ||
class SweetFood | ||
{ | ||
/** | ||
* @ORM\Column(name="id", type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @ORM\Column(name="title", type="string", length=255) | ||
*/ | ||
private $title; | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getTitle() | ||
{ | ||
return $this->title; | ||
} | ||
|
||
/** | ||
* @param mixed $title | ||
*/ | ||
public function setTitle($title) | ||
{ | ||
$this->title = $title; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
tests/fixtures/MakeCrudCustomController/tests/GeneratedCrudControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace App\Tests; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
class GeneratedCrudControllerTest extends WebTestCase | ||
{ | ||
public function testIndexAction() | ||
{ | ||
$client = self::createClient(); | ||
$crawler = $client->request('GET', '/sweet/food/admin/'); | ||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('SweetFood index', $client->getResponse()->getContent()); | ||
|
||
$newLink = $crawler->filter('a:contains("Create new")')->eq(0)->link(); | ||
|
||
$crawler = $client->click($newLink); | ||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('New SweetFood', $client->getResponse()->getContent()); | ||
|
||
$newForm = $crawler->selectButton('Save')->form(); | ||
$client->submit($newForm, ['sweet_food[title]' => 'Candy']); | ||
$this->assertTrue($client->getResponse()->isRedirect()); | ||
|
||
$crawler = $client->followRedirect(); | ||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('SweetFood index', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('<td>Candy</td>', $client->getResponse()->getContent()); | ||
|
||
$editLink = $crawler->filter('a:contains("edit")')->eq(0)->link(); | ||
$crawler = $client->click($editLink); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('Edit SweetFood', $client->getResponse()->getContent()); | ||
$this->assertGreaterThan(0, $crawler->filter('input[type=text]')->count()); | ||
|
||
$editForm = $crawler->selectButton('Update')->form(); | ||
$client->submit($editForm, ['sweet_food[title]' => 'Candy edited']); | ||
$this->assertTrue($client->getResponse()->isRedirect()); | ||
|
||
$crawler = $client->followRedirect(); | ||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('SweetFood index', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('Candy edited', $client->getResponse()->getContent()); | ||
|
||
$showLink = $crawler->filter('a:contains("show")')->eq(0)->link(); | ||
|
||
$crawler = $client->click($showLink); | ||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('SweetFood', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('Candy edited', $client->getResponse()->getContent()); | ||
|
||
$deleteForm = $crawler->selectButton('Delete')->form(); | ||
$client->submit($deleteForm); | ||
$this->assertTrue($client->getResponse()->isRedirect()); | ||
|
||
$client->followRedirect(); | ||
$this->assertTrue($client->getResponse()->isSuccessful()); | ||
$this->assertStringContainsString('<!DOCTYPE html>', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('SweetFood index', $client->getResponse()->getContent()); | ||
$this->assertStringContainsString('no records found', $client->getResponse()->getContent()); | ||
} | ||
} |