<commit_before><?php

namespace OrderTracking\FrontendBundle\Tests\Controller;

use OrderTracking\BackendBundle\Entity\Pedidos;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class PedidosControllerTest extends WebTestCase
{
    private $em;
    public function setUp()
    {
        self::bootKernel();
        $this->em = static::$kernel->getContainer()
            ->get('doctrine')
            ->getManager()
        ;
    }

    public function testCompleteScenario()
    {
        // Create a new client to browse the application
        $client = static::createClient();
        $client->followRedirects(true);

        // Check if frontend is ok
        $crawler = $client->request('GET', '/');
        $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /pedido/");
        $this->assertGreaterThan(
            0,
            $crawler->filter('html:contains("Seguimiento de pedidos")')->count()
        );

        // Submit a fake code track
        $crawler = $client->request('GET', '/pedido/G24OQ4YQ443O');
        $this->assertGreaterThan(
            0,
            $crawler->filter('html:contains("No hemos encontrado ningún pedido con ese número de seguimiento :-(")')->count()
        );

        // Add an order and verify it
        $client2 = static::createClient();
        $client2->followRedirects(true);

        $clientNames = array(
            "<NAME>.",
            "<NAME>",
            "<NAME>"
        );
        $clientEmails = array(
            "<EMAIL>",
            "<EMAIL>",
            "<EMAIL>"
        );

        $order = new Pedidos();
        $order->setEmailCliente($clientEmails[array_rand($clientEmails)]);
        $order->setNombreCliente($clientNames[array_rand($clientNames)]);
        $order->setNombreProducto('5000 Twitter Followers');
        $order->setPrecioProducto('39.95');
        $order->setCodigoSeguimiento('W233Q42HC4IO');
        $order->setEstadoPedido('pendiente');

        $this->em->persist($order);
        $this->em->flush($order);

        $client2->request('GET', '/pedido/W233Q42HC4IO');
        $this->assertEquals(200, $client2->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /pedido/x");
        $this->assertNotEmpty($client2->getResponse()->getContent());

        $this->em->remove($order);
        $this->em->flush();

    }
}<commit_msg>Añadir más assertions<commit_after><?php

namespace OrderTracking\FrontendBundle\Tests\Controller;

use OrderTracking\BackendBundle\Entity\Pedidos;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class PedidosControllerTest extends WebTestCase
{
    private $em;
    private $container;

    public function setUp()
    {
        self::bootKernel();
        $this->container = static::$kernel->getContainer();
        $this->em = $this->container->get('doctrine')
            ->getManager()
        ;
    }

    public function testCompleteScenario()
    {
        // Crear nuevo cliente web
        $client = static::createClient();
        $client->followRedirects(true);

        // Comprobar página de inicio
        $crawler = $client->request('GET', '/');
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        $this->assertGreaterThan(
            0,
            $crawler->filter('html:contains("Seguimiento de pedidos")')->count()
        );

        // Comprobar el estado de un pedido no existente
        $crawler = $client->request('GET', '/pedido/'.$this->container->get('trackcodegenerator')->generate());
        $this->assertGreaterThan(
            0,
            $crawler->filter('html:contains("No hemos encontrado ningún pedido con ese número de seguimiento")')->count()
        );

        // Crear nuevo pedido
        $order = new Pedidos();
        $order->setEmailCliente($this->container->get('demodatagenerator')->emailCliente());
        $order->setNombreCliente($this->container->get('demodatagenerator')->nombreCliente());
        $order->setNombreProducto($this->container->get('demodatagenerator')->nombreProducto());
        $order->setPrecioProducto($this->container->get('demodatagenerator')->precioProducto());
        $order->setCodigoSeguimiento($this->container->get('trackcodegenerator')->generate());
        $order->setEstadoPedido($this->container->get('demodatagenerator')->estadoPedido());
        $this->em->persist($order);
        $this->em->flush($order);

        // Comprobar pedido creado
        $crawler = $client->request('GET', '/pedido/'.$order->getCodigoSeguimiento());
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        $this->assertNotEmpty($client->getResponse()->getContent());
        $this->assertGreaterThan(0, $crawler->filter('html:contains("'.$order->getCodigoSeguimiento().'")')->count());
        $this->assertGreaterThan(0, $crawler->filter('html:contains("'.$order->getNombreCliente().'")')->count());
        $this->assertGreaterThan(0, $crawler->filter('html:contains("'.$order->getEmailCliente().'")')->count());
        $this->assertGreaterThan(0, $crawler->filter('html:contains("'.$order->getNombreProducto().'")')->count());
        $this->assertGreaterThan(0, $crawler->filter('html:contains("'.$order->getPrecioProducto().'")')->count());

        // Eliminar pedido
        $this->em->remove($order);
        $this->em->flush();
    }
}
{'fraction_non_alphanumeric': 0.1741552172298552, 'fraction_numerical': 0.009654660230226514, 'mean_word_length': 3.0052044609665427, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 128, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4673506', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1573, 'n_words': 232}