-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
tests/ORM/Functional/Driver/Common/Integration/Case321/CaseTest.php
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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321; | ||
|
||
use Cycle\ORM\Select; | ||
use Cycle\ORM\Tests\Functional\Driver\Common\BaseTest; | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\IntegrationTestTrait; | ||
use Cycle\ORM\Tests\Traits\TableTrait; | ||
|
||
abstract class CaseTest extends BaseTest | ||
{ | ||
use IntegrationTestTrait; | ||
use TableTrait; | ||
|
||
public function setUp(): void | ||
{ | ||
// Init DB | ||
parent::setUp(); | ||
$this->makeTables(); | ||
|
||
$this->loadSchema(__DIR__ . '/schema.php'); | ||
} | ||
|
||
public function test1(): void | ||
{ | ||
$user = new Entity\User1(); | ||
|
||
// Store changes and calc write queries | ||
$this->captureWriteQueries(); | ||
$this->save($user); | ||
|
||
// Check write queries count | ||
$this->assertNumWrites(1); | ||
} | ||
|
||
public function test2(): void | ||
{ | ||
$user = new Entity\User2(); | ||
|
||
// Store changes and calc write queries | ||
$this->captureWriteQueries(); | ||
$this->save($user); | ||
|
||
// Check write queries count | ||
$this->assertNumWrites(1); | ||
} | ||
|
||
private function makeTables(): void | ||
{ | ||
// Make tables | ||
$this->makeTable('user1', [ | ||
'id' => 'primary', // autoincrement | ||
]); | ||
|
||
$this->makeTable('user2', [ | ||
'id' => 'primary', // autoincrement | ||
]); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/ORM/Functional/Driver/Common/Integration/Case321/Entity/User1.php
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\Entity; | ||
|
||
class User1 | ||
{ | ||
public ?int $id = null; | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/ORM/Functional/Driver/Common/Integration/Case321/Entity/User2.php
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\Entity; | ||
|
||
class User2 | ||
{ | ||
public int $id; | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/ORM/Functional/Driver/Common/Integration/Case321/schema.php
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 | ||
|
||
declare(strict_types=1); | ||
|
||
use Cycle\ORM\Mapper\Mapper; | ||
use Cycle\ORM\SchemaInterface as Schema; | ||
use Cycle\ORM\Select\Source; | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\Entity\User1; | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\Entity\User2; | ||
|
||
return [ | ||
'user1' => [ | ||
Schema::ENTITY => User1::class, | ||
Schema::MAPPER => Mapper::class, | ||
Schema::SOURCE => Source::class, | ||
Schema::DATABASE => 'default', | ||
Schema::TABLE => 'user1', | ||
Schema::PRIMARY_KEY => ['id'], | ||
Schema::FIND_BY_KEYS => ['id'], | ||
Schema::COLUMNS => [ | ||
'id' => 'id', | ||
], | ||
Schema::RELATIONS => [], | ||
Schema::SCOPE => null, | ||
Schema::TYPECAST => [ | ||
'id' => 'int', | ||
], | ||
Schema::SCHEMA => [], | ||
], | ||
'user2' => [ | ||
Schema::ENTITY => User2::class, | ||
Schema::MAPPER => Mapper::class, | ||
Schema::SOURCE => Source::class, | ||
Schema::DATABASE => 'default', | ||
Schema::TABLE => 'user2', | ||
Schema::PRIMARY_KEY => ['id'], | ||
Schema::FIND_BY_KEYS => ['id'], | ||
Schema::COLUMNS => [ | ||
'id' => 'id', | ||
], | ||
Schema::RELATIONS => [], | ||
Schema::SCOPE => null, | ||
Schema::TYPECAST => [ | ||
'id' => 'int', | ||
], | ||
Schema::SCHEMA => [], | ||
], | ||
]; |
17 changes: 17 additions & 0 deletions
17
tests/ORM/Functional/Driver/MySQL/Integration/Case321/CaseTest.php
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\MySQL\Integration\Case321; | ||
|
||
// phpcs:ignore | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\CaseTest as CommonClass; | ||
|
||
/** | ||
* @group driver | ||
* @group driver-mysql | ||
*/ | ||
class CaseTest extends CommonClass | ||
{ | ||
public const DRIVER = 'mysql'; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ORM/Functional/Driver/Postgres/Integration/Case321/CaseTest.php
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\Postgres\Integration\Case321; | ||
|
||
// phpcs:ignore | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\CaseTest as CommonClass; | ||
|
||
/** | ||
* @group driver | ||
* @group driver-postgres | ||
*/ | ||
class CaseTest extends CommonClass | ||
{ | ||
public const DRIVER = 'postgres'; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ORM/Functional/Driver/SQLServer/Integration/Case321/CaseTest.php
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\SQLServer\Integration\Case321; | ||
|
||
// phpcs:ignore | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\CaseTest as CommonClass; | ||
|
||
/** | ||
* @group driver | ||
* @group driver-sqlserver | ||
*/ | ||
class CaseTest extends CommonClass | ||
{ | ||
public const DRIVER = 'sqlserver'; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ORM/Functional/Driver/SQLite/Integration/Case321/CaseTest.php
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Cycle\ORM\Tests\Functional\Driver\SQLite\Integration\Case321; | ||
|
||
// phpcs:ignore | ||
use Cycle\ORM\Tests\Functional\Driver\Common\Integration\Case321\CaseTest as CommonClass; | ||
|
||
/** | ||
* @group driver | ||
* @group driver-sqlite | ||
*/ | ||
class CaseTest extends CommonClass | ||
{ | ||
public const DRIVER = 'sqlite'; | ||
} |