Skip to content
Open
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: 1 addition & 1 deletion .github/workflows/auto_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Automerge PR'
uses: "pascalgn/automerge-action@v0.12.0"
uses: "pascalgn/automerge-action@v0.16.4"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_METHOD: 'squash'
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
coverage: [true]
experimental: [false]
operating_system: [ubuntu-latest]
postgres: ['11', '12', '13', '14', '15']
postgres: ['13', '14', '15']
laravel: ['^10']
php_versions: ['8.1', '8.2']
include:
Expand Down Expand Up @@ -99,6 +99,18 @@ jobs:
postgres: '15'
php_versions: '8.4'
laravel: '^12.0'
- operating_system: 'ubuntu-latest'
coverage: [true]
experimental: [false]
postgres: '17'
php_versions: '8.4'
laravel: '^13.0'
- operating_system: 'ubuntu-latest'
coverage: [true]
experimental: [false]
postgres: '17'
php_versions: '8.5'
laravel: '^13.0'
runs-on: '${{ matrix.operating_system }}'
services:
postgres:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
"ext-json": "*",
"ext-posix": "*",
"php-amqplib/php-amqplib": "^3.0",
"laravel/framework": "^10.0|^11.0|^12.0",
"laravel/framework": "^10.0|^11.0|^12.0|^13.0",
"thecodingmachine/safe": "^2.0",
"umbrellio/laravel-heavy-jobs": "^3.5",
"monolog/monolog": "^3.0",
"influxdb/influxdb-php": "^1.15"
},
"require-dev": {
"phpunit/phpunit": "^10.0|^11.0",
"phpunit/phpunit": "^10.0|^11.0|^12.0",
"php-mock/php-mock": "^2.0",
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0|^11.0",
"mockery/mockery": "^1.0",
"mikey179/vfsstream": "^1.6",
"symplify/easy-coding-standard": "^11.0",
Expand Down
4 changes: 3 additions & 1 deletion src/Integration/Laravel/TableSyncable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ trait TableSyncable
public static function bootTableSyncable(): void
{
if (static::$isTableSyncEnabled) {
static::observe(TableSyncObserver::class);
foreach (['created', 'updated', 'deleted'] as $event) {
static::registerModelEvent($event, TableSyncObserver::class . '@' . $event);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Umbrellio\TableSync\Tests\functional\Laravel\Integration\Console;

use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Console\PidManager;
use Umbrellio\TableSync\Tests\functional\Laravel\LaravelTestCase;

Expand All @@ -17,9 +18,7 @@ protected function setUp(): void
vfsStream::setup('testDir');
}

/**
* @test
*/
#[Test]
public function managing(): void
{
$manager = new PidManager(vfsStream::path('test_file'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Umbrellio\TableSync\Tests\functional\Laravel\Integration\Publishers;

use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Publishers\EnsureConsistencyPublisher;
use Umbrellio\TableSync\Messages\PublishMessage;
use Umbrellio\TableSync\Publisher;
Expand Down Expand Up @@ -31,9 +32,7 @@ protected function setUp(): void
});
}

/**
* @test
*/
#[Test]
public function simplePublish(): void
{
$this->spyPublisher->shouldSkip = true;
Expand All @@ -48,9 +47,7 @@ public function simplePublish(): void
$this->assertNotEmpty($this->spyPublisher->messages);
}

/**
* @test
*/
#[Test]
public function notPublishIfRecordNotExistsAndNotDestroyed(): void
{
$publisher = new EnsureConsistencyPublisher($this->spyPublisher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Umbrellio\TableSync\Tests\functional\Laravel\Integration\Receive;

use Illuminate\Database\Eloquent\Model;
use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Receive\MessageData\AdditionalDataHandlers\ProjectRetriever;
use Umbrellio\TableSync\Integration\Laravel\Receive\MessageData\MessageDataRetriever;
use Umbrellio\TableSync\Messages\ReceivedMessage;
Expand All @@ -13,9 +14,7 @@

class MessageDataRetrieverTest extends LaravelTestCase
{
/**
* @test
*/
#[Test]
public function exceptionIfNoConfig(): void
{
$retriever = new MessageDataRetriever([]);
Expand All @@ -26,9 +25,7 @@ public function exceptionIfNoConfig(): void
$retriever->retrieve($message);
}

/**
* @test
*/
#[Test]
public function exceptionIfNoTableAndModel(): void
{
$retriever = new MessageDataRetriever([
Expand All @@ -41,9 +38,7 @@ public function exceptionIfNoTableAndModel(): void
$retriever->retrieve($message);
}

/**
* @test
*/
#[Test]
public function exceptionIfHasBothTableAndModel(): void
{
$retriever = new MessageDataRetriever([
Expand All @@ -59,9 +54,7 @@ public function exceptionIfHasBothTableAndModel(): void
$retriever->retrieve($message);
}

/**
* @test
*/
#[Test]
public function exceptionIfPassedModelIsNotModelSubclass(): void
{
$retriever = new MessageDataRetriever([
Expand All @@ -76,9 +69,7 @@ public function exceptionIfPassedModelIsNotModelSubclass(): void
$retriever->retrieve($message);
}

/**
* @test
*/
#[Test]
public function exceptionIfNoTargetKeys(): void
{
$retriever = new MessageDataRetriever([
Expand All @@ -93,25 +84,19 @@ public function exceptionIfNoTargetKeys(): void
$retriever->retrieve($message);
}

/**
* @test
*/
#[Test]
public function retrieveByTable(): void
{
$this->assertRetrieved('table', 'test_models');
}

/**
* @test
*/
#[Test]
public function retrieveByModel(): void
{
$this->assertRetrieved('model', TestModel::class);
}

/**
* @test
*/
#[Test]
public function additionalDataHandler(): void
{
$retriever = new MessageDataRetriever([
Expand Down Expand Up @@ -141,9 +126,7 @@ public function additionalDataHandler(): void
], $data->getData());
}

/**
* @test
*/
#[Test]
public function overrideData(): void
{
$retriever = new MessageDataRetriever([
Expand Down
5 changes: 2 additions & 3 deletions tests/functional/Laravel/Integration/Receive/ReceiverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Umbrellio\TableSync\Tests\functional\Laravel\Integration\Receive;

use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Exceptions\UnknownMessageEvent;
use Umbrellio\TableSync\Integration\Laravel\Receive\MessageData\MessageDataRetriever;
use Umbrellio\TableSync\Integration\Laravel\Receive\Receiver;
Expand All @@ -12,9 +13,7 @@

class ReceiverTest extends LaravelTestCase
{
/**
* @test
*/
#[Test]
public function exceptionIfUnknownMessageEvent(): void
{
$messageDataRetreiver = $this->createMock(MessageDataRetriever::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
namespace Umbrellio\TableSync\Tests\functional\Laravel\Integration\Receive\Savers\ConflictResolvers;

use Illuminate\Support\Facades\App;
use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Receive\MessageData\MessageData;
use Umbrellio\TableSync\Integration\Laravel\Receive\Savers\ConflictResolvers\ByTargetKeysResolver;
use Umbrellio\TableSync\Integration\Laravel\Receive\Savers\QuerySaver;
use Umbrellio\TableSync\Tests\functional\Laravel\LaravelTestCase;

class ByTargetKeysResolverTest extends LaravelTestCase
{
/**
* @test
*/
#[Test]
public function correctConditionResolved(): void
{
$resolver = new ByTargetKeysResolver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Umbrellio\TableSync\Tests\functional\Laravel\Integration\Receive\Savers;

use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Receive\Savers\EloquentSaver;
use Umbrellio\TableSync\Tests\functional\Laravel\Models\TestModel;

Expand All @@ -13,9 +14,7 @@ class EloquentSaverTest extends SaverTestCase
protected const TARGET = TestModel::class;
protected const SAVER = EloquentSaver::class;

/**
* @test
*/
#[Test]
public function upsertByDuplicatedTargetKeys(): void
{
$this->dropPrimaryKeyConstraint();
Expand Down Expand Up @@ -44,9 +43,7 @@ public function upsertByDuplicatedTargetKeys(): void
});
}

/**
* @test
*/
#[Test]
public function testUpsertWithChunk(): void
{
$this->dropPrimaryKeyConstraint();
Expand Down Expand Up @@ -81,9 +78,7 @@ public function testUpsertWithChunk(): void
$this->assertDatabaseMissing(static::TARGET, $item3);
}

/**
* @test
*/
#[Test]
public function testDestroyWithChunk(): void
{
$this->dropPrimaryKeyConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\Test;
use Umbrellio\TableSync\Integration\Laravel\Receive\MessageData\MessageData;
use Umbrellio\TableSync\Integration\Laravel\Receive\Savers\Saver;
use Umbrellio\TableSync\Tests\functional\Laravel\LaravelTestCase;
Expand All @@ -28,9 +29,7 @@ protected function setUp(): void
$this->stubPublisher();
}

/**
* @test
*/
#[Test]
public function upsert(): void
{
$data = $this->makeMessageData(['id'], [
Expand Down Expand Up @@ -91,19 +90,15 @@ public function upsert(): void
$this->assertDatabaseHas(static::TARGET, $newRawData);
}

/**
* @test
*/
#[Test]
public function nothingIfUpsertWithEmptyData(): void
{
$data = $this->makeMessageData([], [], 'not_exist_table');

$this->assertNull($data->upsert(10.1));
}

/**
* @test
*/
#[Test]
public function destroy(): void
{
/** @var TestModel $testModel */
Expand All @@ -118,9 +113,7 @@ public function destroy(): void
$this->assertNull($testModel->fresh());
}

/**
* @test
*/
#[Test]
public function destroyBatch(): void
{
$models = factory(TestModel::class, 2)->create();
Expand All @@ -139,9 +132,7 @@ public function destroyBatch(): void
}
}

/**
* @test
*/
#[Test]
public function destroyWithSomeAttributes(): void
{
/** @var TestModel $destroyedModel */
Expand All @@ -163,19 +154,15 @@ public function destroyWithSomeAttributes(): void
$this->assertNotNull($model->fresh());
}

/**
* @test
*/
#[Test]
public function nothingIfDestroyWithEmptyData(): void
{
$data = $this->makeMessageData([], [], 'not_exist_table');

$this->assertNull($data->destroy());
}

/**
* @test
*/
#[Test]
public function destroyByDuplicatedTargetKeys(): void
{
$this->dropPrimaryKeyConstraint();
Expand Down
Loading
Loading