forked from tursodatabase/libsql-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextDataTest.php
64 lines (47 loc) · 1.94 KB
/
TextDataTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
beforeEach(function () {
Schema::create('text_table', function ($table) {
$table->id();
$table->string('description');
});
});
afterEach(function () {
Schema::dropIfExists('text_table');
});
test('it can insert a new text data', function () {
$description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
$result = DB::table('text_table')->insert([
'description' => $description,
]);
$newData = DB::table('text_table')->first();
expect($result)->toBeTrue()
->and(DB::table('text_table')->count())->toBe(1)
->and($newData->description)->toBe($description);
})->group('TextDataTest', 'DataTypes', 'FeatureTest');
test('it can update an existing text data', function () {
$description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
DB::table('text_table')->insert([
'description' => $description,
]);
$newDescription = 'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
$result = DB::table('text_table')->update([
'description' => $newDescription,
]);
$updatedData = DB::table('text_table')->first();
expect($result)->toBe(1)
->and($updatedData->description)->toBe($newDescription);
})->group('TextDataTest', 'DataTypes', 'FeatureTest');
test('it can find the saved record', function () {
$description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
DB::table('text_table')->insert([
'description' => 'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
]);
DB::table('text_table')->insert([
'description' => $description,
]);
$found = DB::table('text_table')->where('description', $description)->first();
expect($found->id)->toBe(2)
->and($found->description)->toBe($description);
})->group('TextDataTest', 'DataTypes', 'FeatureTest');