This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2 from BrosSquad/dusan
Dusan
- Loading branch information
Showing
14 changed files
with
1,026 additions
and
138 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
|
||
|
||
use BrosSquad\MicroORM\Tests\MicroORMTestCase; | ||
use BrosSquad\MicroORM\Tests\Models\User; | ||
use BrosSquad\MicroORM\Tests\Models\Actor; | ||
use Carbon\CarbonImmutable; | ||
|
||
class InsertActionTest extends MicroORMTestCase | ||
{ | ||
|
@@ -14,27 +15,26 @@ class InsertActionTest extends MicroORMTestCase | |
*/ | ||
public function test_insert_into() | ||
{ | ||
$user = new User([ | ||
'name' => 'Test', | ||
'surname' => 'Test', | ||
'email' => '[email protected]', | ||
'password' => 'test123' | ||
$actor = new Actor([ | ||
'first_name' => 'Test', | ||
'last_name' => 'Test', | ||
'last_update' => CarbonImmutable::now() | ||
]); | ||
|
||
$hasInserted = $user->insert(); | ||
$hasInserted = $actor->insert(); | ||
|
||
$this->assertTrue($hasInserted); | ||
} | ||
|
||
public function test_insert_with_save() { | ||
$user = new User([ | ||
'name' => 'Test', | ||
'surname' => 'Test', | ||
'email' => '[email protected]', | ||
'password' => 'test123' | ||
|
||
$actor = new Actor([ | ||
'first_name' => 'Test2', | ||
'last_name' => 'Test2', | ||
'last_update' => CarbonImmutable::now() | ||
]); | ||
|
||
$hasInserted = $user->save(); | ||
$hasInserted = $actor->save(); | ||
|
||
$this->assertTrue($hasInserted); | ||
} | ||
|
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 |
---|---|---|
|
@@ -5,29 +5,38 @@ | |
|
||
|
||
use BrosSquad\MicroORM\Tests\MicroORMTestCase; | ||
use BrosSquad\MicroORM\Tests\Models\User; | ||
use BrosSquad\MicroORM\Tests\Models\Actor; | ||
|
||
class UpdateActionTest extends MicroORMTestCase | ||
{ | ||
public function test_update() | ||
{ | ||
/** @var User|null $user */ | ||
$user = User::query()->whereEquals('email', '[email protected]')->get()->firstOrDefault(); | ||
/** @var Actor $actor */ | ||
$actor = Actor::query()->whereEquals('first_name', 'Test')->get(); | ||
|
||
$actor = $actor[0] ?? NULL; | ||
|
||
$user->name = 'Dusan'; | ||
if ($actor === NULL) { | ||
$this->fail('Run first insert action test'); | ||
} | ||
|
||
$this->assertTrue($user->update()); | ||
$actor->first_name = 'Dusan'; | ||
|
||
$this->assertTrue($actor->update()); | ||
} | ||
|
||
public function test_update_with_save_method() | ||
{ | ||
/** @var User|null $user */ | ||
$user = User::query()->whereEquals('email', '[email protected]')->get()->firstOrDefault(); | ||
|
||
/** @var Actor $actor */ | ||
$actor = Actor::query()->whereEquals('first_name', 'Test')->get()->firstOrDefault(); | ||
|
||
if ($actor === NULL) { | ||
$this->fail('Run first insert action test'); | ||
} | ||
|
||
$user->name = 'Dusan'; | ||
$actor->first_name = 'Dusan'; | ||
|
||
$this->assertTrue($user->save()); | ||
$this->assertTrue($actor->save()); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,21 +5,20 @@ | |
|
||
|
||
use BrosSquad\MicroORM\Tests\MicroORMTestCase; | ||
use BrosSquad\MicroORM\Tests\Models\User; | ||
use Dusan\PhpMvc\Collections\Collection; | ||
|
||
class WhereTests extends MicroORMTestCase | ||
{ | ||
public function test_whereEquals() | ||
{ | ||
/** @var User|null $user */ | ||
$user = User::query()->whereEquals('email', '[email protected]')->get()->firstOrDefault(); | ||
|
||
if($user === NULL) { | ||
$this->assertTrue(true, 'No user has been found'); | ||
} | ||
$this->assertInstanceOf(User::class, $user); | ||
$this->assertEquals('[email protected]', $user->email); | ||
// /** @var User|null $user */ | ||
// $user = User::query()->whereEquals('email', '[email protected]')->get()->firstOrDefault(); | ||
// | ||
// if($user === NULL) { | ||
// $this->assertTrue(true, 'No user has been found'); | ||
// } | ||
// $this->assertInstanceOf(User::class, $user); | ||
// $this->assertEquals('[email protected]', $user->email); | ||
} | ||
|
||
public function test_no_model_found() | ||
|
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,35 @@ | ||
<?php | ||
|
||
|
||
namespace BrosSquad\MicroORM\Tests\Models; | ||
|
||
|
||
use BrosSquad\MicroORM\Model; | ||
|
||
/** | ||
* Class Actor | ||
* | ||
* @package BrosSquad\MicroORM\Tests\Models | ||
*/ | ||
class Actor extends Model | ||
{ | ||
protected const PRIMARY_KEY = 'actor_id'; | ||
protected const UPDATED_AT = 'last_update'; | ||
|
||
/** @var int */ | ||
protected $actor_id; | ||
|
||
/** @var string */ | ||
protected $first_name; | ||
|
||
/** @var string */ | ||
protected $last_name; | ||
|
||
/** @var string */ | ||
protected $last_update; | ||
|
||
protected static function setTable(): string | ||
{ | ||
return 'actor'; | ||
} | ||
} |
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,52 @@ | ||
<?php | ||
|
||
|
||
namespace BrosSquad\MicroORM\Tests\Models; | ||
|
||
|
||
use BrosSquad\MicroORM\Model; | ||
|
||
class Film extends Model | ||
{ | ||
protected const PRIMARY_KEY = 'film_id'; | ||
protected const UPDATED_AT = 'last_update'; | ||
|
||
/** @var int */ | ||
protected $film_id; | ||
|
||
/** @var string */ | ||
protected $title; | ||
|
||
/** @var string */ | ||
protected $description; | ||
|
||
/** @var int */ | ||
protected $release_year; | ||
|
||
/** @var int */ | ||
protected $language_id; | ||
|
||
/** @var int */ | ||
protected $original_language_id; | ||
|
||
/** @var int */ | ||
protected $rental_duration; | ||
|
||
/** @var double */ | ||
protected $rental_rate; | ||
|
||
/** @var int */ | ||
protected $length; | ||
|
||
/** @var double */ | ||
protected $replacement_cost; | ||
|
||
/** @var string */ | ||
protected $rating; | ||
|
||
/** @var array */ | ||
protected $special_features; | ||
|
||
/** @var int|\DateTime */ | ||
protected $last_update; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.