Commit 49a509d1d6f22350ecf57b7f7adf7e0053eea3f3
1 parent
8c45a84511
Exists in
feature/hector
Creacion de la entidad educacion
Showing
9 changed files
with
488 additions
and
0 deletions
Show diff stats
app/Resources/views/educacion/edit.html.twig
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +{% extends 'base.html.twig' %} | ||
2 | + | ||
3 | +{% block body %} | ||
4 | + <h1>Educacion edit</h1> | ||
5 | + | ||
6 | + {{ form_start(edit_form) }} | ||
7 | + {{ form_widget(edit_form) }} | ||
8 | + <input type="submit" value="Edit" /> | ||
9 | + {{ form_end(edit_form) }} | ||
10 | + | ||
11 | + <ul> | ||
12 | + <li> | ||
13 | + <a href="{{ path('educacion_index') }}">Back to the list</a> | ||
14 | + </li> | ||
15 | + <li> | ||
16 | + {{ form_start(delete_form) }} | ||
17 | + <input type="submit" value="Delete"> | ||
18 | + {{ form_end(delete_form) }} | ||
19 | + </li> | ||
20 | + </ul> | ||
21 | +{% endblock %} |
app/Resources/views/educacion/index.html.twig
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +{% extends 'base.html.twig' %} | ||
2 | + | ||
3 | +{% block body %} | ||
4 | + <h1>Educacions list</h1> | ||
5 | + | ||
6 | + <table> | ||
7 | + <thead> | ||
8 | + <tr> | ||
9 | + <th>Id</th> | ||
10 | + <th>Universidad</th> | ||
11 | + <th>Titulo</th> | ||
12 | + <th>Fegreso</th> | ||
13 | + <th>Actions</th> | ||
14 | + </tr> | ||
15 | + </thead> | ||
16 | + <tbody> | ||
17 | + {% for educacion in educacions %} | ||
18 | + <tr> | ||
19 | + <td><a href="{{ path('educacion_show', { 'id': educacion.id }) }}">{{ educacion.id }}</a></td> | ||
20 | + <td>{{ educacion.universidad }}</td> | ||
21 | + <td>{{ educacion.titulo }}</td> | ||
22 | + <td>{% if educacion.fegreso %}{{ educacion.fegreso|date('Y-m-d') }}{% endif %}</td> | ||
23 | + <td> | ||
24 | + <ul> | ||
25 | + <li> | ||
26 | + <a href="{{ path('educacion_show', { 'id': educacion.id }) }}">show</a> | ||
27 | + </li> | ||
28 | + <li> | ||
29 | + <a href="{{ path('educacion_edit', { 'id': educacion.id }) }}">edit</a> | ||
30 | + </li> | ||
31 | + </ul> | ||
32 | + </td> | ||
33 | + </tr> | ||
34 | + {% endfor %} | ||
35 | + </tbody> | ||
36 | + </table> | ||
37 | + | ||
38 | + <ul> | ||
39 | + <li> | ||
40 | + <a href="{{ path('educacion_new') }}">Create a new educacion</a> | ||
41 | + </li> | ||
42 | + </ul> | ||
43 | +{% endblock %} |
app/Resources/views/educacion/new.html.twig
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +{% extends 'base.html.twig' %} | ||
2 | + | ||
3 | +{% block body %} | ||
4 | + <h1>Educacion creation</h1> | ||
5 | + | ||
6 | + {{ form_start(form) }} | ||
7 | + {{ form_widget(form) }} | ||
8 | + <input type="submit" value="Create" /> | ||
9 | + {{ form_end(form) }} | ||
10 | + | ||
11 | + <ul> | ||
12 | + <li> | ||
13 | + <a href="{{ path('educacion_index') }}">Back to the list</a> | ||
14 | + </li> | ||
15 | + </ul> | ||
16 | +{% endblock %} |
app/Resources/views/educacion/show.html.twig
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +{% extends 'base.html.twig' %} | ||
2 | + | ||
3 | +{% block body %} | ||
4 | + <h1>Educacion</h1> | ||
5 | + | ||
6 | + <table> | ||
7 | + <tbody> | ||
8 | + <tr> | ||
9 | + <th>Id</th> | ||
10 | + <td>{{ educacion.id }}</td> | ||
11 | + </tr> | ||
12 | + <tr> | ||
13 | + <th>Universidad</th> | ||
14 | + <td>{{ educacion.universidad }}</td> | ||
15 | + </tr> | ||
16 | + <tr> | ||
17 | + <th>Titulo</th> | ||
18 | + <td>{{ educacion.titulo }}</td> | ||
19 | + </tr> | ||
20 | + <tr> | ||
21 | + <th>Fegreso</th> | ||
22 | + <td>{% if educacion.fegreso %}{{ educacion.fegreso|date('Y-m-d') }}{% endif %}</td> | ||
23 | + </tr> | ||
24 | + </tbody> | ||
25 | + </table> | ||
26 | + | ||
27 | + <ul> | ||
28 | + <li> | ||
29 | + <a href="{{ path('educacion_index') }}">Back to the list</a> | ||
30 | + </li> | ||
31 | + <li> | ||
32 | + <a href="{{ path('educacion_edit', { 'id': educacion.id }) }}">Edit</a> | ||
33 | + </li> | ||
34 | + <li> | ||
35 | + {{ form_start(delete_form) }} | ||
36 | + <input type="submit" value="Delete"> | ||
37 | + {{ form_end(delete_form) }} | ||
38 | + </li> | ||
39 | + </ul> | ||
40 | +{% endblock %} |
src/UBV/PracticaBundle/Controller/educacionController.php
@@ -0,0 +1,136 @@ | @@ -0,0 +1,136 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace UBV\PracticaBundle\Controller; | ||
4 | + | ||
5 | +use UBV\PracticaBundle\Entity\educacion; | ||
6 | +use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
8 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request; | ||
9 | + | ||
10 | +/** | ||
11 | + * Educacion controller. | ||
12 | + * | ||
13 | + * @Route("educacion") | ||
14 | + */ | ||
15 | +class educacionController extends Controller | ||
16 | +{ | ||
17 | + /** | ||
18 | + * Lists all educacion entities. | ||
19 | + * | ||
20 | + * @Route("/", name="educacion_index") | ||
21 | + * @Method("GET") | ||
22 | + */ | ||
23 | + public function indexAction() | ||
24 | + { | ||
25 | + $em = $this->getDoctrine()->getManager(); | ||
26 | + | ||
27 | + $educacions = $em->getRepository('UBVPracticaBundle:educacion')->findAll(); | ||
28 | + | ||
29 | + return $this->render('educacion/index.html.twig', array( | ||
30 | + 'educacions' => $educacions, | ||
31 | + )); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * Creates a new educacion entity. | ||
36 | + * | ||
37 | + * @Route("/new", name="educacion_new") | ||
38 | + * @Method({"GET", "POST"}) | ||
39 | + */ | ||
40 | + public function newAction(Request $request) | ||
41 | + { | ||
42 | + $educacion = new Educacion(); | ||
43 | + $form = $this->createForm('UBV\PracticaBundle\Form\educacionType', $educacion); | ||
44 | + $form->handleRequest($request); | ||
45 | + | ||
46 | + if ($form->isSubmitted() && $form->isValid()) { | ||
47 | + $em = $this->getDoctrine()->getManager(); | ||
48 | + $em->persist($educacion); | ||
49 | + $em->flush(); | ||
50 | + | ||
51 | + return $this->redirectToRoute('educacion_show', array('id' => $educacion->getId())); | ||
52 | + } | ||
53 | + | ||
54 | + return $this->render('educacion/new.html.twig', array( | ||
55 | + 'educacion' => $educacion, | ||
56 | + 'form' => $form->createView(), | ||
57 | + )); | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * Finds and displays a educacion entity. | ||
62 | + * | ||
63 | + * @Route("/{id}", name="educacion_show") | ||
64 | + * @Method("GET") | ||
65 | + */ | ||
66 | + public function showAction(educacion $educacion) | ||
67 | + { | ||
68 | + $deleteForm = $this->createDeleteForm($educacion); | ||
69 | + | ||
70 | + return $this->render('educacion/show.html.twig', array( | ||
71 | + 'educacion' => $educacion, | ||
72 | + 'delete_form' => $deleteForm->createView(), | ||
73 | + )); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Displays a form to edit an existing educacion entity. | ||
78 | + * | ||
79 | + * @Route("/{id}/edit", name="educacion_edit") | ||
80 | + * @Method({"GET", "POST"}) | ||
81 | + */ | ||
82 | + public function editAction(Request $request, educacion $educacion) | ||
83 | + { | ||
84 | + $deleteForm = $this->createDeleteForm($educacion); | ||
85 | + $editForm = $this->createForm('UBV\PracticaBundle\Form\educacionType', $educacion); | ||
86 | + $editForm->handleRequest($request); | ||
87 | + | ||
88 | + if ($editForm->isSubmitted() && $editForm->isValid()) { | ||
89 | + $this->getDoctrine()->getManager()->flush(); | ||
90 | + | ||
91 | + return $this->redirectToRoute('educacion_edit', array('id' => $educacion->getId())); | ||
92 | + } | ||
93 | + | ||
94 | + return $this->render('educacion/edit.html.twig', array( | ||
95 | + 'educacion' => $educacion, | ||
96 | + 'edit_form' => $editForm->createView(), | ||
97 | + 'delete_form' => $deleteForm->createView(), | ||
98 | + )); | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Deletes a educacion entity. | ||
103 | + * | ||
104 | + * @Route("/{id}", name="educacion_delete") | ||
105 | + * @Method("DELETE") | ||
106 | + */ | ||
107 | + public function deleteAction(Request $request, educacion $educacion) | ||
108 | + { | ||
109 | + $form = $this->createDeleteForm($educacion); | ||
110 | + $form->handleRequest($request); | ||
111 | + | ||
112 | + if ($form->isSubmitted() && $form->isValid()) { | ||
113 | + $em = $this->getDoctrine()->getManager(); | ||
114 | + $em->remove($educacion); | ||
115 | + $em->flush(); | ||
116 | + } | ||
117 | + | ||
118 | + return $this->redirectToRoute('educacion_index'); | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Creates a form to delete a educacion entity. | ||
123 | + * | ||
124 | + * @param educacion $educacion The educacion entity | ||
125 | + * | ||
126 | + * @return \Symfony\Component\Form\Form The form | ||
127 | + */ | ||
128 | + private function createDeleteForm(educacion $educacion) | ||
129 | + { | ||
130 | + return $this->createFormBuilder() | ||
131 | + ->setAction($this->generateUrl('educacion_delete', array('id' => $educacion->getId()))) | ||
132 | + ->setMethod('DELETE') | ||
133 | + ->getForm() | ||
134 | + ; | ||
135 | + } | ||
136 | +} |
src/UBV/PracticaBundle/Entity/educacion.php
@@ -0,0 +1,128 @@ | @@ -0,0 +1,128 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace UBV\PracticaBundle\Entity; | ||
4 | + | ||
5 | +use Doctrine\ORM\Mapping as ORM; | ||
6 | + | ||
7 | +/** | ||
8 | + * educacion | ||
9 | + * | ||
10 | + * @ORM\Table(name="educacion") | ||
11 | + * @ORM\Entity(repositoryClass="UBV\PracticaBundle\Repository\educacionRepository") | ||
12 | + */ | ||
13 | +class educacion | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @var int | ||
17 | + * | ||
18 | + * @ORM\Column(name="id", type="integer") | ||
19 | + * @ORM\Id | ||
20 | + * @ORM\GeneratedValue(strategy="AUTO") | ||
21 | + */ | ||
22 | + private $id; | ||
23 | + | ||
24 | + /** | ||
25 | + * @var string | ||
26 | + * | ||
27 | + * @ORM\Column(name="universidad", type="string", length=255) | ||
28 | + */ | ||
29 | + private $universidad; | ||
30 | + | ||
31 | + /** | ||
32 | + * @var string | ||
33 | + * | ||
34 | + * @ORM\Column(name="titulo", type="string", length=255) | ||
35 | + */ | ||
36 | + private $titulo; | ||
37 | + | ||
38 | + /** | ||
39 | + * @var \DateTime | ||
40 | + * | ||
41 | + * @ORM\Column(name="fegreso", type="date") | ||
42 | + */ | ||
43 | + private $fegreso; | ||
44 | + | ||
45 | + | ||
46 | + /** | ||
47 | + * Get id | ||
48 | + * | ||
49 | + * @return int | ||
50 | + */ | ||
51 | + public function getId() | ||
52 | + { | ||
53 | + return $this->id; | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Set universidad | ||
58 | + * | ||
59 | + * @param string $universidad | ||
60 | + * | ||
61 | + * @return educacion | ||
62 | + */ | ||
63 | + public function setUniversidad($universidad) | ||
64 | + { | ||
65 | + $this->universidad = $universidad; | ||
66 | + | ||
67 | + return $this; | ||
68 | + } | ||
69 | + | ||
70 | + /** | ||
71 | + * Get universidad | ||
72 | + * | ||
73 | + * @return string | ||
74 | + */ | ||
75 | + public function getUniversidad() | ||
76 | + { | ||
77 | + return $this->universidad; | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * Set titulo | ||
82 | + * | ||
83 | + * @param string $titulo | ||
84 | + * | ||
85 | + * @return educacion | ||
86 | + */ | ||
87 | + public function setTitulo($titulo) | ||
88 | + { | ||
89 | + $this->titulo = $titulo; | ||
90 | + | ||
91 | + return $this; | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Get titulo | ||
96 | + * | ||
97 | + * @return string | ||
98 | + */ | ||
99 | + public function getTitulo() | ||
100 | + { | ||
101 | + return $this->titulo; | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * Set fegreso | ||
106 | + * | ||
107 | + * @param \DateTime $fegreso | ||
108 | + * | ||
109 | + * @return educacion | ||
110 | + */ | ||
111 | + public function setFegreso($fegreso) | ||
112 | + { | ||
113 | + $this->fegreso = $fegreso; | ||
114 | + | ||
115 | + return $this; | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Get fegreso | ||
120 | + * | ||
121 | + * @return \DateTime | ||
122 | + */ | ||
123 | + public function getFegreso() | ||
124 | + { | ||
125 | + return $this->fegreso; | ||
126 | + } | ||
127 | +} | ||
128 | + |
src/UBV/PracticaBundle/Form/educacionType.php
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace UBV\PracticaBundle\Form; | ||
4 | + | ||
5 | +use Symfony\Component\Form\AbstractType; | ||
6 | +use Symfony\Component\Form\FormBuilderInterface; | ||
7 | +use Symfony\Component\OptionsResolver\OptionsResolver; | ||
8 | + | ||
9 | +class educacionType extends AbstractType | ||
10 | +{ | ||
11 | + /** | ||
12 | + * {@inheritdoc} | ||
13 | + */ | ||
14 | + public function buildForm(FormBuilderInterface $builder, array $options) | ||
15 | + { | ||
16 | + $builder->add('universidad')->add('titulo')->add('fegreso'); | ||
17 | + }/** | ||
18 | + * {@inheritdoc} | ||
19 | + */ | ||
20 | + public function configureOptions(OptionsResolver $resolver) | ||
21 | + { | ||
22 | + $resolver->setDefaults(array( | ||
23 | + 'data_class' => 'UBV\PracticaBundle\Entity\educacion' | ||
24 | + )); | ||
25 | + } | ||
26 | + | ||
27 | + /** | ||
28 | + * {@inheritdoc} | ||
29 | + */ | ||
30 | + public function getBlockPrefix() | ||
31 | + { | ||
32 | + return 'ubv_practicabundle_educacion'; | ||
33 | + } | ||
34 | + | ||
35 | + | ||
36 | +} |
src/UBV/PracticaBundle/Repository/educacionRepository.php
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace UBV\PracticaBundle\Repository; | ||
4 | + | ||
5 | +/** | ||
6 | + * educacionRepository | ||
7 | + * | ||
8 | + * This class was generated by the Doctrine ORM. Add your own custom | ||
9 | + * repository methods below. | ||
10 | + */ | ||
11 | +class educacionRepository extends \Doctrine\ORM\EntityRepository | ||
12 | +{ | ||
13 | +} |
src/UBV/PracticaBundle/Tests/Controller/educacionControllerTest.php
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace UBV\PracticaBundle\Tests\Controller; | ||
4 | + | ||
5 | +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
6 | + | ||
7 | +class educacionControllerTest extends WebTestCase | ||
8 | +{ | ||
9 | + /* | ||
10 | + public function testCompleteScenario() | ||
11 | + { | ||
12 | + // Create a new client to browse the application | ||
13 | + $client = static::createClient(); | ||
14 | + | ||
15 | + // Create a new entry in the database | ||
16 | + $crawler = $client->request('GET', '/educacion/'); | ||
17 | + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /educacion/"); | ||
18 | + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); | ||
19 | + | ||
20 | + // Fill in the form and submit it | ||
21 | + $form = $crawler->selectButton('Create')->form(array( | ||
22 | + 'ubv_practicabundle_educacion[field_name]' => 'Test', | ||
23 | + // ... other fields to fill | ||
24 | + )); | ||
25 | + | ||
26 | + $client->submit($form); | ||
27 | + $crawler = $client->followRedirect(); | ||
28 | + | ||
29 | + // Check data in the show view | ||
30 | + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); | ||
31 | + | ||
32 | + // Edit the entity | ||
33 | + $crawler = $client->click($crawler->selectLink('Edit')->link()); | ||
34 | + | ||
35 | + $form = $crawler->selectButton('Update')->form(array( | ||
36 | + 'ubv_practicabundle_educacion[field_name]' => 'Foo', | ||
37 | + // ... other fields to fill | ||
38 | + )); | ||
39 | + | ||
40 | + $client->submit($form); | ||
41 | + $crawler = $client->followRedirect(); | ||
42 | + | ||
43 | + // Check the element contains an attribute with value equals "Foo" | ||
44 | + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); | ||
45 | + | ||
46 | + // Delete the entity | ||
47 | + $client->submit($crawler->selectButton('Delete')->form()); | ||
48 | + $crawler = $client->followRedirect(); | ||
49 | + | ||
50 | + // Check the entity has been delete on the list | ||
51 | + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); | ||
52 | + } | ||
53 | + | ||
54 | + */ | ||
55 | +} |