order = new \Order(); $this->order->createFromDB(1); } public function testReplacePlaceholdersMergesCustomPlaceholders() { $this->order->setPlaceholder('DUMMY', 'Hello World!'); $result = $this->order->replacePlaceholders('Text is {DUMMY}'); $this->assertSame('Text is Hello World!', $result); } /** * @dataProvider data_testPlaceholder */ public function testPlaceholder($source, $expected) { $text = $this->order->replacePlaceholders("start {$source} end"); $this->assertEquals("start {$expected} end", $text); } public function data_testPlaceholder() { return [ ['{KOD}', '201300025'], ['{STAV}', 'nová'], ['{ODKAZ}', 'https://www.kupshop.local/objednavka/1/?cf=dad3869906bbc5b768a369ea898a1acb'], ['{CENA}', '1 692,80 Kč'], // ['{DATUM}', date('d.\&\n\b\s\p\;m.\&\n\b\s\p\;Y')], // ['{CAS}', date('H:i:s')], ['{WEB}', 'https://www.kupshop.local/'], ['{ZAPLATIT}', '1 693 Kč'], ['{OSLOVENI_JMENO}', 'Lukáši'], ['{OSLOVENI_PRIJMENI}', 'pane Klímo'], ['{POPIS_ZPUSOBU_DORUCENI}', 'popis zpusobu doruceni, popis dopravy, popis platby, kod:201300025'], ['{POPIS_DOPRAVY}', 'popis dopravy'], ['{POPIS_PLATBY}', 'popis platby, kod:201300025'], ['{ODKAZ_SLEDOVANI_BALIKU}', 'https://www.ppl.cz/en/track-a-shipment?shipmentId=123456'], ]; } private function getLastUserMessage() { return end($this->order->getHistory(true))['comment']; } protected function getDataSet() { return $this->getJsonDataSet(/* @lang JSON */ '{ "delivery_type_delivery": [ { "id":4, "name":"PPL", "price":0, "photo":null, "class":"PPL", "time_days":null, "time_hours":null, "currencies":null, "description":"popis dopravy" } ], "delivery_type_payment": [ { "id":1, "name":"Dobírka", "price":0, "class":null, "photo":null, "description":"popis platby, kod:{KOD}" } ], "delivery_type": [ { "id":4, "id_delivery":4, "id_payment":1, "price":90, "vat":2, "price_dont_countin_from":2000, "format":null, "figure":"Y", "description":"popis zpusobu doruceni, {POPIS_DOPRAVY}, {POPIS_PLATBY}" } ], "orders": [ { "id":1, "order_no":201300025, "currency":"CZK", "currency_rate":1, "id_user":null, "date_created":"2013-09-13 13:44:00", "date_accept":"2013-09-13 13:50:19", "date_handle":"2013-09-13 13:50:19", "date_updated":"2015-02-16 11:28:32", "status":0, "status_payed":0, "status_dispatch":0, "status_storno":0, "total_price":1692.8, "invoice_name":"Lukáš", "invoice_surname":"Klíma", "invoice_firm":"WPJ s.r.o.", "invoice_ico":"", "invoice_dic":"", "invoice_street":"Za komínem 5", "invoice_city":"Trutnov", "invoice_zip":54101, "invoice_country":"Česká Republika", "invoice_phone":123456789, "invoice_email":"klima@wpj.cz", "delivery_name":"Lukáš", "delivery_surname":"Klíma", "delivery_firm":"WPJ s.r.o.", "delivery_street":"Za komínem 5", "delivery_city":"Trutnov", "delivery_zip":54101, "delivery_country":"Česká Republika", "delivery_type":"Hotově - Osobní odběr", "id_delivery":4, "delivery_complete":"N", "note_user":"", "note_admin":"", "package_id":"123456", "flags":"" } ] }'); } }