Skip to content

Commit f81eae1

Browse files
committed
Added tests
1 parent dd929c0 commit f81eae1

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of CodeIgniter 4 framework.
7+
*
8+
* (c) CodeIgniter Foundation <admin@codeigniter.com>
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
namespace CodeIgniter\Database\Live\SQLSRV;
15+
16+
use CodeIgniter\Database\SQLSRV\Builder;
17+
use CodeIgniter\Test\CIUnitTestCase;
18+
use CodeIgniter\Test\DatabaseTestTrait;
19+
use PHPUnit\Framework\Attributes\Group;
20+
use Tests\Support\Database\Seeds\CITestSeeder;
21+
22+
/**
23+
* @internal
24+
*/
25+
#[Group('DatabaseLive')]
26+
final class IncrementTest extends CIUnitTestCase
27+
{
28+
use DatabaseTestTrait;
29+
30+
protected $refresh = true;
31+
protected $seed = CITestSeeder::class;
32+
33+
protected function setUp(): void
34+
{
35+
parent::setUp();
36+
37+
if ($this->db->DBDriver !== 'SQLSRV') {
38+
$this->markTestSkipped('This test is only for SQLSRV.');
39+
}
40+
}
41+
42+
public function testIncrementWhenCastTextToIntFalse(): void
43+
{
44+
$this->hasInDatabase('job', ['name' => 'incremental', 'created_at' => 6]);
45+
46+
$this->assertTrue($this->db->table('job') instanceof Builder);
47+
48+
$this->db->table('job')->castTextToInt = false;
49+
50+
$this->db->table('job')
51+
->where('name', 'incremental')
52+
->increment('created_at');
53+
54+
$this->seeInDatabase('job', ['name' => 'incremental', 'created_at' => 7]);
55+
}
56+
57+
public function testDecrementWhenCastTextToIntFalse(): void
58+
{
59+
$this->hasInDatabase('job', ['name' => 'decremental', 'created_at' => 6]);
60+
61+
$this->assertTrue($this->db->table('job') instanceof Builder);
62+
63+
$this->db->table('job')->castTextToInt = false;
64+
65+
$this->db->table('job')
66+
->where('name', 'decremental')
67+
->decrement('created_at');
68+
69+
$this->seeInDatabase('job', ['name' => 'decremental', 'created_at' => 5]);
70+
}
71+
}

0 commit comments

Comments
 (0)