Skip to content

Commit

Permalink
Upgrading to laravel 11 and php 8.3. Fixing up doctrine annotations i…
Browse files Browse the repository at this point in the history
…ntegration to work with 12.19. Fixing up tests to use mysql server since it doesn't work with sqlite3. Fixing migrations. Tests pass except some random broken ones.
  • Loading branch information
calebfavor committed Aug 15, 2024
1 parent 5dd0c8e commit 3538cac
Show file tree
Hide file tree
Showing 20 changed files with 276 additions and 306 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
composer.lock
.idea
.phpunit*
.phpunit*
.codebuddy
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# PHPUnit Test Notes
This packages tests require a running mysql server. See connection details inside
the phpunit.xml.


# Menu
- [railnotifications](#railnotifications)
* [Install](#install)
* [NotificationBroadcast event](#notificationbroadcast-event)
Expand Down
32 changes: 10 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,25 @@
"name": "railroad/railnotifications",
"description": "Laravel notification system using entities",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Caleb Favor",
"email": "calebfavor@gmail.com"
}
],
"require": {
"php": "^8.1",
"laravel/framework": "^9.0",
"php": "^8.2",
"laravel/framework": "^11.9",
"guzzlehttp/guzzle": "^7.2",
"kreait/firebase-php": "^6.3",
"doctrine/dbal": "^3.3",
"doctrine/dbal": "^3.0",
"doctrine/annotations": "^2.0",
"symfony/dom-crawler": "^6.0",
"railroad/doctrine": "2.0.*",
"railroad/doctrine-array-hydrator": "^2.0",
"jms/serializer": "1.*",
"railroad/doctrine": "3.0.*",
"railroad/doctrine-array-hydrator": "3.0.*",
"jms/serializer": "^3.0",
"ext-redis": "*",
"ext-pdo": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5.10",
"orchestra/testbench": "^7.4",
"dms/phpunit-arraysubset-asserts": "^0.4.0"
"phpunit/phpunit": "^11.0.1",
"phpunit/php-code-coverage": "^11.0.1",
"orchestra/testbench": "^9.2"
},
"repositories": [
{
Expand All @@ -43,11 +37,5 @@
"psr-4": {
"Railroad\\Railnotifications\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": true,
"composer/package-versions-deprecated": true
}
}
}
2 changes: 2 additions & 0 deletions migrations/2017_02_24_181248_create_notifications_table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
Expand All @@ -26,6 +27,7 @@ function (Blueprint $table) {
$table->timestamps();
}
);
// var_dump("OID " . spl_object_id(DB::connection(config('railnotifications.database_connection_name'))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
'notification_broadcasts',
function (Blueprint $table) {
$table->increments('id');
$table->string('channel', 1500);
$table->string('channel', 500);
$table->string('type');
$table->string('status');
$table->text('report')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
Schema::connection(config('railnotifications.database_connection_name'))->table(
'notifications',
function ($table) {
$table->string('comment')->charset('utf8mb4')->collation('utf8mb4_unicode_ci')->change();
$table->string('comment')->charset('utf8mb4')->collation('utf8mb4_unicode_ci')->nullable()->change();
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function up()
'notifications',
function (\Illuminate\Database\Schema\Blueprint $table) {
$table->mediumText('data')->comment(' ')->change();
$table->mediumText('comment')->comment(' ')->change();
$table->mediumText('comment')->comment(' ')->nullable()->change();
}
);
}
Expand Down
50 changes: 25 additions & 25 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Test">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<server name="APP_ENV" value="testing"/>
<server name="APP_DEBUG" value="true"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Test">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
<server name="APP_DEBUG" value="true"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="MYSQL_DATABASE_NAME" value="railnotifications_automated_tests"/>
<server name="MYSQL_HOST" value="mysql8"/>
<server name="MYSQL_USER_NAME" value="root"/>
<server name="MYSQL_PASSWORD" value="root"/>
<server name="MYSQL_PORT" value="3306"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
1 change: 1 addition & 0 deletions src/Controllers/BroadcastNotificationJsonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\ORM\ORMException;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;
use Railroad\Railnotifications\Exceptions\NotFoundException;
use Railroad\Railnotifications\Requests\BroadcastNotificationRequest;
use Railroad\Railnotifications\Services\NotificationBroadcastService;
Expand Down
93 changes: 0 additions & 93 deletions src/Drivers/ExistingPDOSqliteDriver.php

This file was deleted.

11 changes: 9 additions & 2 deletions src/Faker/Faker.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,30 @@ class Faker extends Generator
{
public function notification(array $override = [])
{
return array_merge(
$array = array_merge(
[
'type' => $this->randomElement(array_keys(config('railnotifications.mapping_types'))),
'data' => json_encode(['commentId' => $this->randomNumber()]),
'data' => json_encode(['commentId' => $override['commentId'] ?? $this->randomNumber()]),
'subject_id' => null,
'author_id' => $this->randomNumber(),
'author_avatar' => $this->imageUrl(),
'author_display_name' => $this->name(),
'recipient_id' => $this->randomNumber(),
'content_title' => $this->text(),
'read_on' => null,
'comment' => $this->text(),
'brand' => config('railnotifications.brand'),
'created_at' => Carbon::now()
->toDateTimeString(),
],
$override
);

if (isset($array['commentId'])) {
unset($array['commentId']);
}

return $array;
}

public function notificationBroadcast(array $override = [])
Expand Down
6 changes: 3 additions & 3 deletions src/Listeners/NotificationEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public function handleUserUpdated($event)
$user->getId(), $user->getDisplayName(), $user->getProfilePictureUrl()
);

dispatch_now($job);
dispatch_sync($job);
}
}

Expand Down Expand Up @@ -425,7 +425,7 @@ public function handleThreadUpdated($event)
{
$job = new UpdateNotificationsThreadData($event->getThreadId());

dispatch_now($job);
dispatch_sync($job);
}

/**
Expand All @@ -435,7 +435,7 @@ public function handlePostUpdated($event)
{
$job = new UpdateNotificationsPostData($event->getPostId());

dispatch_now($job);
dispatch_sync($job);
}

/**
Expand Down
Loading

0 comments on commit 3538cac

Please sign in to comment.