-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from WendellAdriel/fix-model-conflicts
Fix Model Conflicts
- Loading branch information
Showing
9 changed files
with
183 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
<?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 Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./app</directory> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
|
||
<php> | ||
<env name="DB_CONNECTION" value="sqlite"/> | ||
<env name="DB_DATABASE" value=":memory:"/> | ||
</php> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage/> | ||
<php> | ||
<env name="DB_CONNECTION" value="sqlite"/> | ||
<env name="DB_DATABASE" value=":memory:"/> | ||
</php> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./app</directory> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Datasets; | ||
|
||
use Illuminate\Database\Eloquent\Concerns\HasUlids; | ||
use Illuminate\Database\Eloquent\Model; | ||
use WendellAdriel\Lift\Attributes\PrimaryKey; | ||
use WendellAdriel\Lift\Lift; | ||
|
||
final class Crew extends Model | ||
{ | ||
use HasUlids; | ||
use Lift; | ||
|
||
#[PrimaryKey(type: 'string', incrementing: false)] | ||
public string $id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Datasets; | ||
|
||
use Illuminate\Database\Eloquent\Concerns\HasUuids; | ||
use Illuminate\Database\Eloquent\Model; | ||
use WendellAdriel\Lift\Attributes\PrimaryKey; | ||
use WendellAdriel\Lift\Lift; | ||
|
||
final class Game extends Model | ||
{ | ||
use HasUuids; | ||
use Lift; | ||
|
||
#[PrimaryKey(type: 'string', incrementing: false)] | ||
public string $id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Datasets; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Database\Eloquent\Model; | ||
use WendellAdriel\Lift\Attributes\Cast; | ||
use WendellAdriel\Lift\Attributes\DB; | ||
use WendellAdriel\Lift\Attributes\Fillable; | ||
use WendellAdriel\Lift\Attributes\PrimaryKey; | ||
use WendellAdriel\Lift\Lift; | ||
|
||
#[DB(table: 'posts')] | ||
class PostTimestamps extends Model | ||
{ | ||
use Lift; | ||
|
||
#[PrimaryKey] | ||
public int $id; | ||
|
||
#[Fillable] | ||
public string $title; | ||
|
||
#[Fillable] | ||
public string $content; | ||
|
||
#[Fillable] | ||
public ?int $user_id; | ||
|
||
#[Cast('datetime')] | ||
public Carbon $created_at; | ||
|
||
#[Cast('datetime')] | ||
public Carbon $updated_at; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Tests\Datasets\PostTimestamps; | ||
|
||
it('should set timestamps on create', function () { | ||
PostTimestamps::create([ | ||
'title' => 'Test', | ||
'content' => 'Test', | ||
]); | ||
|
||
$post = PostTimestamps::first(); | ||
expect($post->created_at)->not->toBeNull(); | ||
expect($post->updated_at)->not->toBeNull(); | ||
}); | ||
|
||
it('should set timestamps on update', function () { | ||
$post = PostTimestamps::create([ | ||
'title' => 'Test', | ||
'content' => 'Test', | ||
]); | ||
sleep(2); // Wait 2 seconds to update | ||
$post->title = 'Test 2'; | ||
$post->save(); | ||
$post = $post->fresh(); | ||
|
||
expect($post->created_at)->not->toBeNull(); | ||
expect($post->updated_at)->not->toBeNull(); | ||
expect($post->created_at)->not->toEqual($post->updated_at); | ||
expect($post->updated_at)->toBeGreaterThan($post->created_at); | ||
expect($post->title)->toBe('Test 2'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters