aimeos /
aimeos-symfony
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Aimeos\ShopBundle\Tests\Controller; |
||||||
| 4 | |||||||
| 5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
||||||
| 6 | |||||||
| 7 | |||||||
| 8 | class CheckoutControllerTest extends WebTestCase |
||||||
| 9 | { |
||||||
| 10 | protected function setUp() : void |
||||||
| 11 | { |
||||||
| 12 | \Aimeos\MShop::cache( false ); |
||||||
| 13 | \Aimeos\Controller\Frontend::cache( false ); |
||||||
| 14 | } |
||||||
| 15 | |||||||
| 16 | |||||||
| 17 | public function testStandardNavbar() |
||||||
| 18 | { |
||||||
| 19 | $client = static::createClient( array(), array( |
||||||
| 20 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 21 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 22 | ) ); |
||||||
| 23 | |||||||
| 24 | $crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
||||||
| 25 | |||||||
| 26 | $link = $crawler->filter( '.catalog-list-items .product a:contains("Unittest: Bundle")' )->link(); |
||||||
| 27 | $crawler = $client->click( $link ); |
||||||
| 28 | |||||||
| 29 | $form = $crawler->filter( '.catalog-detail .addbasket .btn-primary' )->form(); |
||||||
| 30 | $crawler = $client->submit( $form ); |
||||||
| 31 | |||||||
| 32 | $link = $crawler->filter( '.basket-standard .btn-action' )->link(); |
||||||
| 33 | $crawler = $client->click( $link ); |
||||||
| 34 | |||||||
| 35 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Adresse")' )->count() ); |
||||||
| 36 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
||||||
| 37 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
||||||
| 38 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
||||||
| 39 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
||||||
| 40 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
||||||
| 41 | |||||||
| 42 | |||||||
| 43 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 44 | $form['ca_billingoption']->select( $crawler->filter( '.checkout-standard-address .item-address input' )->attr( 'value' ) ); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 45 | $crawler = $client->submit( $form ); |
||||||
| 46 | |||||||
| 47 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
||||||
| 48 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
||||||
| 49 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Versand")' )->count() ); |
||||||
| 50 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
||||||
| 51 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
||||||
| 52 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
||||||
| 53 | |||||||
| 54 | |||||||
| 55 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 56 | $form['c_deliveryoption']->select( $crawler->filter( '.checkout-standard-delivery .item-service input' )->attr( 'value' ) ); |
||||||
| 57 | $crawler = $client->submit( $form ); |
||||||
| 58 | |||||||
| 59 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
||||||
| 60 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
||||||
| 61 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
||||||
| 62 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Zahlung")' )->count() ); |
||||||
| 63 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
||||||
| 64 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
||||||
| 65 | |||||||
| 66 | |||||||
| 67 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 68 | $form['c_paymentoption']->select( $crawler->filter( '.checkout-standard-payment .item-service input' )->attr( 'value' ) ); |
||||||
| 69 | $crawler = $client->submit( $form ); |
||||||
| 70 | |||||||
| 71 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .basket a' )->count() ); |
||||||
| 72 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .address a' )->count() ); |
||||||
| 73 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .delivery a' )->count() ); |
||||||
| 74 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .payment a' )->count() ); |
||||||
| 75 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard .steps .current:contains("Übersicht")' )->count() ); |
||||||
| 76 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps .summary a' )->count() ); |
||||||
| 77 | |||||||
| 78 | |||||||
| 79 | $link = $crawler->filter( '.checkout-standard .steps .basket a' )->link(); |
||||||
| 80 | $crawler = $client->click( $link ); |
||||||
| 81 | $this->assertEquals( 0, $crawler->filter( '.checkout-standard .steps' )->count() ); |
||||||
| 82 | } |
||||||
| 83 | |||||||
| 84 | |||||||
| 85 | public function testStandardNextBack() |
||||||
| 86 | { |
||||||
| 87 | $client = static::createClient( array(), array( |
||||||
| 88 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 89 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 90 | ) ); |
||||||
| 91 | |||||||
| 92 | $crawler = $this->_goToSummary( $client ); |
||||||
| 93 | |||||||
| 94 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 95 | |||||||
| 96 | |||||||
| 97 | $link = $crawler->filter( '.checkout-standard .btn-back' )->link(); |
||||||
| 98 | $crawler = $client->click( $link ); |
||||||
| 99 | |||||||
| 100 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-payment' )->count() ); |
||||||
| 101 | |||||||
| 102 | |||||||
| 103 | $link = $crawler->filter( '.checkout-standard .btn-back' )->link(); |
||||||
| 104 | $crawler = $client->click( $link ); |
||||||
| 105 | |||||||
| 106 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-delivery' )->count() ); |
||||||
| 107 | |||||||
| 108 | |||||||
| 109 | $link = $crawler->filter( '.checkout-standard .btn-back' )->link(); |
||||||
| 110 | $crawler = $client->click( $link ); |
||||||
| 111 | |||||||
| 112 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-address' )->count() ); |
||||||
| 113 | |||||||
| 114 | |||||||
| 115 | $form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
||||||
| 116 | $crawler = $client->submit( $form ); |
||||||
| 117 | |||||||
| 118 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-delivery' )->count() ); |
||||||
| 119 | |||||||
| 120 | |||||||
| 121 | $form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
||||||
| 122 | $crawler = $client->submit( $form ); |
||||||
| 123 | |||||||
| 124 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-payment' )->count() ); |
||||||
| 125 | |||||||
| 126 | |||||||
| 127 | $form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
||||||
| 128 | $crawler = $client->submit( $form ); |
||||||
| 129 | |||||||
| 130 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 131 | } |
||||||
| 132 | |||||||
| 133 | |||||||
| 134 | public function testStandardAddressPayment() |
||||||
| 135 | { |
||||||
| 136 | $client = static::createClient( array(), array( |
||||||
| 137 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 138 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 139 | ) ); |
||||||
| 140 | |||||||
| 141 | $crawler = $this->_goToSummary( $client ); |
||||||
| 142 | |||||||
| 143 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 144 | |||||||
| 145 | |||||||
| 146 | $link = $crawler->filter( '.checkout-standard .common-summary-address .payment .modify' )->link(); |
||||||
| 147 | $crawler = $client->click( $link ); |
||||||
| 148 | |||||||
| 149 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-address' )->count() ); |
||||||
| 150 | } |
||||||
| 151 | |||||||
| 152 | |||||||
| 153 | public function testStandardAddressDelivery() |
||||||
| 154 | { |
||||||
| 155 | $client = static::createClient( array(), array( |
||||||
| 156 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 157 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 158 | ) ); |
||||||
| 159 | |||||||
| 160 | $crawler = $this->_goToSummary( $client ); |
||||||
| 161 | |||||||
| 162 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 163 | |||||||
| 164 | |||||||
| 165 | $link = $crawler->filter( '.checkout-standard .common-summary-address .delivery .modify' )->link(); |
||||||
| 166 | $crawler = $client->click( $link ); |
||||||
| 167 | |||||||
| 168 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-address' )->count() ); |
||||||
| 169 | } |
||||||
| 170 | |||||||
| 171 | |||||||
| 172 | public function testStandardDelivery() |
||||||
| 173 | { |
||||||
| 174 | $client = static::createClient( array(), array( |
||||||
| 175 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 176 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 177 | ) ); |
||||||
| 178 | |||||||
| 179 | $crawler = $this->_goToSummary( $client ); |
||||||
| 180 | |||||||
| 181 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 182 | |||||||
| 183 | |||||||
| 184 | $link = $crawler->filter( '.checkout-standard .common-summary-service .delivery .modify' )->link(); |
||||||
| 185 | $crawler = $client->click( $link ); |
||||||
| 186 | |||||||
| 187 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-delivery' )->count() ); |
||||||
| 188 | } |
||||||
| 189 | |||||||
| 190 | |||||||
| 191 | public function testStandardPayment() |
||||||
| 192 | { |
||||||
| 193 | $client = static::createClient( array(), array( |
||||||
| 194 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 195 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 196 | ) ); |
||||||
| 197 | |||||||
| 198 | $crawler = $this->_goToSummary( $client ); |
||||||
| 199 | |||||||
| 200 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 201 | |||||||
| 202 | |||||||
| 203 | $link = $crawler->filter( '.checkout-standard .common-summary-service .payment .modify' )->link(); |
||||||
| 204 | $crawler = $client->click( $link ); |
||||||
| 205 | |||||||
| 206 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-payment' )->count() ); |
||||||
| 207 | } |
||||||
| 208 | |||||||
| 209 | |||||||
| 210 | public function testStandardBasket() |
||||||
| 211 | { |
||||||
| 212 | $client = static::createClient( array(), array( |
||||||
| 213 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 214 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 215 | ) ); |
||||||
| 216 | |||||||
| 217 | $crawler = $this->_goToSummary( $client ); |
||||||
| 218 | |||||||
| 219 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 220 | |||||||
| 221 | |||||||
| 222 | $link = $crawler->filter( '.checkout-standard .common-summary-detail .modify' )->link(); |
||||||
| 223 | $crawler = $client->click( $link ); |
||||||
| 224 | |||||||
| 225 | $this->assertEquals( 1, $crawler->filter( '.basket-standard' )->count() ); |
||||||
| 226 | } |
||||||
| 227 | |||||||
| 228 | |||||||
| 229 | public function testStandardOrder() |
||||||
| 230 | { |
||||||
| 231 | $client = static::createClient( array(), array( |
||||||
| 232 | 'PHP_AUTH_USER' => '[email protected]', |
||||||
| 233 | 'PHP_AUTH_PW' => 'unittest', |
||||||
| 234 | ) ); |
||||||
| 235 | |||||||
| 236 | $crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
||||||
| 237 | |||||||
| 238 | $link = $crawler->filter( '.catalog-list-items .product a:contains("Unittest: Bundle")' )->link(); |
||||||
| 239 | $crawler = $client->click( $link ); |
||||||
| 240 | |||||||
| 241 | $form = $crawler->filter( '.catalog-detail .addbasket .btn-primary' )->form(); |
||||||
| 242 | $crawler = $client->submit( $form ); |
||||||
| 243 | |||||||
| 244 | $link = $crawler->filter( '.basket-standard .btn-action' )->link(); |
||||||
| 245 | $crawler = $client->click( $link ); |
||||||
| 246 | |||||||
| 247 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 248 | $form['ca_billingoption']->select( $crawler->filter( '.checkout-standard-address .item-address input' )->attr( 'value' ) ); |
||||||
| 249 | $crawler = $client->submit( $form ); |
||||||
| 250 | |||||||
| 251 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 252 | $form['c_deliveryoption']->select( $crawler->filter( '.checkout-standard-delivery .item-service input' )->attr( 'value' ) ); |
||||||
| 253 | $crawler = $client->submit( $form ); |
||||||
| 254 | |||||||
| 255 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 256 | $payId = $crawler->filter( '.checkout-standard-payment .item-service' )->eq( 1 )->filter( 'input' )->attr( 'value' ); |
||||||
| 257 | $form['c_paymentoption']->select( $payId ); |
||||||
| 258 | $form['c_payment[' . $payId . '][directdebit.accountowner]'] = 'test user'; |
||||||
| 259 | $form['c_payment[' . $payId . '][directdebit.accountno]'] = '12345'; |
||||||
| 260 | $form['c_payment[' . $payId . '][directdebit.bankcode]'] = '67890'; |
||||||
| 261 | $form['c_payment[' . $payId . '][directdebit.bankname]'] = 'test bank'; |
||||||
| 262 | $crawler = $client->submit( $form ); |
||||||
| 263 | |||||||
| 264 | $this->assertEquals( 1, $crawler->filter( '.checkout-standard-summary' )->count() ); |
||||||
| 265 | |||||||
| 266 | |||||||
| 267 | // Test if T&C are not accepted |
||||||
| 268 | $form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
||||||
| 269 | $crawler = $client->submit( $form ); |
||||||
| 270 | |||||||
| 271 | $form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
||||||
| 272 | $form['cs_option_terms_value']->tick(); |
||||||
|
0 ignored issues
–
show
The method
tick() does not exist on Symfony\Component\DomCrawler\Field\FormField. It seems like you code against a sub-type of Symfony\Component\DomCrawler\Field\FormField such as Symfony\Component\DomCrawler\Field\ChoiceFormField.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 273 | $crawler = $client->submit( $form ); |
||||||
| 274 | |||||||
| 275 | $form = $crawler->filter( '.checkout-standard .btn-action' )->form(); |
||||||
| 276 | $crawler = $client->submit( $form ); |
||||||
| 277 | |||||||
| 278 | $this->assertEquals( 1, $crawler->filter( '.checkout-confirm' )->count() ); |
||||||
| 279 | } |
||||||
| 280 | |||||||
| 281 | |||||||
| 282 | public function testUpdate() |
||||||
| 283 | { |
||||||
| 284 | $client = static::createClient(); |
||||||
| 285 | |||||||
| 286 | $client->request( 'GET', '/unittest/de/EUR/update' ); |
||||||
| 287 | |||||||
| 288 | $this->assertEquals( 200, $client->getResponse()->getStatusCode() ); |
||||||
| 289 | } |
||||||
| 290 | |||||||
| 291 | |||||||
| 292 | /** |
||||||
| 293 | * Moves forward to the summary page |
||||||
| 294 | * |
||||||
| 295 | * @param \Symfony\Bundle\FrameworkBundle\Client $client HTTP test client |
||||||
|
0 ignored issues
–
show
The type
Symfony\Bundle\FrameworkBundle\Client was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 296 | * @return \Symfony\Component\DomCrawler\Crawler Crawler HTTP crawler |
||||||
| 297 | */ |
||||||
| 298 | protected function _goToSummary( $client ) |
||||||
| 299 | { |
||||||
| 300 | $crawler = $client->request( 'GET', '/unittest/de/EUR/shop/' ); |
||||||
| 301 | |||||||
| 302 | $link = $crawler->filter( '.catalog-list-items .product a:contains("Unittest: Bundle")' )->link(); |
||||||
| 303 | $crawler = $client->click( $link ); |
||||||
| 304 | |||||||
| 305 | $form = $crawler->filter( '.catalog-detail .addbasket .btn-primary' )->form(); |
||||||
| 306 | $crawler = $client->submit( $form ); |
||||||
| 307 | |||||||
| 308 | $link = $crawler->filter( '.basket-standard .btn-action' )->link(); |
||||||
| 309 | $crawler = $client->click( $link ); |
||||||
| 310 | |||||||
| 311 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 312 | $form['ca_billingoption']->select( $crawler->filter( '.checkout-standard-address .item-address input' )->attr( 'value' ) ); |
||||||
| 313 | $crawler = $client->submit( $form ); |
||||||
| 314 | |||||||
| 315 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 316 | $form['c_deliveryoption']->select( $crawler->filter( '.checkout-standard-delivery .item-service input' )->attr( 'value' ) ); |
||||||
| 317 | $crawler = $client->submit( $form ); |
||||||
| 318 | |||||||
| 319 | $form = $crawler->filter( '.checkout-standard form' )->form(); |
||||||
| 320 | $form['c_paymentoption']->select( $crawler->filter( '.checkout-standard-payment .item-service input' )->attr( 'value' ) ); |
||||||
| 321 | $crawler = $client->submit( $form ); |
||||||
| 322 | |||||||
| 323 | return $crawler; |
||||||
| 324 | } |
||||||
| 325 | } |
||||||
| 326 |