|
11 | 11 |
|
12 | 12 | namespace CodeIgniter\Database\Live; |
13 | 13 |
|
| 14 | +use CodeIgniter\Database\RawSql; |
14 | 15 | use CodeIgniter\Test\CIUnitTestCase; |
15 | 16 | use CodeIgniter\Test\DatabaseTestTrait; |
16 | 17 | use Tests\Support\Database\Seeds\CITestSeeder; |
@@ -121,4 +122,32 @@ public function testLikeSpacesOrTabs() |
121 | 122 | $this->assertCount(1, $spaces); |
122 | 123 | $this->assertCount(1, $tabs); |
123 | 124 | } |
| 125 | + |
| 126 | + /** |
| 127 | + * @see https://github.com/codeigniter4/CodeIgniter4/issues/7268 |
| 128 | + */ |
| 129 | + public function testLikeRawSqlAndCountAllResultsAndGet() |
| 130 | + { |
| 131 | + $builder = $this->db->table('job'); |
| 132 | + $builder->like(new RawSql('name'), 'Developer'); |
| 133 | + $count = $builder->countAllResults(false); |
| 134 | + $results = $builder->get()->getResult(); |
| 135 | + |
| 136 | + $this->assertSame(1, $count); |
| 137 | + $this->assertSame('Developer', $results[0]->name); |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * @see https://github.com/codeigniter4/CodeIgniter4/issues/7268 |
| 142 | + */ |
| 143 | + public function testLikeRawSqlAndGetAndCountAllResults() |
| 144 | + { |
| 145 | + $builder = $this->db->table('job'); |
| 146 | + $builder->like(new RawSql('name'), 'Developer'); |
| 147 | + $results = $builder->get(null, 0, false)->getResult(); |
| 148 | + $count = $builder->countAllResults(); |
| 149 | + |
| 150 | + $this->assertSame(1, $count); |
| 151 | + $this->assertSame('Developer', $results[0]->name); |
| 152 | + } |
124 | 153 | } |
0 commit comments