-
-
Notifications
You must be signed in to change notification settings - Fork 132
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 #108 from yurii-github/fix/79-fix-syntax-for-type-…
…uuid more syntax tests for type uuid / no increment
- Loading branch information
Showing
7 changed files
with
116 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Awobaz\Compoships\Tests\Models; | ||
|
||
use Awobaz\Compoships\Compoships; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* @property string $pcid | ||
* @property string $code | ||
* | ||
* @mixin \Illuminate\Database\Eloquent\Builder | ||
*/ | ||
class ProductCode extends Model | ||
{ | ||
use Compoships; | ||
|
||
public $timestamps = false; | ||
public $incrementing = false; | ||
protected $keyType = 'string'; | ||
protected $table = 'product_codes'; | ||
} |
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,47 @@ | ||
<?php | ||
|
||
namespace Awobaz\Compoships\Tests\Unit; | ||
|
||
use Awobaz\Compoships\Tests\Models\Allocation; | ||
use Awobaz\Compoships\Tests\Models\OriginalPackage; | ||
use Awobaz\Compoships\Tests\Models\ProductCode; | ||
use Awobaz\Compoships\Tests\TestCase\TestCase; | ||
use Illuminate\Database\Capsule\Manager as Capsule; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class BelongsToTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function test_uuid_no_inrecemnt_relation() | ||
{ | ||
Model::unguard(); | ||
|
||
$pcid = uniqid(); | ||
$productCode = new ProductCode([ | ||
'pcid' => $pcid, | ||
'code' => 'AAA-BBB-CCC', | ||
]); | ||
$productCode->save(); | ||
|
||
$allocation = new Allocation(); | ||
$allocation->save(); | ||
|
||
/** @var OriginalPackage $package */ | ||
$package = $allocation->originalPackages()->create([ | ||
'pcid' => $pcid, | ||
]); | ||
|
||
$dbPackage = Capsule::table('original_packages')->find($package->id); | ||
|
||
$this->assertEquals(1, Capsule::table('original_packages')->count()); | ||
$this->assertNotNull($dbPackage); | ||
$this->assertEquals($pcid, $package->pcid); | ||
$this->assertEquals($pcid, $dbPackage->pcid); | ||
$this->assertInstanceOf(ProductCode::class, $package->productCode); | ||
$this->assertEquals($pcid, $package->productCode->pcid); | ||
|
||
$this->assertEquals($package->productCode, $package->productCode2); | ||
} | ||
} |
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