Skip to content

Commit

Permalink
Merge pull request #20 from northernco/automated-testing-deprecations
Browse files Browse the repository at this point in the history
Address test deprecation warnings
  • Loading branch information
cpkdevries committed Jun 22, 2023
2 parents a8601f9 + 50888d2 commit 2db72bb
Show file tree
Hide file tree
Showing 30 changed files with 1,135 additions and 1,547 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ defaults:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
php: ['7.4', '8.0', '8.1']
php: ['8.0', '8.1', '8.2']

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "symfony-bundle",
"license": "MIT",
"require": {
"php": ">=7.4",
"php": ">=8.0",
"symfony/form": "^4.4|^5.2",
"symfony/dependency-injection": "^4.4|^5.2",
"symfony/config": "^4.4|^5.2",
Expand All @@ -23,7 +23,7 @@
"symfony/framework-bundle": "^4.4|^5.2",
"symfony/expression-language": "^4.4|^5.2",
"symfony/phpunit-bridge": "^4.4|^5.2",
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9.5",
"doctrine/orm": "~2.4,>=2.4.5"
},
"suggest": {
Expand Down
32 changes: 21 additions & 11 deletions src/Grid/Action/RowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,17 @@ class RowAction implements RowActionInterface
*/
public function __construct($title, $route, $confirm = false, $target = '_self', $attributes = [], $role = null)
{
$this->title = $title;
$this->route = $route;
$this->confirm = $confirm;
$this->title = $title;
$this->route = $route;
$this->confirm = $confirm;
$this->confirmMessage = 'Do you want to ' . strtolower($title) . ' this row?';
$this->target = $target;
$this->attributes = $attributes;
$this->role = $role;
$this->target = $target;
$this->attributes = $attributes;
$this->role = $role;
}

// @todo: has this setter real sense? we passed this value from constructor

/**
* Set action title.
*
Expand All @@ -99,6 +100,7 @@ public function getTitle()
}

// @todo: has this setter real sense? we passed this value from constructor

/**
* Set action route.
*
Expand Down Expand Up @@ -220,7 +222,7 @@ public function getColumn()
*/
public function addRouteParameters($routeParameters)
{
$routeParameters = (array) $routeParameters;
$routeParameters = (array)$routeParameters;

foreach ($routeParameters as $key => $routeParameter) {
if (is_int($key)) {
Expand All @@ -242,7 +244,7 @@ public function addRouteParameters($routeParameters)
*/
public function setRouteParameters($routeParameters)
{
$this->routeParameters = (array) $routeParameters;
$this->routeParameters = (array)$routeParameters;

return $this;
}
Expand All @@ -256,6 +258,7 @@ public function getRouteParameters()
}

// @todo: why is this accepting string? it seems pretty useless, isn't it?
/**
* Set route parameters mapping.
*
Expand All @@ -265,7 +268,7 @@ public function getRouteParameters()
*/
public function setRouteParametersMapping($routeParametersMapping)
{
$this->routeParametersMapping = (array) $routeParametersMapping;
$this->routeParametersMapping = (array)$routeParametersMapping;

return $this;
}
Expand Down Expand Up @@ -346,11 +349,11 @@ public function getRole()
/**
* Set render callback.
*
* @deprecated This is deprecated and will be removed in 3.0; use addManipulateRender instead.
*
* @param \Closure $callback
*
* @return self
* @deprecated This is deprecated and will be removed in 3.0; use addManipulateRender instead.
*
*/
public function manipulateRender(\Closure $callback)
{
Expand All @@ -371,6 +374,11 @@ public function addManipulateRender($callback)
return $this;
}

public function getCallbacks(): array
{
return $this->callbacks;
}

/**
* Render action for row.
*
Expand All @@ -392,6 +400,7 @@ public function render($row)
}

// @todo: should not this be "isEnabled"?
/**
* {@inheritdoc}
*/
Expand All @@ -401,6 +410,7 @@ public function getEnabled()
}

// @todo: should not this be "enable" as default value is false?
/**
* Set the enabled state of this action.
*
Expand Down
31 changes: 23 additions & 8 deletions src/Grid/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ abstract class Column
*/
public function __construct($params = null)
{
$this->__initialize((array) $params);
$this->__initialize((array)$params);
}

public function __initialize(array $params)
Expand Down Expand Up @@ -206,8 +206,8 @@ public function getParam($id, $default = null)
/**
* Draw cell.
*
* @param mixed $value
* @param Row $row
* @param mixed $value
* @param Row $row
* @param $router
*
* @return string
Expand All @@ -218,8 +218,8 @@ public function renderCell($value, $row, $router)
return call_user_func($this->callback, $value, $row, $router);
}

$value = is_bool($value) ? (int) $value : $value;
if (array_key_exists((string) $value, $this->values)) {
$value = is_bool($value) ? (int)$value : $value;
if (array_key_exists((string)$value, $this->values)) {
$value = $this->values[$value];
}

Expand All @@ -240,6 +240,11 @@ public function manipulateRenderCell($callback)
return $this;
}

public function getCallback(): ?\Closure
{
return $this->callback;
}

/**
* Set column identifier.
*
Expand Down Expand Up @@ -563,6 +568,11 @@ public function getData()
return $result;
}

public function getDataAttribute(): array
{
return $this->data;
}

/**
* Return true if filter value is correct (has to be overridden in each Column class that can be filtered, in order to catch wrong values).
*
Expand Down Expand Up @@ -692,7 +702,7 @@ public function setFilterType($filterType)
{
$this->filterType = strtolower($filterType);

return $this;
return $this;
}

public function getFilterType()
Expand Down Expand Up @@ -742,7 +752,7 @@ public function getFilters($source)
case self::OPERATOR_NEQ:
case self::OPERATOR_NLIKE:
case self::OPERATOR_NSLIKE:
foreach ((array) $this->data['from'] as $value) {
foreach ((array)$this->data['from'] as $value) {
$filters[] = new Filter($this->data['operator'], $value);
}
break;
Expand Down Expand Up @@ -798,7 +808,7 @@ public function getOperators()
self::OPERATOR_GT,
self::OPERATOR_GTE,
self::OPERATOR_BTW,
self::OPERATOR_BTWE, ]);
self::OPERATOR_BTWE,]);
}

return $this->operators;
Expand Down Expand Up @@ -910,6 +920,11 @@ public function setAuthorizationChecker(AuthorizationCheckerInterface $authoriza
return $this;
}

public function getAuthorizationChecker(): ?AuthorizationCheckerInterface
{
return $this->authorizationChecker;
}

public function getParentType()
{
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Grid/Columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getIterator($showOnlySourceColumns = false)
*
* @return Columns
*/
public function addColumn(Column $column, $position = 0)
public function addColumn(Column $column, int $position = 0)
{
$column->setAuthorizationChecker($this->authorizationChecker);

Expand Down
Loading

0 comments on commit 2db72bb

Please sign in to comment.