diff --git a/.travis.yml b/.travis.yml index eaeda5f52..3b985469d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ script: - sed -i 's/opensourcepos.tar.gz/opensourcepos.$version.tgz/g' package.json - npm ci && npm install -g gulp && npm run build - docker build . --target ospos -t ospos + - docker build . --target ospos_test -t ospos_test + - docker run --rm ospos_test /app/vendor/bin/phpunit --testdox - docker build app/Database/ -t "jekkos/opensourcepos:sql-$TAG" env: global: diff --git a/Dockerfile b/Dockerfile index 4846cd46e..376b0834d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ RUN composer install -d/app #RUN sed -i 's/backupGlobals="true"/backupGlobals="false"/g' /app/tests/phpunit.xml WORKDIR /app/tests -CMD ["/app/vendor/phpunit/phpunit/phpunit"] +CMD ["/app/vendor/phpunit/phpunit/phpunit", "/app/test/helpers"] FROM ospos AS ospos_dev diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 3cce20b59..db61d5dc9 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -466,7 +466,9 @@ class Sales extends Secure_Controller */ public function getDeletePayment(string $payment_id): void { - $this->sale_lib->delete_payment(base64_decode($payment_id)); + helper('url'); + + $this->sale_lib->delete_payment(base64url_decode($payment_id)); $this->_reload(); // TODO: Hungarian notation } diff --git a/app/Helpers/url_helper.php b/app/Helpers/url_helper.php new file mode 100644 index 000000000..d0249b2f2 --- /dev/null +++ b/app/Helpers/url_helper.php @@ -0,0 +1,31 @@ +' . esc($success) . ''; } + +helper('url'); ?>
Directory access is forbidden.
- - - diff --git a/tests/make_sale_receiving.js b/tests/make_sale_receiving.js deleted file mode 100644 index 9567dfebf..000000000 --- a/tests/make_sale_receiving.js +++ /dev/null @@ -1,43 +0,0 @@ -var assert = require('assert'); -var ospos = require('./ospos'); -require('wd'); - -describe("create item and make sale", function () { - this.timeout(25000); - - var def_timeout = 3000; - - var item = { name: "anItem", category: "aCategory", cost_price: 10, unit_price: 20 }; - - it("should be able to add item", function (done) { - return ospos.create_item(this.browser, item).then(done, done); - }); - - it("should be able to make sale", function (done) { - return this.browser.get(ospos.url("/index.php/sales")) - .elementById("item", def_timeout).clear().type("1\uE007") - .elementByName("quantity", def_timeout).clear().type("2").elementByName("discount", def_timeout).type(item.cost_price).elementByCssSelector(".glyphicon.glyphicon-refresh").click() - .elementById("add_payment_button", def_timeout).click().elementByCssSelector("tbody#payment_contents tr td:last-child", def_timeout).text().then(function (value) { - assert.equal(value, "$43.56", "price " + value + " in sale register is not correct!!"); - }).elementById("finish_sale_button", def_timeout).click().elementByCssSelector("#receipt_items tbody tr:nth-child(8) td:last-child", def_timeout).text().then(function (value) { - assert.equal(value, "$43.56", "price " + value + " on sale receipt is not correct!!"); - }).elementByCssSelector("#receipt_items tbody tr:nth-child(10) td:last-child", def_timeout).text().then(function (value) { - assert.equal(value, "-$43.56", "payment amount " + value + " on sale receipt is not correct!!") - }).then(done, done); - }); - - - it("should be able to make receiving", function (done) { - return this.browser.get(ospos.url("/index.php/receivings")) - .elementById("item", def_timeout).clear().type("1\uE007") - .elementByName("quantity", def_timeout).clear().type("2").elementByCssSelector("a[title='Update']").click() - .elementByCssSelector("td:nth-last-child(2)").text().then(function (value) { - assert.equal(value, "$20.00", "price " + value + " in receiving register is not correct!!"); - }).elementById("finish_receiving_button").click().elementByCssSelector("#receipt_items tbody tr:nth-last-child(2) td:nth-child(2) div.total-value").text().then(function (value) { - assert.equal(value, "$20.00", "price " + value + " on receiving receipt is not correct!!"); - }) - .then(done, done); - }); - - -}); diff --git a/tests/ospos.js b/tests/ospos.js deleted file mode 100644 index 26ea741d0..000000000 --- a/tests/ospos.js +++ /dev/null @@ -1,47 +0,0 @@ -var assert = require('assert'); - -var ospos = function () { - - var server = "http://localhost"; - - return { - - url: function (suffix) { - return server + suffix; - } - , - login: function (browser, done) { - return browser.get(this.url("/index.php")) - .elementByName('username').type("admin").getValue() - .then(function (value) { - assert.equal(value, "admin"); - }) - .elementByName('password').type("pointofsale").getValue() - .then(function (value) { - assert.ok(value, "pointofsale"); - }) - .elementByName('loginButton').click() - .elementById('home_module_list').then(function (value) { - assert.ok(value, "Login failed!!") - }) - .then(done, done); - - }, - - create_item: function (browser, item) { - return browser.get(this.url("/index.php/items")).elementByCssSelector("button[title*='New Item']", 5000).click() - .elementById('cost_price', 2000).clear().type(item.cost_price) - .elementById("unit_price", 2000).type(item.unit_price) - .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") - .elementById("name", 10000).type(item.name) - .elementById("category", 2000).clear().type(item.category) - .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) - .elementById("quantity_1", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() - .elementByXPath("//table/tbody/tr[td/text()='anItem']", 5000).text().then(function (value) { - assert.equal(value, "1 - anItem aCategory - $10.00 $20.00 1 21.00%"); - }); - } - } -}; - -module.exports = ospos(); diff --git a/tests/phpunit.xml b/tests/phpunit.xml index ccde244d8..7c20c1a2d 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,26 +1,15 @@ -