Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion app/Controllers/Sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ public function postAddPayment(): void
*/
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
}
Expand Down
31 changes: 31 additions & 0 deletions app/Helpers/url_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

if (!function_exists('base64url_encode')) {
/**
* Encode data to Base64 URL-safe string.
*
* @param string $data
* @return string
*/
function base64url_encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
}

if (!function_exists('base64url_decode')) {
/**
* Decode Base64 URL-safe string to original data.
*
* @param string $data
* @return string|false
*/
function base64url_decode($data)
{
$remainder = strlen($data) % 4;
if ($remainder) {
$data .= str_repeat('=', 4 - $remainder);
}
return base64_decode(strtr($data, '-_', '+/'));
}
}
4 changes: 3 additions & 1 deletion app/Views/sales/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
if (isset($success)) {
echo '<div class="alert alert-dismissible alert-success">' . esc($success) . '</div>';
}

helper('url');
?>

<div id="register_wrapper">
Expand Down Expand Up @@ -478,7 +480,7 @@
<tbody id="payment_contents">
<?php foreach ($payments as $payment_id => $payment) { ?>
<tr>
<td><?= anchor("$controller_name/deletePayment/". base64_encode($payment_id), '<span class="glyphicon glyphicon-trash"></span>') ?></td>
<td><?= anchor("$controller_name/deletePayment/". base64url_encode($payment_id), '<span class="glyphicon glyphicon-trash"></span>') ?></td>
<td><?= $payment['payment_type'] ?></td>
<td style="text-align: right;"><?= to_currency($payment['payment_amount']) ?></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"matrix": "https://matrix.to/#/#opensourcepos_Lobby:gitter.im"
},
"require": {
"ext-intl": "*",
"php": "^8.1",
"codeigniter4/framework": "4.6.0",
"dompdf/dompdf": "^2.0.3",
Expand Down
4 changes: 1 addition & 3 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2.2'

include:
- docker/docker-mysql.yml

Expand All @@ -18,6 +16,6 @@ services:
- MYSQL_DATABASE=ospos
- MYSQL_USERNAME=admin
- MYSQL_PASSWORD=pointofsale
command: [ "/bin/wait-for-it.sh", "mysql:3306", "--", "/app/vendor/bin/phpunit", "/app/app/tests" ]
command: [ "/bin/wait-for-it.sh", "mysql:3306", "--", "/app/vendor/bin/phpunit", "/app/tests" ]
ports:
- "80:80"
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions tests/giftcard_numbering.js

This file was deleted.

25 changes: 25 additions & 0 deletions tests/helpers/UrlHelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use PHPUnit\Framework\TestCase;

class UrlHelperTest extends TestCase
{
protected function setUp(): void
{
// Include the url_helper.php file
require_once __DIR__ . '/../../app/Helpers/url_helper.php';
}

public function testBase64urlEncode(): void
{
$data = 'Test data';
$encoded = base64url_encode($data);

// Assert that the encoded string is URL-safe
$this->assertMatchesRegularExpression('/^[A-Za-z0-9\-_]+$/', $encoded);

// Assert that decoding the encoded string returns the original data
$decoded = base64url_decode($encoded);
$this->assertEquals($data, $decoded);
}
}
11 changes: 0 additions & 11 deletions tests/index.html

This file was deleted.

43 changes: 0 additions & 43 deletions tests/make_sale_receiving.js

This file was deleted.

47 changes: 0 additions & 47 deletions tests/ospos.js

This file was deleted.

15 changes: 2 additions & 13 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap = "../../vendor/autoload.php"
<phpunit bootstrap = "../vendor/autoload.php"
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false">
stopOnFailure = "false">

<testsuites>
<testsuite name="Helpers">
<directory>helpers</directory>
</testsuite>
<testsuite name="Libraries">
<directory>libraries</directory>
</testsuite>
<testsuite name="Models">
<directory>models</directory>
</testsuite>
</testsuites>

</phpunit>
32 changes: 0 additions & 32 deletions tests/receiving_quantity.js

This file was deleted.

11 changes: 0 additions & 11 deletions tests/sanity_check.js

This file was deleted.

Loading