Skip to content

Commit

Permalink
Merge pull request #5622 from Laravel-Backpack/fix-column-priority
Browse files Browse the repository at this point in the history
fix column priority tests
  • Loading branch information
pxpm authored Aug 19, 2024
2 parents 3414754 + 467873a commit d8a5303
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/Unit/CrudPanel/CrudPanelColumnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,19 @@ public function testMoveColumnBefore()
$this->crudPanel->beforeColumn('column1');

$keys = array_keys($this->crudPanel->columns());
$this->assertEquals($this->expectedTwoColumnsArray['column2'], $this->crudPanel->columns()[$keys[0]]);
$expected = $this->expectedTwoColumnsArray['column2'];
$expected['priority'] = 0;
$this->assertEquals($expected, $this->crudPanel->columns()[$keys[0]]);
$this->assertEquals(['column2', 'column1'], $keys);
}

public function testItDoesNotChangeThePriorityIfDeveloperDefinedIt()
{
$this->crudPanel->addColumn('column1');
$this->crudPanel->addColumn(['name' => 'column2', 'priority' => 5])->beforeColumn('column1');
$this->assertEquals(5, $this->crudPanel->firstColumnWhere('name', 'column2')['priority']);
}

public function testMoveColumnBeforeUnknownColumnName()
{
$this->crudPanel->addColumns($this->twoColumnsArray);
Expand All @@ -418,7 +427,9 @@ public function testMoveColumnAfter()
$this->crudPanel->afterColumn('column1');

$keys = array_keys($this->crudPanel->columns());
$this->assertEquals($this->expectedThreeColumnsArray['column3'], $this->crudPanel->columns()[$keys[1]]);
$expected = $this->expectedThreeColumnsArray['column3'];
$expected['priority'] = 1;
$this->assertEquals($expected, $this->crudPanel->columns()[$keys[1]]);
$this->assertEquals(['column1', 'column3', 'column2'], $keys);
}

Expand Down

0 comments on commit d8a5303

Please sign in to comment.