M
M
magary42017-02-01 16:08:22
symfony
magary4, 2017-02-01 16:08:22

Testing cart functionality?

I see that in order to test this functionality, I need 3 levels of the
1st to test the objects themselves

$product = new Product(123);
$basket->add($product)

assert (  instanceof $basket->get(123) == \namespace\Product );
$basket->remove( 123 );
assert( false === $basket->getAll() )

2nd test forms and route returning cart content
$crawler = $client->request(‘POST’, “/basket/add” );

$form = $crawler->filter('#formID')->form();
$form->setValues(array(
    "form[productId]” => 123,
    "form[quontity]”  => 4
));
$response = $client->getResponse();
// assert status code

$crawler = $client->request('GET', “/basket/getAll” );
$response = $client->getResponse();
// foreach basketItems и найти положеный ProductId

$crawler = $client->request('GET', “/basket/delete/123” );
$response = $client->getResponse();
// check status code и повторить /basket/getAll проверить что продукт удалился

3rd test javascript in all browsers
through selenium open the product page and click on the "add to cart" button, wait for the ajax response. call route /basket/getAll with ajax, check that the product is in JSON, click on the "remove from basket" button, and check again,
am I on the right track?
just starting with testing
thanks in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question