示例#1
0
 /**
  * Checking current parameters in Delivery List page 
  * if you want to skip verifying of some parameters type null
  * @param sring             $name       Delivery name
  * @param string            $active     Active checkbox on - enabled |off - disabled 
  * @param int|string|float  $price      Delivery price
  * @param int|string|float  $freefrom   Delivery free from
  * @return void
  */
 function CheckInList($name, $active = null, $price = null, $freefrom = null)
 {
     $I = $this;
     $I->wait(3);
     $I->amOnPage(\DeliveryPage::$URL);
     $I->waitForText('Список способов доставки');
     $rows = $I->grabTagCount($I, "tbody tr");
     $I->comment($rows);
     $present = FALSE;
     if ($rows > 0) {
         for ($j = 1; $j <= $rows; ++$j) {
             $method = $I->grabTextFrom(\DeliveryPage::ListMethodLine($j));
             $I->comment($method);
             if ($method == $name) {
                 $present = TRUE;
                 break;
             }
         }
     }
     $I->comment("results: \n Method: \n{$method} Present: {$present} in row: {$j}\n");
     //Error when method isn't present in delivery list page
     $present ? $I->assertEquals($method, $name) : $I->fail("Method wasn't created");
     if ($active) {
         $attribute = $I->grabAttributeFrom(\DeliveryPage::ListActiveButtonLine($j), "class");
         switch ($active) {
             case 'on':
                 $I->assertEquals("prod-on_off ", $attribute);
                 break;
             case 'off':
                 $I->assertEquals("prod-on_off disable_tovar", $attribute);
                 break;
         }
     }
     if ($price) {
         $Cprice = $I->grabTextFrom(\DeliveryPage::ListPriceLine($j));
         $price = number_format($price, 5, ".", "");
         $I->assertEquals(preg_replace('/[^0-9.]*/u', '', $Cprice), $price);
     }
     if ($freefrom) {
         $Cfreefrom = $I->grabTextFrom(\DeliveryPage::ListFreeFromLine($j));
         $freefrom = number_format($freefrom, 5, ".", "");
         $I->assertEquals(preg_replace('/[^0-9.]*/u', '', $Cfreefrom), $freefrom);
     }
 }