Skip to content

Commit 14a192d

Browse files
committed
Add tests for raw columns.
1 parent 3d7f056 commit 14a192d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/Integration/QueryDataTableTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ public function it_does_not_allow_raw_html_on_edited_columns()
169169
$this->assertNotEquals('<a href="#">Allowed</a>', $json['data'][0]['email']);
170170
}
171171

172+
/** @test */
173+
public function it_allows_raw_html_on_specified_columns()
174+
{
175+
$json = $this->call('GET', '/query/xss-raw')->json();
176+
$this->assertNotEquals('<a href="#">Allowed</a>', $json['data'][0]['foo']);
177+
$this->assertEquals('<a href="#">Allowed</a>', $json['data'][0]['name']);
178+
$this->assertEquals('<a href="#">Allowed</a>', $json['data'][0]['email']);
179+
}
180+
172181
/** @test */
173182
public function it_can_return_auto_index_column()
174183
{
@@ -264,5 +273,16 @@ protected function setUp()
264273
})
265274
->toJson();
266275
});
276+
277+
$route->get('/query/xss-raw', function (DataTables $dataTable) {
278+
return $dataTable->query(DB::table('users'))
279+
->addColumn('foo', '<a href="#">Allowed</a>')
280+
->editColumn('name', '<a href="#">Allowed</a>')
281+
->editColumn('email', function() {
282+
return '<a href="#">Allowed</a>';
283+
})
284+
->rawColumns(['name', 'email'])
285+
->toJson();
286+
});
267287
}
268288
}

0 commit comments

Comments
 (0)