From d4c72dfdedee6d7190f5ea37797692d9736ded5d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 11:33:24 +0100 Subject: Fix loading notifications without a message on oracle Signed-off-by: Joas Schilling --- lib/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Handler.php b/lib/Handler.php index 2a16a2b..4bf1d95 100644 --- a/lib/Handler.php +++ b/lib/Handler.php @@ -307,7 +307,7 @@ class Handler { ->setObject($row['object_type'], $row['object_id']) ->setSubject($row['subject'], (array) json_decode($row['subject_parameters'], true)); - if ($row['message'] !== '') { + if ($row['message'] !== '' && $row['message'] !== null) { $notification->setMessage($row['message'], (array) json_decode($row['message_parameters'], true)); } if ($row['link'] !== '' && $row['link'] !== null) { -- cgit v1.2.3 From 2dffc814dee6482c6ed52e19c4e7b5db7ad7e509 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 13:26:02 +0100 Subject: Add a unit test for the empty message handling Signed-off-by: Joas Schilling --- tests/Unit/HandlerTest.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/Unit/HandlerTest.php b/tests/Unit/HandlerTest.php index d6f7ea4..23cec0a 100644 --- a/tests/Unit/HandlerTest.php +++ b/tests/Unit/HandlerTest.php @@ -106,6 +106,62 @@ class HandlerTest extends TestCase { $this->assertSame(0, $this->handler->count($limitedNotification2), 'Wrong notification count for user2 after deleting'); } + public function testFullEmptyMessageForOracle() { + $notification = $this->getNotification([ + 'getApp' => 'testing_notifications', + 'getUser' => 'test_user1', + 'getDateTime' => new \DateTime(), + 'getObjectType' => 'notification', + 'getObjectId' => '1337', + 'getSubject' => 'subject', + 'getSubjectParameters' => [], + 'getMessage' => '', + 'getMessageParameters' => [], + 'getLink' => 'link', + 'getIcon' => 'icon', + 'getActions' => [ + [ + 'getLabel' => 'action_label', + 'getLink' => 'action_link', + 'getRequestType' => 'GET', + 'isPrimary' => false, + ] + ], + ]); + $limitedNotification1 = $this->getNotification([ + 'getApp' => 'testing_notifications', + 'getUser' => 'test_user1', + ]); + $limitedNotification2 = $this->getNotification([ + 'getApp' => 'testing_notifications', + 'getUser' => 'test_user2', + ]); + + // Make sure there is no notification + $this->assertSame(0, $this->handler->count($limitedNotification1), 'Wrong notification count for user1 before adding'); + $notifications = $this->handler->get($limitedNotification1); + $this->assertCount(0, $notifications, 'Wrong notification count for user1 before beginning'); + $this->assertSame(0, $this->handler->count($limitedNotification2), 'Wrong notification count for user2 before adding'); + $notifications = $this->handler->get($limitedNotification2); + $this->assertCount(0, $notifications, 'Wrong notification count for user2 before beginning'); + + // Add and count + $this->assertGreaterThan(0, $this->handler->add($notification)); + $this->assertSame(1, $this->handler->count($limitedNotification1), 'Wrong notification count for user1 after adding'); + $this->assertSame(0, $this->handler->count($limitedNotification2), 'Wrong notification count for user2 after adding'); + + // Get and count + $notifications = $this->handler->get($limitedNotification1); + $this->assertCount(1, $notifications, 'Wrong notification get for user1 after adding'); + $notifications = $this->handler->get($limitedNotification2); + $this->assertCount(0, $notifications, 'Wrong notification get for user2 after adding'); + + // Delete and count again + $this->handler->delete($notification); + $this->assertSame(0, $this->handler->count($limitedNotification1), 'Wrong notification count for user1 after deleting'); + $this->assertSame(0, $this->handler->count($limitedNotification2), 'Wrong notification count for user2 after deleting'); + } + public function testDeleteById() { $notification = $this->getNotification([ 'getApp' => 'testing_notifications', -- cgit v1.2.3 From 86129375827d0677b7655e786dca871cae69cc09 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 12:24:05 +0100 Subject: Add OCI github action Signed-off-by: Joas Schilling --- .github/workflows/oci.yml | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/oci.yml diff --git a/.github/workflows/oci.yml b/.github/workflows/oci.yml new file mode 100644 index 0000000..34ee5aa --- /dev/null +++ b/.github/workflows/oci.yml @@ -0,0 +1,73 @@ +name: PHPUnit + +on: + pull_request: + push: + branches: + - master + - stable* + +env: + APP_NAME: notifications + +jobs: + oci: + runs-on: ubuntu-latest + + strategy: + # do not stop on another job's failure + fail-fast: false + matrix: + php-versions: ['7.4'] + databases: ['oci'] + server-versions: ['stable20'] + + name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }} + + services: + oracle: + image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2" + ports: + - "1521:1521" + + steps: + - name: Checkout server + uses: actions/checkout@v2 + with: + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Checkout app + uses: actions/checkout@v2 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: composer i + + - name: Set up php ${{ matrix.php-versions }} + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-versions }}" + extensions: mbstring, iconv, fileinfo, intl, oci8 + tools: phpunit:8.5.2 + coverage: none + + - name: Set up Nextcloud + run: | + mkdir data + ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin + php -f index.php + ./occ app:enable --force ${{ env.APP_NAME }} + + - name: PHPUnit + working-directory: apps/${{ env.APP_NAME }}/tests/Unit + run: phpunit -c phpunit.xml -- cgit v1.2.3 From 449b38055eaa94c750724691109bad3b0543cf52 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 13:30:20 +0100 Subject: No more travis time Signed-off-by: Joas Schilling --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e426407..6c21549 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,8 +70,6 @@ matrix: env: DB=mysql - php: 7.3 env: DB=pgsql - - php: 7.3 - env: DB=oracle - php: 7.2 env: DB=mysql;INTEGRATION=1 allow_failures: -- cgit v1.2.3