Skip to content

Commit a437f48

Browse files
committed
DateTime filter (#189): Add test case
1 parent 347a348 commit a437f48

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

tests/TDBMAbstractServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private static function initSchema(Connection $connection): void
266266
}
267267

268268
$db->table('person')
269-
->column('modified_at')->datetime()->null()
269+
->column('modified_at')->datetime()->null()->index()
270270
->column('order')->integer()->null();
271271

272272

tests/TDBMDaoGeneratorTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
use TheCodingMachine\TDBM\Test\Dao\Generated\UserBaseDao;
7777
use TheCodingMachine\TDBM\Test\Dao\InheritedObjectDao;
7878
use TheCodingMachine\TDBM\Test\Dao\NodeDao;
79+
use TheCodingMachine\TDBM\Test\Dao\PersonDao;
7980
use TheCodingMachine\TDBM\Test\Dao\RefNoPrimKeyDao;
8081
use TheCodingMachine\TDBM\Test\Dao\RoleDao;
8182
use TheCodingMachine\TDBM\Test\Dao\StateDao;
@@ -747,8 +748,9 @@ public function testFindFromRawSqlOrderByUserCount(): void
747748
$countryDao = new TestCountryDao($this->tdbmService);
748749
$countries = $countryDao->getCountriesByUserCount();
749750

750-
$this->assertCount(4, $countries);
751-
for ($i = 1; $i < count($countries); $i++) {
751+
$nbCountries = 4;
752+
$this->assertCount($nbCountries, $countries);
753+
for ($i = 1; $i < $nbCountries; $i++) {
752754
$this->assertLessThanOrEqual($countries[$i - 1]->getUsers()->count(), $countries[$i]->getUsers()->count());
753755
}
754756
}
@@ -2169,4 +2171,11 @@ public function testMethodNameConflictsBetweenRegularAndAutoPivotProperties(): v
21692171
$artist->getChildrenByArtistsRelations(); // auto-pivot relationship
21702172
$this->assertEquals(1, 1);
21712173
}
2174+
2175+
public function testFindByDateTime(): void
2176+
{
2177+
$personDao = new PersonDao($this->tdbmService);
2178+
$personDao->findByModifiedAt(new \DateTimeImmutable('+1 year'))->count();
2179+
$this->assertTrue(true);
2180+
}
21722181
}

0 commit comments

Comments
 (0)