Skip to content

Commit

Permalink
fix: inserted virtual data in mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter committed Aug 20, 2024
2 parents 385f146 + 3481914 commit 46533b0
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/BackupTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace WatheqAlshowaiter\BackupTables;


use Illuminate\Support\Facades\Facade;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/BackupTablesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace WatheqAlshowaiter\BackupTables;


use Illuminate\Support\ServiceProvider;

class BackupTablesServiceProvider extends ServiceProvider
class BackupTablesServiceProvider extends ServiceProvider
{
public function register()
{
Expand Down
3 changes: 0 additions & 3 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ class Constants

public const VERSION_AFTER_ID_METHOD_SUPPORT = 7.0;


public const VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT = 8.0;


}
1 change: 0 additions & 1 deletion src/Models/Father.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace WatheqAlshowaiter\BackupTables\Models;


use Illuminate\Database\Eloquent\Model;

class Father extends Model
Expand Down
1 change: 0 additions & 1 deletion src/Models/Son.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace WatheqAlshowaiter\BackupTables\Models;


use Illuminate\Database\Eloquent\Model;

class Son extends Model
Expand Down
6 changes: 3 additions & 3 deletions tests/BackupTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use WatheqAlshowaiter\BackupTables\BackupTables;
use WatheqAlshowaiter\BackupTables\Constants;
use WatheqAlshowaiter\BackupTables\Models\Father;
use WatheqAlshowaiter\BackupTables\Models\Son;
use Illuminate\Support\Facades\DB;

class BackupTablesTest extends TestCase
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public function test_generate_single_table_backup_all_table_data()
$this->assertEquals(Father::value('first_name'), DB::table($newTableName)->value('first_name'));
$this->assertEquals(Father::value('email'), DB::table($newTableName)->value('email'));

if(DB::getDriverName() == 'mysql' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT){
if (DB::getDriverName() == 'mysql' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT) {
$this->assertEquals(Father::value('full_name'), DB::table($newTableName)->value('full_name')); // StoredAs tables
$this->assertEquals(Father::value('status'), DB::table($newTableName)->value('status')); // virtualAs tables
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public function test_generate_multiple_table_backup()
$this->assertEquals(Father::value('first_name'), DB::table($newTableName)->value('first_name'));
$this->assertEquals(Father::value('email'), DB::table($newTableName)->value('email'));

if(DB::getDriverName() == 'mysql' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT){
if (DB::getDriverName() == 'mysql' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT) {
$this->assertEquals(Father::value('full_name'), DB::table($newTableName)->value('full_name')); // StoredAs tables
$this->assertEquals(Father::value('status'), DB::table($newTableName)->value('status')); // virtualAs tables
}
Expand Down

0 comments on commit 46533b0

Please sign in to comment.