/** * Get filename * * @return string */ protected function getFilename() { if (empty($this->generator->getOptions()->categories_filename)) { $config = \XLite\Module\XC\PitneyBowes\Model\Shipping\Processor\PitneyBowes::getProcessorConfiguration(); $parts = array('Sender_ID' => $config->sender_id, 'Data_Feed_Name' => 'category-tree', 'Operation' => 'update', 'Recipient_ID' => '16061', 'UTC_Date_Time' => \XLite\Core\Converter::formatTime(null, '%Y%m%d_%H%M%S'), 'Random_6_Digits' => str_pad(rand(0, pow(10, 6)), 6, '0', STR_PAD_LEFT)); $this->generator->getOptions()->categories_filename = implode('_', $parts) . '.csv'; } return $this->generator->getOptions()->categories_filename; }
/** * Format timestamp * * @param mixed $base String or object instance to get field value from * @param string $field Field to get value OPTIONAL * @param string $format Date format OPTIONAL * * @return string */ protected function formatTime($base, $field = null, $format = null) { if (is_object($base)) { $base = $base instanceof \XLite\Model\AEntity ? $base->{$field} : $base->get($field); } return \XLite\Core\Converter::formatTime($base, $format); }
/** * Get value of the "name" column * * @param \XLite\Module\XC\PitneyBowes\Model\PBExport $item Export item model * * @return string */ protected function getDateColumnValue(\XLite\Module\XC\PitneyBowes\Model\PBExport $item) { return \XLite\Core\Converter::formatTime($item->getExportDate()); }
public function testStructure() { $order = $this->buy(); $locale = setlocale(LC_ALL, 'C'); $date = \XLite\Core\Converter::formatTime($order->getDate()); // Title $this->assertEquals('Order #' . $order->getOrderId() . ', ' . $date, $this->getJSExpression('jQuery("#page-title").html()'), 'check page title'); // Links $this->assertElementPresent("//div[@class='order-box']" . "/div[@class='order-statuses']" . "/div[@class='shipping order-status-" . $order->getStatus() . "']"); $this->assertElementPresent("//div[@class='order-box']" . "/ul[@class='links']" . "/li[@class='back']" . "/a" . "/span[text()='Back to order list']"); $this->assertElementPresent("//div[@class='order-box']" . "/ul[@class='links']" . "/li[@class='print']" . "/a" . "/span[text()='Print invoice']"); $this->assertEquals(1, intval($this->getJSExpression('jQuery(".invoice-box").length')), 'check invoice box count'); // Invoice header $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='header']" . "/tbody" . "/tr" . "/td[@class='address']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='header']" . "/tbody" . "/tr" . "/td[@class='logo']" . "/img[@class='logo']"); // Invoice title $this->assertElementPresent("//div[@class='invoice-box']" . "/h2[@class='invoice' and text()='Invoice #" . $order->getOrderId() . "']"); // Subhead $this->assertElementPresent("//div[@class='invoice-box']" . "/div[@class='subhead']" . "/span[text()='Grand total: \$" . number_format(round($order->getTotal(), 2), 2) . "']"); // Items $countTR = intval($this->getJSExpression('jQuery(".invoice-box .items tr").length')); $this->assertEquals(count($order->getItems()) * 3 + 2, $countTR, 'TR count checking'); $countTH = intval($this->getJSExpression('jQuery(".invoice-box .items th").length')); $this->assertEquals(5, $countTH, 'TH count checking'); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr" . "/th[position()=1 and text()='Item description']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr" . "/th[position()=2 and text()='Total']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=2]" . "/th[position()=1 and text()='SKU']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=2]" . "/th[position()=2 and text()='Qty']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=2]" . "/th[position()=3 and text()='Price']"); // First product $item = $order->getItems()->get(0); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=4]" . "/td[position()=1]" . "/a[text()='" . $item->getName() . "']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=5]" . "/td[position()=1 and text()='SKU " . $item->getSku() . "']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=5]" . "/td[position()=3 and text()='\$" . number_format(round($item->getPrice(), 2), 2) . "']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=5]" . "/td[position()=2 and text()='" . $item->getAmount() . "']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='items']" . "/tbody" . "/tr[position()=4]" . "/td[position()=2 and text()='\$" . number_format(round($item->getTotal(), 2), 2) . "']"); // Totals $countTR = intval($this->getJSExpression('jQuery(".invoice-box .totals tr").length')); $this->assertEquals(count($order->getSurcharges()) + 2, $countTR, 'Totals TR count checking'); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='totals']" . "/tbody" . "/tr[position()=1]" . "/td[position()=1 and text()='Subtotal:']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='totals']" . "/tbody" . "/tr[position()=1]" . "/td[position()=2 and text()='\$" . number_format(round($order->getSubtotal(), 2), 2) . "']"); $i = 2; foreach ($order->getSurchargeTotals() as $type => $m) { $name = 1 == $m['count'] ? $m['lastName'] : $m['name']; $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='totals']" . "/tbody" . "/tr[position()={$i} and contains(@class,'" . $type . "-modifier')]"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='totals']" . "/tbody" . "/tr[position()={$i} and contains(@class,'" . $type . "-modifier')]" . "/td[position()=1 and contains(text(),'" . $name . ":')]"); $this->assertEquals('$' . number_format($m['cost'], 2), trim($this->getJSExpression('jQuery(".invoice-box .totals tr:eq(1) td:eq(1)").html()')), 'check total modifier #' . $i); $i++; } $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='totals']" . "/tbody" . "/tr[position()={$countTR}]" . "/td[position()=1 and text()='Grand total:']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='totals']" . "/tbody" . "/tr[position()={$countTR}]" . "/td[position()=2 and text()='\$" . number_format(round($order->getTotal(), 2), 2) . "']"); // Addresses $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='addresses']" . "/tbody" . "/tr[position()=1]" . "/td[position()=1 and @class='ship']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='addresses']" . "/tbody" . "/tr[position()=1]" . "/td[position()=2 and @class='bill']"); // Methods $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='addresses']" . "/tbody" . "/tr[position()=2]" . "/td[position()=1 and @class='shipping']"); $this->assertElementPresent("//div[@class='invoice-box']" . "/table[@class='addresses']" . "/tbody" . "/tr[position()=2]" . "/td[position()=2 and @class='payment']"); $txt = $this->getJSExpression('jQuery(".invoice-box .addresses .payment").html()'); $txt = str_replace("\n", "", trim($txt)); $this->assertRegExp('/' . $order->getPaymentmethod()->getName() . '/S', $txt, 'check payment method'); }
/** * Show TopMessage if shop was recently restored to restore point * * @return void */ protected function checkRestorationFlag() { $restored = \Includes\Decorator\Utils\PersistentInfo::get('restoredTo'); \Includes\Decorator\Utils\PersistentInfo::discard('restoredTo'); if (!empty($restored)) { \XLite\Core\TopMessage::addInfo('The system has been restored to the selected snapshot of X', array('date' => \XLite\Core\Converter::formatTime($restored))); } }