public function testAddTimestampsForDifferentEntities() { $article = new Article($this->getConn()); $article->title = 'Foo'; $article->save(); $writer = new Writer($this->getConn()); $writer->save(); $datetime = new \DateTime(); $this->assertEquals($datetime, $article->created_at); $this->assertEquals($datetime, $article->updated_at); $this->assertEquals($datetime, $writer->createdAt); $this->assertEquals($datetime, $writer->anotherCreate); $this->assertEquals($datetime, $writer->updatedAt); $this->assertEquals($datetime, $writer->anotherUpdate); //check that other fields haven't been set on different entities $this->assertNull($writer->created_at); $this->assertNull($writer->updated_at); $this->assertNull($article->createdAt); $this->assertNull($article->anotherCreate); $this->assertNull($article->updatedAt); $this->assertNull($article->anotherUpdate); }
/** * @dataProvider updateMethodProvider */ public function testUpdateFieldsCanBeConfigured($update_method) { $writer = new Writer($this->conn, ['id' => 1]); $writer->setStored(); $writer->forename = 'Glynn'; $writer->{$update_method}(); $datetime = new \DateTime(); $this->assertEquals($datetime, $writer->updatedAt); $this->assertEquals($datetime, $writer->anotherUpdate); //check that other fields haven't been set $this->assertNull($writer->createdAt); $this->assertNull($writer->anotherCreate); }