diff --git a/app/Resources/views/candidato/edit.html.twig b/app/Resources/views/candidato/edit.html.twig new file mode 100644 index 0000000..2045c4d --- /dev/null +++ b/app/Resources/views/candidato/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Editar Candidato

+ + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + + +{% endblock %} diff --git a/app/Resources/views/candidato/index.html.twig b/app/Resources/views/candidato/index.html.twig new file mode 100644 index 0000000..02cb527 --- /dev/null +++ b/app/Resources/views/candidato/index.html.twig @@ -0,0 +1,50 @@ +{% extends 'base.html.twig' %} + +{% block body %} +{% for type, flashMessage in app.session.flashbag.all() %} +
+ + {% if flashMessage.title is defined %} + {{ flashMessage.title }} + {{ flashMessage.message }} + {% else %} + {{ type }} + {% endif %} +
+ {% endfor %} +

Formulario de Candidatos

+ + + + + + + + + + + + + + + + {% for candidato in candidatos %} + + + + + + + + + {% endfor %} + +
CedulaNombreApellidoPaisEstadoAcciones
{{ candidato.cedula }}{{ candidato.nombre }}{{ candidato.apellido }}{{ candidato.pais }}{{ candidato.estado }} +
    + + +
+
+{% endblock %} diff --git a/app/Resources/views/candidato/new.html.twig b/app/Resources/views/candidato/new.html.twig new file mode 100644 index 0000000..3891a4e --- /dev/null +++ b/app/Resources/views/candidato/new.html.twig @@ -0,0 +1,157 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Formulario para crear un candidato

+
+ +
+ {{ form_start(form, {'attr': {'novalidate': 'novalidate'}, 'action': path('candidato_new')}) }} +
+
+ {{ form_label(form.nombre) }} + {{ form_widget(form.nombre) }} + {% if form.nombre.vars.errors[0].message is defined %} + + {{ form.nombre.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_label(form.apellido) }} + {{ form_widget(form.apellido) }} + {% if form.apellido.vars.errors[0].message is defined %} + + {{ form.apellido.vars.errors[0].message }} + {% endif %} +
+
+ +
+
+ {{ form_label(form.cedula) }} + {{ form_widget(form.cedula) }} + {% if form.cedula.vars.errors[0].message is defined %} + + {{ form.cedula.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_label(form.edad) }} + {{ form_widget(form.edad) }} + {% if form.edad.vars.errors[0].message is defined %} + + {{ form.edad.vars.errors[0].message }} + {% endif %} +
+ +
+
+ + {{ form_widget(form.sexo) }} +
+
+
+
+
+ {{ form_label(form.estadoCivil) }} + {{ form_widget(form.estadoCivil) }} + {% if form.estadoCivil.vars.errors[0].message is defined %} + + {{ form.estadoCivil.vars.errors[0].message }} + {% endif %} +
+
+
+ +
+
+
+ +
+
+
+ {{ form_label(form.primaria) }} + {{ form_widget(form.primaria) }} + {% if form.primaria.vars.errors[0].message is defined %} + + {{ form.primaria.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_label(form.secundaria) }} + {{ form_widget(form.secundaria) }} + {% if form.secundaria.vars.errors[0].message is defined %} + + {{ form.secundaria.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_label(form.terciaria) }} + {{ form_widget(form.terciaria) }} + {% if form.terciaria.vars.errors[0].message is defined %} + + {{ form.terciaria.vars.errors[0].message }} + {% endif %} +
+
+
+
+
+ {{ form_label(form.aldea) }} + {{ form_widget(form.aldea) }} + {% if form.aldea.vars.errors[0].message is defined %} + + {{ form.aldea.vars.errors[0].message }} + {% endif %} +
+
+
+
+
+ +
+ +
+
+
+ {{ form_label(form.estado) }} + {{ form_widget(form.estado) }} + {% if form.estado.vars.errors[0].message is defined %} + + {{ form.estado.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_label(form.municipio) }} + {{ form_widget(form.municipio) }} + {% if form.municipio.vars.errors[0].message is defined %} + + {{ form.municipio.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_label(form.parroquia) }} + {{ form_widget(form.parroquia) }} + {% if form.parroquia.vars.errors[0].message is defined %} + + {{ form.parroquia.vars.errors[0].message }} + {% endif %} +
+
+
+
+
+ +
+ + +{% endblock %} diff --git a/app/Resources/views/candidato/show.html.twig b/app/Resources/views/candidato/show.html.twig new file mode 100644 index 0000000..69108e9 --- /dev/null +++ b/app/Resources/views/candidato/show.html.twig @@ -0,0 +1,74 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +

Ver Candidato

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ candidato.id }}
Nombre{{ candidato.nombre }}
Apellido{{ candidato.apellido }}
Cedula{{ candidato.cedula }}
Edad{{ candidato.edad }}
Sexo{% if candidato.sexo %}Yes{% else %}No{% endif %}
Primaria{{ candidato.primaria }}
Secundaria{{ candidato.secundaria }}
Terciaria{{ candidato.terciaria }}
Pais{{ candidato.pais }}
Estado{{ candidato.estado }}
Municipio{{ candidato.municipio }}
Parroquia{{ candidato.parroquia }}
+
+ +
+{% endblock %} diff --git a/app/Resources/views/estado/edit.html.twig b/app/Resources/views/estado/edit.html.twig new file mode 100644 index 0000000..26cb310 --- /dev/null +++ b/app/Resources/views/estado/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estado edit

+ + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + + +{% endblock %} diff --git a/app/Resources/views/estado/index.html.twig b/app/Resources/views/estado/index.html.twig new file mode 100644 index 0000000..4956622 --- /dev/null +++ b/app/Resources/views/estado/index.html.twig @@ -0,0 +1,41 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estados list

+ + + + + + + + + + + + {% for estado in estados %} + + + + + + + {% endfor %} + +
IdDescriptionCodigoActions
{{ estado.id }}{{ estado.descripcion }}{{ estado.codigo }} + +
+ + +{% endblock %} diff --git a/app/Resources/views/estado/new.html.twig b/app/Resources/views/estado/new.html.twig new file mode 100644 index 0000000..0086f9e --- /dev/null +++ b/app/Resources/views/estado/new.html.twig @@ -0,0 +1,16 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estado creation

+ + {{ form_start(form) }} + {{ form_widget(form) }} + + {{ form_end(form) }} + + +{% endblock %} diff --git a/app/Resources/views/estado/show.html.twig b/app/Resources/views/estado/show.html.twig new file mode 100644 index 0000000..b6edad6 --- /dev/null +++ b/app/Resources/views/estado/show.html.twig @@ -0,0 +1,36 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estado

+ + + + + + + + + + + + + + + + +
Id{{ estado.id }}
Descripcion{{ estado.descripcion }}
Codigo{{ estado.codigo }}
+ + +{% endblock %} diff --git a/app/Resources/views/municipio/edit.html.twig b/app/Resources/views/municipio/edit.html.twig new file mode 100644 index 0000000..c3b65d1 --- /dev/null +++ b/app/Resources/views/municipio/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Municipio edit

+ + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + + +{% endblock %} diff --git a/app/Resources/views/municipio/index.html.twig b/app/Resources/views/municipio/index.html.twig new file mode 100644 index 0000000..27460e8 --- /dev/null +++ b/app/Resources/views/municipio/index.html.twig @@ -0,0 +1,42 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Municipios list

+ + + + + + + + + + + + + {% for municipio in municipios %} + + + + + + + + {% endfor %} + +
IdDescripcionCodigoEstadoAcciones
{{ municipio.id }}{{ municipio.descripcion }}{{ municipio.codigo }}{{ municipio.estado }} + +
+ +{% endblock %} diff --git a/app/Resources/views/municipio/new.html.twig b/app/Resources/views/municipio/new.html.twig new file mode 100644 index 0000000..407e2cb --- /dev/null +++ b/app/Resources/views/municipio/new.html.twig @@ -0,0 +1,16 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Municipio creation

+ + {{ form_start(form) }} + {{ form_widget(form) }} + + {{ form_end(form) }} + + +{% endblock %} \ No newline at end of file diff --git a/app/Resources/views/municipio/show.html.twig b/app/Resources/views/municipio/show.html.twig new file mode 100644 index 0000000..55470a4 --- /dev/null +++ b/app/Resources/views/municipio/show.html.twig @@ -0,0 +1,36 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Municipio

+ + + + + + + + + + + + + + + + +
Id{{ municipio.id }}
Descripcion{{ municipio.descripcion }}
Codigo{{ municipio.codigo }}
+ + +{% endblock %} diff --git a/app/Resources/views/persona/edit.html.twig b/app/Resources/views/persona/edit.html.twig index 10d4c38..a45e655 100644 --- a/app/Resources/views/persona/edit.html.twig +++ b/app/Resources/views/persona/edit.html.twig @@ -1,21 +1,51 @@ {% extends 'base.html.twig' %} {% block body %} -

Persona edit

+

Editar Persona

- {{ form_start(edit_form) }} - {{ form_widget(edit_form) }} - - {{ form_end(edit_form) }} +
+
+
+
+ {{ form_label(edit_form.nombre) }} + {{ form_widget(edit_form.nombre) }} + + {% if edit_form.nombre.vars.errors[0].message is defined %} + + {{ edit_form.nombre.vars.errors[0].message }} + {% endif %} +
+ +
+
+ {{ form_label(edit_form.apellido) }} + {{ form_widget(edit_form.apellido) }} + {% if edit_form.apellido.vars.errors[0].message is defined %} + + {{ edit_form.apellido.vars.errors[0].message }} + {% endif %} +
+
+ +
+
+
+ {{ form_label(edit_form.cedula) }} + {{ form_widget(edit_form.cedula) }} + {% if edit_form.cedula.vars.errors[0].message is defined %} + + {{ edit_form.cedula.vars.errors[0].message }} + {% endif %} +
+
+ +
+
+ {% endblock %} diff --git a/app/Resources/views/persona/index.html.twig b/app/Resources/views/persona/index.html.twig index 4048a56..4bbcb91 100644 --- a/app/Resources/views/persona/index.html.twig +++ b/app/Resources/views/persona/index.html.twig @@ -1,17 +1,32 @@ {% extends 'base.html.twig' %} {% block body %} -

Personas list

+ {% for type, flashMessage in app.session.flashbag.all() %} +
+ + {% if flashMessage.title is defined %} + {{ flashMessage.title }} + {{ flashMessage.message }} + {% else %} + {{ type }} + {% endif %} +
+ {% endfor %} - +

Lista de personas

+ + + +
- + - - - + + {% for persona in personas %} @@ -19,25 +34,15 @@ - + {% endfor %}
Id Nombre ApellidoCeduñaActions
CedulaAcciones
{{ persona.id }} {{ persona.nombre }} {{ persona.apellido }}{{ persona.ceduña }}{{ persona.cedula }}
- - {% endblock %} diff --git a/app/Resources/views/persona/new.html.twig b/app/Resources/views/persona/new.html.twig index 4988328..c6deb62 100644 --- a/app/Resources/views/persona/new.html.twig +++ b/app/Resources/views/persona/new.html.twig @@ -1,16 +1,47 @@ {% extends 'base.html.twig' %} {% block body %} -

Persona creation

+

Formulario para crear persona

- {{ form_start(form) }} - {{ form_widget(form) }} - - {{ form_end(form) }} +
+
+ {{ form_start(form, {'attr': {'novalidate': 'novalidate'}, 'action': path('persona_new')}) }} + {{ form_label(form.nombre) }} + {{ form_widget(form.nombre) }} + {% if form.nombre.vars.errors[0].message is defined %} + + {{ form.nombre.vars.errors[0].message }} + {% endif %} +
+ +
+ {{ form_start(form, {'attr': {'novalidate': 'novalidate'}, 'action': path('persona_new')}) }} + {{ form_label(form.apellido) }} + {{ form_widget(form.apellido) }} + {% if form.apellido.vars.errors[0].message is defined %} + + {{ form.apellido.vars.errors[0].message }} + {% endif %} +
+
+
+
+ {{ form_start(form, {'attr': {'novalidate': 'novalidate'}, 'action': path('persona_new')}) }} + {{ form_label(form.cedula) }} + {{ form_widget(form.cedula) }} + {% if form.cedula.vars.errors[0].message is defined %} + + {{ form.cedula.vars.errors[0].message }} + {% endif %} +
+
+ +
+
{% endblock %} diff --git a/app/Resources/views/persona/show.html.twig b/app/Resources/views/persona/show.html.twig index ea1be96..04bbc3e 100644 --- a/app/Resources/views/persona/show.html.twig +++ b/app/Resources/views/persona/show.html.twig @@ -1,40 +1,38 @@ {% extends 'base.html.twig' %} {% block body %} -

Persona

+

Ver Persona

- +
- + - + - + - - + +
Id{{ persona.id }}
Nombre{{ persona.nombre }}
Apellido{{ persona.apellido }}
Ceduña{{ persona.ceduña }}Cedula
- +
+ + + + + {{ form_start(delete_form) }} + + {{ form_end(delete_form) }} + + +
{% endblock %} diff --git a/src/UBV/PracticaBundle/Controller/candidatoController.php b/src/UBV/PracticaBundle/Controller/candidatoController.php new file mode 100644 index 0000000..dabcffe --- /dev/null +++ b/src/UBV/PracticaBundle/Controller/candidatoController.php @@ -0,0 +1,137 @@ +getDoctrine()->getManager(); + + $candidatos = $em->getRepository('UBVPracticaBundle:candidato')->findAll(); + + return $this->render('candidato/index.html.twig', array( + 'candidatos' => $candidatos, + )); + } + + /** + * Creates a new candidato entity. + * + * @Route("/new", name="candidato_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request) + { + $candidato = new Candidato(); + $form = $this->createForm('UBV\PracticaBundle\Form\candidatoType', $candidato); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($candidato); + $em->flush(); + + return $this->redirectToRoute('candidato_show', array('id' => $candidato->getId())); + } + + return $this->render('candidato/new.html.twig', array( + 'candidato' => $candidato, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a candidato entity. + * + * @Route("/{id}", name="candidato_show") + * @Method("GET") + */ + public function showAction(candidato $candidato) + { + $deleteForm = $this->createDeleteForm($candidato); + + return $this->render('candidato/show.html.twig', array( + 'candidato' => $candidato, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing candidato entity. + * + * @Route("/{id}/edit", name="candidato_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, candidato $candidato) + { + $deleteForm = $this->createDeleteForm($candidato); + $editForm = $this->createForm('UBV\PracticaBundle\Form\candidatoType', $candidato); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('candidato_edit', array('id' => $candidato->getId())); + } + + return $this->render('candidato/edit.html.twig', array( + 'candidato' => $candidato, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Deletes a candidato entity. + * + * @Route("/{id}", name="candidato_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, candidato $candidato) + { + $form = $this->createDeleteForm($candidato); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->remove($candidato); + $em->flush(); + } + + return $this->redirectToRoute('candidato_index'); + } + + /** + * Creates a form to delete a candidato entity. + * + * @param candidato $candidato The candidato entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(candidato $candidato) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('candidato_delete', array('id' => $candidato->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/UBV/PracticaBundle/Controller/estadoController.php b/src/UBV/PracticaBundle/Controller/estadoController.php new file mode 100644 index 0000000..9777484 --- /dev/null +++ b/src/UBV/PracticaBundle/Controller/estadoController.php @@ -0,0 +1,136 @@ +getDoctrine()->getManager(); + + $estados = $em->getRepository('UBVPracticaBundle:estado')->findAll(); + + return $this->render('estado/index.html.twig', array( + 'estados' => $estados, + )); + } + + /** + * Creates a new estado entity. + * + * @Route("/new", name="estado_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request) + { + $estado = new Estado(); + $form = $this->createForm('UBV\PracticaBundle\Form\estadoType', $estado); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($estado); + $em->flush(); + + return $this->redirectToRoute('estado_show', array('id' => $estado->getId())); + } + + return $this->render('estado/new.html.twig', array( + 'estado' => $estado, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a estado entity. + * + * @Route("/{id}", name="estado_show") + * @Method("GET") + */ + public function showAction(estado $estado) + { + $deleteForm = $this->createDeleteForm($estado); + + return $this->render('estado/show.html.twig', array( + 'estado' => $estado, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing estado entity. + * + * @Route("/{id}/edit", name="estado_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, estado $estado) + { + $deleteForm = $this->createDeleteForm($estado); + $editForm = $this->createForm('UBV\PracticaBundle\Form\estadoType', $estado); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('estado_edit', array('id' => $estado->getId())); + } + + return $this->render('estado/edit.html.twig', array( + 'estado' => $estado, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Deletes a estado entity. + * + * @Route("/{id}", name="estado_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, estado $estado) + { + $form = $this->createDeleteForm($estado); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->remove($estado); + $em->flush(); + } + + return $this->redirectToRoute('estado_index'); + } + + /** + * Creates a form to delete a estado entity. + * + * @param estado $estado The estado entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(estado $estado) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('estado_delete', array('id' => $estado->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/UBV/PracticaBundle/Controller/municipioController.php b/src/UBV/PracticaBundle/Controller/municipioController.php new file mode 100644 index 0000000..cb324d3 --- /dev/null +++ b/src/UBV/PracticaBundle/Controller/municipioController.php @@ -0,0 +1,136 @@ +getDoctrine()->getManager(); + + $municipios = $em->getRepository('UBVPracticaBundle:municipio')->findAll(); + + return $this->render('municipio/index.html.twig', array( + 'municipios' => $municipios, + )); + } + + /** + * Creates a new municipio entity. + * + * @Route("/new", name="municipio_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request) + { + $municipio = new Municipio(); + $form = $this->createForm('UBV\PracticaBundle\Form\municipioType', $municipio); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($municipio); + $em->flush(); + + return $this->redirectToRoute('municipio_show', array('id' => $municipio->getId())); + } + + return $this->render('municipio/new.html.twig', array( + 'municipio' => $municipio, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a municipio entity. + * + * @Route("/{id}", name="municipio_show") + * @Method("GET") + */ + public function showAction(municipio $municipio) + { + $deleteForm = $this->createDeleteForm($municipio); + + return $this->render('municipio/show.html.twig', array( + 'municipio' => $municipio, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing municipio entity. + * + * @Route("/{id}/edit", name="municipio_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, municipio $municipio) + { + $deleteForm = $this->createDeleteForm($municipio); + $editForm = $this->createForm('UBV\PracticaBundle\Form\municipioType', $municipio); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('municipio_edit', array('id' => $municipio->getId())); + } + + return $this->render('municipio/edit.html.twig', array( + 'municipio' => $municipio, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Deletes a municipio entity. + * + * @Route("/{id}", name="municipio_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, municipio $municipio) + { + $form = $this->createDeleteForm($municipio); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->remove($municipio); + $em->flush(); + } + + return $this->redirectToRoute('municipio_index'); + } + + /** + * Creates a form to delete a municipio entity. + * + * @param municipio $municipio The municipio entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(municipio $municipio) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('municipio_delete', array('id' => $municipio->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/UBV/PracticaBundle/Controller/personaController.php b/src/UBV/PracticaBundle/Controller/personaController.php index 25dd72f..26f5bc6 100644 --- a/src/UBV/PracticaBundle/Controller/personaController.php +++ b/src/UBV/PracticaBundle/Controller/personaController.php @@ -47,8 +47,14 @@ class personaController extends Controller $em = $this->getDoctrine()->getManager(); $em->persist($persona); $em->flush(); - - return $this->redirectToRoute('persona_show', array('id' => $persona->getId())); + $this->get('session')->getFlashBag()->set( + 'success', array( + 'title' => 'Guardado!', + 'message' => 'Persona Guardada satisfactoriamente.' + ) + ); + + return $this->redirectToRoute('persona_index', array('id' => $persona->getId())); } return $this->render('persona/new.html.twig', array( @@ -87,8 +93,14 @@ class personaController extends Controller if ($editForm->isSubmitted() && $editForm->isValid()) { $this->getDoctrine()->getManager()->flush(); - - return $this->redirectToRoute('persona_edit', array('id' => $persona->getId())); + $this->get('session')->getFlashBag()->set( + 'success', array( + 'title' => 'Editado!', + 'message' => 'Persona Editada satisfactoriamente.' + ) + ); + + return $this->redirectToRoute('persona_index', array('id' => $persona->getId())); } return $this->render('persona/edit.html.twig', array( diff --git a/src/UBV/PracticaBundle/Entity/aldea.php b/src/UBV/PracticaBundle/Entity/aldea.php index a7b3a08..6231036 100644 --- a/src/UBV/PracticaBundle/Entity/aldea.php +++ b/src/UBV/PracticaBundle/Entity/aldea.php @@ -155,5 +155,10 @@ class aldea { return $this->estatus; } + + public function __toString(){ + + return $this->getDescripcion(); + } } diff --git a/src/UBV/PracticaBundle/Entity/candidato.php b/src/UBV/PracticaBundle/Entity/candidato.php new file mode 100644 index 0000000..d6c67b1 --- /dev/null +++ b/src/UBV/PracticaBundle/Entity/candidato.php @@ -0,0 +1,469 @@ +id; + } + + /** + * Set nombre + * + * @param string $nombre + * + * @return candidato + */ + public function setNombre($nombre) + { + $this->nombre = $nombre; + + return $this; + } + + /** + * Get nombre + * + * @return string + */ + public function getNombre() + { + return $this->nombre; + } + + /** + * Set apellido + * + * @param string $apellido + * + * @return candidato + */ + public function setApellido($apellido) + { + $this->apellido = $apellido; + + return $this; + } + + /** + * Get apellido + * + * @return string + */ + public function getApellido() + { + return $this->apellido; + } + + /** + * Set cedula + * + * @param string $cedula + * + * @return candidato + */ + public function setCedula($cedula) + { + $this->cedula = $cedula; + + return $this; + } + + /** + * Get cedula + * + * @return string + */ + public function getCedula() + { + return $this->cedula; + } + + /** + * Set edad + * + * @param integer $edad + * + * @return candidato + */ + public function setEdad($edad) + { + $this->edad = $edad; + + return $this; + } + + /** + * Get edad + * + * @return int + */ + public function getEdad() + { + return $this->edad; + } + + /** + * Set sexo + * + * @param boolean $sexo + * + * @return candidato + */ + public function setSexo($sexo) + { + $this->sexo = $sexo; + + return $this; + } + + /** + * Get sexo + * + * @return bool + */ + public function getSexo() + { + return $this->sexo; + } + + /** + * Set primaria + * + * @param string $primaria + * + * @return candidato + */ + public function setPrimaria($primaria) + { + $this->primaria = $primaria; + + return $this; + } + + /** + * Get primaria + * + * @return string + */ + public function getPrimaria() + { + return $this->primaria; + } + + /** + * Set secundaria + * + * @param string $secundaria + * + * @return candidato + */ + public function setSecundaria($secundaria) + { + $this->secundaria = $secundaria; + + return $this; + } + + /** + * Get secundaria + * + * @return string + */ + public function getSecundaria() + { + return $this->secundaria; + } + + /** + * Set terciaria + * + * @param string $terciaria + * + * @return candidato + */ + public function setTerciaria($terciaria) + { + $this->terciaria = $terciaria; + + return $this; + } + + /** + * Get terciaria + * + * @return string + */ + public function getTerciaria() + { + return $this->terciaria; + } + + /** + * Set pais + * + * @param string $pais + * + * @return candidato + */ + public function setPais($pais) + { + $this->pais = $pais; + + return $this; + } + + /** + * Get pais + * + * @return string + */ + public function getPais() + { + return $this->pais; + } + + /** + * Set estado + * + * @param string $estado + * + * @return candidato + */ + public function setEstado($estado) + { + $this->estado = $estado; + + return $this; + } + + /** + * Get estado + * + * @return string + */ + public function getEstado() + { + return $this->estado; + } + + /** + * Set municipio + * + * @param string $municipio + * + * @return candidato + */ + public function setMunicipio($municipio) + { + $this->municipio = $municipio; + + return $this; + } + + /** + * Get municipio + * + * @return string + */ + public function getMunicipio() + { + return $this->municipio; + } + + /** + * Set parroquia + * + * @param string $parroquia + * + * @return candidato + */ + public function setParroquia($parroquia) + { + $this->parroquia = $parroquia; + + return $this; + } + + /** + * Get parroquia + * + * @return string + */ + public function getParroquia() + { + return $this->parroquia; + } + + /** + * Set aldea + * + * @param \UBV\PracticaBundle\Entity\Aldea $aldea + * + * @return candidato + */ + public function setAldea(\UBV\PracticaBundle\Entity\Aldea $aldea=null) + { + $this->aldea = $aldea; + + return $this; + } + + /** + * Get aldea + * + * @return string\UBV\PracticaBundle\Entity\Aldea + */ + public function getAldea() + { + return $this->aldea; + } + + /** + * Set estadoCivil + * + * @param \UBV\PracticaBundle\Entity\EstadoCivil $estadoCivil + * + * @return candidato + */ + public function setEstadoCivil(\UBV\PracticaBundle\Entity\EstadoCivil $estadoCivil=null) + { + $this->estadoCivil = $estadoCivil; + + return $this; + } + + /** + * Get estadoCivil + * + * @return string\UBV\PracticaBundle\Entity\EstadoCivil + */ + public function getestadoCivil() + { + return $this->estadoCivil; + } +} + diff --git a/src/UBV/PracticaBundle/Entity/estado.php b/src/UBV/PracticaBundle/Entity/estado.php index b31d702..373ff0a 100644 --- a/src/UBV/PracticaBundle/Entity/estado.php +++ b/src/UBV/PracticaBundle/Entity/estado.php @@ -93,5 +93,57 @@ class estado { return $this->codigo; } + + public function __toString(){ + + return $this->getDescripcion(); + } + + /** + * @ORM\OneToMany(targetEntity="estado", mappedBy="estado", cascade={"persist", "remove"}) + * @Assert\Valid() + */ + protected $municipio; + + /** + * Constructor + */ + public function __construct() + { + $this->municipio = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function setMunicipio(\Doctrine\Common\Collections\Collection $municipio) + { + $this->municipio = $municipio; + foreach ($municipio as $municipio) { + $municipio->setEstado($this); + } + } +} +class Municipio +{ + + /** + * @var string $descripcion + * + * @ORM\Column(name="descripcion", type="string", length=255) + * @Assert\NotBlank() + */ + protected $descripcion; + + /** + * @var string $codigo + * + * @ORM\Column(name="codigo", type="string", length=255) + * @Assert\NotBlank() + */ + protected $codigo; + + /** + * @ORM\ManyToOne(targetEntity="estado", inversedBy="municipio") + * @ORM\JoinColumn(name="estado_id", referencedColumnName="id") + */ + private $estado; } diff --git a/src/UBV/PracticaBundle/Entity/estadoCivil.php b/src/UBV/PracticaBundle/Entity/estadoCivil.php index cf39e73..11308dd 100644 --- a/src/UBV/PracticaBundle/Entity/estadoCivil.php +++ b/src/UBV/PracticaBundle/Entity/estadoCivil.php @@ -93,5 +93,10 @@ class estadoCivil { return $this->codigo; } + + public function __toString(){ + + return $this->getDescripcion(); + } } diff --git a/src/UBV/PracticaBundle/Entity/municipio.php b/src/UBV/PracticaBundle/Entity/municipio.php index a6d49a3..c3f09b9 100644 --- a/src/UBV/PracticaBundle/Entity/municipio.php +++ b/src/UBV/PracticaBundle/Entity/municipio.php @@ -35,6 +35,13 @@ class municipio */ private $codigo; + /** + * @ORM\ManyToOne(targetEntity="estado", inversedBy="municipios", cascade={"persist", "remove"}) + * @ORM\JoinColumn(name="estado_id", referencedColumnName="id", nullable=false) + * }) + */ + private $estado; + /** * Get id @@ -93,5 +100,35 @@ class municipio { return $this->codigo; } + + /** + * Set estado + * + * @param \UBV\PracticaBundle\Entity\Estado $estado + * + * @return municipio + */ + public function setEstado(\UBV\PracticaBundle\Entity\Estado $estado=null) + { + $this->estado = $estado; + + return $this; + } + + /** + * Get estado + * + * @return string\UBV\PracticaBundle\Entity\Estado + */ + public function getEStado() + { + return $this->estado; + } + + public function __toString(){ + + return $this->getDescripcion(); + } + } diff --git a/src/UBV/PracticaBundle/Entity/persona.php b/src/UBV/PracticaBundle/Entity/persona.php index 418ce42..cb4023e 100644 --- a/src/UBV/PracticaBundle/Entity/persona.php +++ b/src/UBV/PracticaBundle/Entity/persona.php @@ -3,6 +3,7 @@ namespace UBV\PracticaBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * persona @@ -23,24 +24,58 @@ class persona /** * @var string - * + * @Assert\NotNull(message= "Por favor introduzca su Nombre", groups={"Default"}) + * @Assert\NotBlank( message= "Por favor introduzca Nombre valido Valido", groups={"Default"}) + * @Assert\Length( + * min = 2, + * max = 45, + * minMessage = "Tu Nombre debe tener como minimo {{ limit }} letras", + * maxMessage = "Tu Nombre no debe exceder de {{ limit }} letras" + * ) + * @Assert\Regex( + * pattern="/\d/", + * match=false, + * message="Tu Nombre no debe contener numeros" + *) * @ORM\Column(name="nombre", type="string", length=255) + * */ private $nombre; + + /** * @var string - * + * @Assert\NotNull(message= "Por favor introduzca su Apellido", groups={"Default"}) + * @Assert\NotBlank( message= "Por favor introduzca Apellido valido Valido", groups={"Default"}) + * @Assert\Length( + * min = 2, + * max = 45, + * minMessage = "Tu Apellido debe tener como minimo {{ limit }} letras", + * maxMessage = "Tu Apellido no debe exceder de {{ limit }} letras" + * ) + * @Assert\Regex( + * pattern="/\d/", + * match=false, + * message="Tu Apellido no debe contener numeros" + *) * @ORM\Column(name="apellido", type="string", length=255) */ private $apellido; /** * @var string - * - * @ORM\Column(name="ceduña", type="string", length=255, unique=true) + * @Assert\NotNull(message= "Por favor introduzca su Cedula", groups={"Default"}) + * @Assert\NotBlank( message= "Por favor introduzca Cedula valido Valido", groups={"Default"}) + * @Assert\Length( + * min = 4, + * max = 10, + * minMessage = "Tu Cedula debe tener como minimo {{ limit }} numeros", + * maxMessage = "Tu Cedula no debe exceder de {{ limit }} numeros" + * ) + * @ORM\Column(name="cedula", type="string", length=255, unique=true) */ - private $ceduña; + private $cedula; /** @@ -102,27 +137,27 @@ class persona } /** - * Set ceduña + * Set cedula * - * @param string $ceduña + * @param string $cedula * * @return persona */ - public function setCeduña($ceduña) + public function setCedula($cedula) { - $this->ceduña = $ceduña; + $this->cedula = $cedula; return $this; } /** - * Get ceduña + * Get cedula * * @return string */ - public function getCeduña() + public function getCedula() { - return $this->ceduña; + return $this->cedula; } } diff --git a/src/UBV/PracticaBundle/Entity/personas.php b/src/UBV/PracticaBundle/Entity/personas.php new file mode 100644 index 0000000..ddbe670 --- /dev/null +++ b/src/UBV/PracticaBundle/Entity/personas.php @@ -0,0 +1,128 @@ +id; + } + + /** + * Set nombre + * + * @param string $nombre + * + * @return personas + */ + public function setNombre($nombre) + { + $this->nombre = $nombre; + + return $this; + } + + /** + * Get nombre + * + * @return string + */ + public function getNombre() + { + return $this->nombre; + } + + /** + * Set apellido + * + * @param string $apellido + * + * @return personas + */ + public function setApellido($apellido) + { + $this->apellido = $apellido; + + return $this; + } + + /** + * Get apellido + * + * @return string + */ + public function getApellido() + { + return $this->apellido; + } + + /** + * Set cedula + * + * @param string $cedula + * + * @return personas + */ + public function setCedula($cedula) + { + $this->cedula = $cedula; + + return $this; + } + + /** + * Get cedula + * + * @return string + */ + public function getCedula() + { + return $this->cedula; + } +} + diff --git a/src/UBV/PracticaBundle/Form/candidatoType.php b/src/UBV/PracticaBundle/Form/candidatoType.php new file mode 100644 index 0000000..1ff5029 --- /dev/null +++ b/src/UBV/PracticaBundle/Form/candidatoType.php @@ -0,0 +1,134 @@ +add('nombre', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Nombre', + 'attr' => array('class' => 'form-control','placeholder'=>'Introduzca su nombre'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('apellido', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Apellido', + 'attr' => array('class' => 'form-control','placeholder'=>'Introduzca su apellido'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('cedula', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Cedula', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:18031258'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('edad', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Edad', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:18'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('sexo', 'choice', array( + 'choices' => array( + '0' => 'Masculino', + '1' => 'Femenino' + ), + 'empty_value' => 'Ingrese su genero', + 'empty_data' => null + )) + ->add('estadoCivil', EntityType::class, array( + 'disabled'=>false, + 'class' => 'UBVPracticaBundle:EstadoCivil', + 'label' =>"Estado Civil", + 'empty_data' => "0", + 'placeholder'=>"Seleccione...", + 'attr' => array('class' => 'form-control form-control-choice','placeholder'=>''), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('pais', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Pais', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:Venezuela'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('primaria', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Escuela', + 'attr' => array('class' => 'form-control','placeholder'=>'Nombre de la escuela'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('secundaria', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Liceo', + 'attr' => array('class' => 'form-control','placeholder'=>'Nombre del liceo'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('terciaria', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Universidad', + 'attr' => array('class' => 'form-control','placeholder'=>'Nombre de la universidad'), + 'label_attr' => array('class' => 'control-label'), + )) + + ->add('aldea', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Aldea', + 'attr' => array('class' => 'form-control','placeholder'=>'Nombre de la aldea'), + 'label_attr' => array('class' => 'control-label'), + )) + + ->add('estado', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Estado', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:Distrito Capital'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('municipio', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Municipio', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:Libertador'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('parroquia', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Parroquia', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:San José'), + 'label_attr' => array('class' => 'control-label'), + )); + }/** + * {@inheritdoc} + */ + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'UBV\PracticaBundle\Entity\candidato' + )); + } + + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'ubv_practicabundle_candidato'; + } + + +} diff --git a/src/UBV/PracticaBundle/Form/estadoType.php b/src/UBV/PracticaBundle/Form/estadoType.php new file mode 100644 index 0000000..6ab6c63 --- /dev/null +++ b/src/UBV/PracticaBundle/Form/estadoType.php @@ -0,0 +1,37 @@ +add('descripcion')->add('codigo'); + + }/** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'UBV\PracticaBundle\Entity\estado' + )); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'ubv_practicabundle_estado'; + } + + +} diff --git a/src/UBV/PracticaBundle/Form/estadomunicipioType.php b/src/UBV/PracticaBundle/Form/estadomunicipioType.php new file mode 100644 index 0000000..8bd1ef1 --- /dev/null +++ b/src/UBV/PracticaBundle/Form/estadomunicipioType.php @@ -0,0 +1,47 @@ +add('estado') + ->add('municipio', 'collection', array( + 'type' => new MunicipioType(), + 'label' => 'Descripcion', + 'by_reference' => false, + 'prototype_data' => new Municipio(), + 'allow_delete' => true, + 'allow_add' => true, + 'attr' => array( + 'class' => 'row municipio' + ) + )) + ; + } + /** + * {@inheritdoc} + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'UBV\PracticaBundle\Entity\estado', + )); + } + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'ubv_practicabundle_municipio'; + } +} \ No newline at end of file diff --git a/src/UBV/PracticaBundle/Form/municipioType.php b/src/UBV/PracticaBundle/Form/municipioType.php new file mode 100644 index 0000000..e5a4b91 --- /dev/null +++ b/src/UBV/PracticaBundle/Form/municipioType.php @@ -0,0 +1,38 @@ +add('descripcion') + ->add('codigo') + ->add('estado'); + }/** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'UBV\PracticaBundle\Entity\municipio' + )); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'ubv_practicabundle_municipio'; + } +} \ No newline at end of file diff --git a/src/UBV/PracticaBundle/Form/personaType.php b/src/UBV/PracticaBundle/Form/personaType.php index 64f7737..03af5b9 100644 --- a/src/UBV/PracticaBundle/Form/personaType.php +++ b/src/UBV/PracticaBundle/Form/personaType.php @@ -5,6 +5,8 @@ namespace UBV\PracticaBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints\Length; class personaType extends AbstractType { @@ -13,7 +15,25 @@ class personaType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('nombre')->add('apellido')->add('ceduña'); + $builder + ->add('nombre', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Nombre', + 'attr' => array('class' => 'form-control','placeholder'=>'Introduzca su nombre'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('apellido', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Apellido', + 'attr' => array('class' => 'form-control','placeholder'=>'Introduzca su apellido'), + 'label_attr' => array('class' => 'control-label'), + )) + ->add('cedula', null, array( + 'constraints' => new NotBlank(array('groups' => array('Default'))), + 'label'=>'Cedula', + 'attr' => array('class' => 'form-control','placeholder'=>'Ejemplo:18031258'), + 'label_attr' => array('class' => 'control-label'), + )); }/** * {@inheritdoc} */ diff --git a/src/UBV/PracticaBundle/Repository/candidatoRepository.php b/src/UBV/PracticaBundle/Repository/candidatoRepository.php new file mode 100644 index 0000000..9a1c68e --- /dev/null +++ b/src/UBV/PracticaBundle/Repository/candidatoRepository.php @@ -0,0 +1,13 @@ +request('GET', '/candidato/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /candidato/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'ubv_practicabundle_candidato[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'ubv_practicabundle_candidato[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} diff --git a/src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php b/src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php new file mode 100644 index 0000000..2167a62 --- /dev/null +++ b/src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/estado/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /estado/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'ubv_practicabundle_estado[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'ubv_practicabundle_estado[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} diff --git a/src/UBV/PracticaBundle/Tests/Controller/municipioControllerTest.php b/src/UBV/PracticaBundle/Tests/Controller/municipioControllerTest.php new file mode 100644 index 0000000..33aee19 --- /dev/null +++ b/src/UBV/PracticaBundle/Tests/Controller/municipioControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/municipio/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /municipio/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'ubv_practicabundle_municipio[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'ubv_practicabundle_municipio[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +}