-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SQLite3 config synchronous (#9202)
* feat: add SQLite3 config synchronous * add synchronous value validation * Update system/Database/SQLite3/Connection.php Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com> * add type for the synchronous property * use InvalidArgumentException from the CodeIgniter namespace * fix rector --------- Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
- Loading branch information
1 parent
c76a68f
commit 35c5784
Showing
5 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Database\Live\SQLite3; | ||
|
||
use CodeIgniter\Exceptions\InvalidArgumentException; | ||
use CodeIgniter\Test\CIUnitTestCase; | ||
use Config\Database; | ||
use PHPUnit\Framework\Attributes\Group; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[Group('DatabaseLive')] | ||
final class ConnectTest extends CIUnitTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->db = Database::connect($this->DBGroup); | ||
|
||
if ($this->db->DBDriver !== 'SQLite3') { | ||
$this->markTestSkipped('This test is only for SQLite3.'); | ||
} | ||
} | ||
|
||
public function testShowErrorMessageWhenSettingInvalidSynchronous(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Invalid synchronous value.'); | ||
|
||
$config = config('Database'); | ||
$group = $config->tests; | ||
// Sets invalid synchronous. | ||
$group['synchronous'] = 123; | ||
$db = Database::connect($group); | ||
|
||
// Actually connect to DB. | ||
$db->initialize(); | ||
} | ||
} |
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