Exemplo n.º 1
0
 public function testExtraFieldsMarkdown()
 {
     $model = new MarkdownModel();
     $fields = $model->getFieldsInit();
     $this->assertEquals(3, count($fields));
     $this->assertInstanceOf(MarkdownField::className(), $model->getField('content'));
     $this->assertInstanceOf(MarkdownHtmlField::className(), $model->getField('content_html'));
     $model->content = "# Hello world";
     $this->assertEquals("# Hello world", $model->content_html);
     $this->assertEquals("<h1>Hello world</h1>\n", $model->getField('content_html')->getDbPrepValue());
     $model->save();
     $fetchModel = MarkdownModel::objects()->filter(['pk' => 1])->get();
     $this->assertEquals("# Hello world", $fetchModel->content);
     $this->assertEquals("<h1>Hello world</h1>\n", $fetchModel->content_html);
 }
Exemplo n.º 2
0
 public static function getFields()
 {
     return ['content' => ['class' => MarkdownField::className()]];
 }