Skip to content

Commit e5907ab

Browse files
committed
Fix builder columns with tests
1 parent 34b9cbe commit e5907ab

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

src/Html/Columns/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
trait Action
88
{
99
/**
10-
* Add a action column.
10+
* Add an action column.
1111
*
1212
* @param array $attributes
1313
* @param bool $prepend

src/Html/Columns/Checkbox.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ trait Checkbox
99
/**
1010
* Add a checkbox column.
1111
*
12-
* @param array $attributes
13-
* @param bool|int $position true to prepend, false to append or a zero-based index for positioning
12+
* @param array $attributes
13+
* @param bool|int $position true to prepend, false to append or a zero-based index for positioning
1414
* @return $this
1515
*/
1616
public function addCheckbox(array $attributes = [], bool|int $position = false): static
1717
{
1818
$attributes = array_merge([
19-
'defaultContent' => '<input type="checkbox" ' . $this->html->attributes($attributes) . '/>',
20-
'title' => '<input type="checkbox" ' . $this->html->attributes($attributes + ['id' => 'dataTablesCheckbox']) . '/>',
19+
'defaultContent' => '<input type="checkbox" '.$this->html->attributes($attributes).'/>',
20+
'title' => '<input type="checkbox" '.$this->html->attributes($attributes + ['id' => 'dataTablesCheckbox']).'/>',
2121
'data' => 'checkbox',
2222
'name' => 'checkbox',
2323
'orderable' => false,

tests/BuilderTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,52 @@ public function it_can_remove_table_class_attribute()
136136
$builder->removeTableClass(['a' => ' b ', ' foo bar ']);
137137
$this->assertEquals('a', $builder->getTableAttribute('class'));
138138
}
139+
140+
/** @test */
141+
public function it_can_add_checkbox()
142+
{
143+
$builder = $this->getHtmlBuilder();
144+
$builder->addCheckbox();
145+
146+
$column = $builder->getColumns()[0];
147+
148+
$this->assertCount(1, $builder->getColumns());
149+
$this->assertInstanceOf(Column::class, $column);
150+
$this->assertEquals(false, $column->orderable);
151+
$this->assertEquals(false, $column->searchable);
152+
$this->assertEquals(false, $column->exportable);
153+
$this->assertEquals(true, $column->printable);
154+
}
155+
156+
/** @test */
157+
public function it_can_add_index_column()
158+
{
159+
$builder = $this->getHtmlBuilder();
160+
$builder->addIndex();
161+
162+
$column = $builder->getColumns()[0];
163+
164+
$this->assertCount(1, $builder->getColumns());
165+
$this->assertInstanceOf(Column::class, $column);
166+
$this->assertEquals(false, $column->orderable);
167+
$this->assertEquals(false, $column->searchable);
168+
$this->assertEquals(false, $column->exportable);
169+
$this->assertEquals(true, $column->printable);
170+
}
171+
172+
/** @test */
173+
public function it_can_add_action_column()
174+
{
175+
$builder = $this->getHtmlBuilder();
176+
$builder->addAction();
177+
178+
$column = $builder->getColumns()[0];
179+
180+
$this->assertCount(1, $builder->getColumns());
181+
$this->assertInstanceOf(Column::class, $column);
182+
$this->assertEquals(false, $column->orderable);
183+
$this->assertEquals(false, $column->searchable);
184+
$this->assertEquals(false, $column->exportable);
185+
$this->assertEquals(true, $column->printable);
186+
}
139187
}

0 commit comments

Comments
 (0)