/** * @dataProvider updateMethodProvider */ public function testUpdateSetsUpdatedAtField($update_method) { $article = new Article($this->conn, ['id' => 1]); $article->setStored(); $article->title = 'foo'; $article->{$update_method}(); $this->assertEquals(new \DateTime(), $article->updated_at); }
/** * @dataProvider updateMethodProvider */ public function testSlugIsNotOverriddenOnUpdate($update_method) { $article = new Article($this->conn); $article->id = 3; $article->title = 'Something something foo'; $article->slug = 'something-something-foo'; $article->setStored(); $article->title = 'Another title'; $article->slug = 'custom-slug'; $article->{$update_method}(); $this->assertSame('custom-slug', $article->slug); }
public function testSchemaWithOneEntity() { $this->creator->addEntityClass('ActiveDoctrine\\Tests\\Fixtures\\Articles\\Article'); $schema = $this->creator->createSchema(); $this->assertTrue($schema->hasTable('articles')); $table = $schema->getTable('articles'); $this->assertSame(Article::getFields(), array_keys($table->getColumns())); $this->assertSame('integer', $table->getColumn('id')->getType()->getName()); $this->assertSame('datetime', $table->getColumn('created_at')->getType()->getName()); }
public function testTimestampNotUpdatedIfNotModified() { $this->loadData('articles'); $article = Article::selectOne($this->getConn())->execute(); $created = $article->created_at; $updated = $article->updated_at; $article->update(); $this->assertSame($created, $article->created_at); $this->assertSame($updated, $article->updated_at); }
public function testSetValuesSafeCanAcceptAnything() { //blacklist is set to [], so should allow anything $article = new Article($this->conn); $values = ['id' => 12, 'title' => 'Foo', 'slug' => 'foo', 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()]; $article->setValuesSafe($values); $this->assertSame($values, $article->getValues()); }