php - Symfony test serialize

684

This is my test file

$crawler = $this->client->request('GET', $this->getUrlOfRoute($this->routeStep1));
    $buttonCrawlerNode = $crawler->selectButton('next_step');

    $form = $buttonCrawlerNode->form(array(
        'form[name]' => '__davidc',
            ), 'POST');

    $crawler = $this->client->submit($form);

    $container = $this->client->getContainer();


    $session = $container->get('session')->get('maSession');

This is my controller :

if (!$form->getData()['name']) {

        return $this->redirect($this->generateUrl('error_page'));
    }
    $data = $form->getData();
    $name = $data['name'];
    $unObject = new ObjectPerso();
    $unObject->setName($name);

    $test= serialize($unObject);

    $this->get('session')->set('maSession',  serialize($unObject));
    var_dump($this->get('session')->get('maSession'));
    return $this->redirect($this->generateUrl('step2'));

My problem is that when I execute the test, it does not pass the serialize. This will return no error or exception but valid test.

Now I want to check the form and the session and I can not because it does not serialize and therefore nothing is not my session variable.

People are also looking for solutions to the problem: php - hide price and add_cart for anonymous user in drupal

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.