generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #4 from richan-fongdasen/issue-3
Fixes #3 - Issues related to Blob/Binary data type
- Loading branch information
Showing
3 changed files
with
55 additions
and
3 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
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,48 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
beforeEach(function () { | ||
Schema::create('blob_table', function ($table) { | ||
$table->id(); | ||
$table->binary('blob'); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
Schema::dropIfExists('blob_table'); | ||
}); | ||
|
||
test('it can insert a new blob data', function () { | ||
$data = random_bytes(50); | ||
|
||
$result = DB::table('blob_table')->insert([ | ||
'blob' => $data, | ||
]); | ||
|
||
$newData = DB::table('blob_table')->first(); | ||
|
||
expect($result)->toBeTrue() | ||
->and(DB::table('blob_table')->count())->toBe(1) | ||
->and($newData->blob)->toBe($data); | ||
})->group('BlobDataTest', 'DataTypes', 'FeatureTest'); | ||
|
||
test('it can update an existing blob data', function () { | ||
$data = random_bytes(50); | ||
|
||
DB::table('blob_table')->insert([ | ||
'blob' => $data, | ||
]); | ||
|
||
$newData = random_bytes(50); | ||
|
||
$result = DB::table('blob_table')->update([ | ||
'blob' => $newData, | ||
]); | ||
|
||
$updatedData = DB::table('blob_table')->first(); | ||
|
||
expect($result)->toBe(1) | ||
->and($updatedData->blob)->toBe($newData); | ||
})->group('BlobDataTest', 'DataTypes', 'FeatureTest'); |