public function testSerializeKeepsProperties() { $now = new \DateTime(); $performance = new Performance($this->getConn(), ['name' => 'foo', 'start_time' => $now]); $performance->insert(); //simulate caching the entity $cache = serialize($performance); $cached_performance = unserialize($cache); $this->assertEquals($performance->getValues(), $cached_performance->getValues()); $this->assertTrue($cached_performance->isStored()); }
public function testSelectOneTypeConversion() { $date = new \DateTime('2000-01-01'); $this->loadSchema('music_festival'); $this->loadData('music_festival'); $perf = Performance::selectOne($this->getConn())->where('start_time', '=', $date)->execute(); $this->assertInstanceOf('ActiveDoctrine\\Tests\\Fixtures\\MusicFestival\\Performance', $perf); $this->assertSame('Millennium', $perf->name); $this->assertEquals($date, $perf->start_time); }
/** * @dataProvider updateMethodProvider() */ public function testUpdateWithType($update_method) { $this->loadSchema('music_festival'); $this->loadData('music_festival'); $perf = Performance::selectOne($this->getConn())->where('id', '=', 2)->execute(); $this->assertSame('Millennium', $perf->name); $perf->name = 'Party'; $now = new \DateTime(); $perf->start_time = $now; $perf->{$update_method}(); //select it again to check the row has been updated $selected = Performance::selectOne($this->getConn())->where('id', '=', 2)->execute(); $this->assertSame('Party', $selected->name); $this->assertEquals($now, $selected->start_time); }