Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 4096b36

Browse files
Updated unit tests (#885)
* Upgraded Symfony requirement to supported versions: 3.4 (LTS) or ^4.1. Other versions don't get security updates to it's important to upgrade as soon as possible. * Fixed some PHPUnit deprecations * Added some columns to PostDatatable * Added PHP 7.2 and 7.3 to Travis, remove PHP 7.1. since we don't support that version anymore.
1 parent 1422aa2 commit 4096b36

File tree

7 files changed

+57
-30
lines changed

7 files changed

+57
-30
lines changed

.travis.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,26 @@ cache:
99
matrix:
1010
fast_finish: true
1111
include:
12-
- php: 7.1
13-
env: DEPENDENCIES=beta
12+
- php: 7.2
13+
env: DEPENDENCIES=beta SYMFONY_REQUIRE="3.4.*"
14+
- php: 7.2
15+
env: DEPENDENCIES=beta SYMFONY_REQUIRE="4.3.*"
16+
- php: 7.3
17+
env: DEPENDENCIES=beta SYMFONY_REQUIRE="3.4.*"
18+
- php: 7.3
19+
env: DEPENDENCIES=beta SYMFONY_REQUIRE="4.3.*"
1420
- php: hhvm
1521
allow_failures:
1622
- php: hhvm
1723

1824
env:
19-
- SYMFONY_VERSION="3.0.*" DEPENDENCIES=dev COMPOSER_FLAGS="--prefer-stable"
25+
- SYMFONY_REQUIRE="3.4.*" DEPENDENCIES=dev COMPOSER_FLAGS="--prefer-stable"
2026

2127
before_install:
2228
- composer self-update
23-
- if [ "$DEPENDENCIES" = "beta" ]; then composer config minimum-stability beta; fi;
24-
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/framework-bundle=$SYMFONY_VERSION; fi
29+
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
30+
- if [ "$DEPENDENCIES" = "beta" ]; then composer config minimum-stability beta; fi;
2531
- if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
26-
- composer require --dev "phpunit/phpunit=5.7.*"
2732

2833
install: composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
2934

Datatable/Filter/SelectFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function setMultiple($multiple)
171171
/**
172172
* @throws Exception
173173
*/
174-
private function setSelectSearchType(string $searchValue)
174+
private function setSelectSearchType(string $searchValue): void
175175
{
176176
$searchTypesCount = \count($this->selectSearchTypes);
177177

Tests/Column/ArrayColumnTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@
1919
*/
2020
final class ArrayColumnTest extends \PHPUnit\Framework\TestCase
2121
{
22-
/**
23-
* testCreate.
24-
*/
2522
public function testIsAssociative()
2623
{
2724
$arrayColumn = new ArrayColumn();
2825
static::assertFalse($this->callMethod($arrayColumn, 'isAssociative', [['a', 'b']]));
2926
static::assertTrue($this->callMethod($arrayColumn, 'isAssociative', [['a' => 1, 'b' => 1]]));
3027
}
3128

32-
/**
33-
* testCreate.
34-
*/
3529
public function testArrayToString()
3630
{
3731
$arrayColumn = new ArrayColumn();

Tests/DatatableTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
*/
2626
final class DatatableTest extends \PHPUnit\Framework\TestCase
2727
{
28-
/**
29-
* testCreate.
30-
*/
3128
public function testCreate()
3229
{
3330
$tableClass = PostDatatable::class;

Tests/Datatables/PostDatatable.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
namespace Sg\DatatablesBundle\Tests\Datatables;
1313

1414
use Sg\DatatablesBundle\Datatable\AbstractDatatable;
15+
use Sg\DatatablesBundle\Datatable\Column\ActionColumn;
16+
use Sg\DatatablesBundle\Datatable\Column\AttributeColumn;
17+
use Sg\DatatablesBundle\Datatable\Column\BooleanColumn;
1518
use Sg\DatatablesBundle\Datatable\Column\Column;
19+
use Sg\DatatablesBundle\Datatable\Column\DateTimeColumn;
20+
use Sg\DatatablesBundle\Datatable\Column\ImageColumn;
21+
use Sg\DatatablesBundle\Datatable\Column\NumberColumn;
22+
use Sg\DatatablesBundle\Datatable\Column\VirtualColumn;
1623

1724
class PostDatatable extends AbstractDatatable
1825
{
@@ -37,6 +44,32 @@ public function buildDatatable(array $options = [])
3744
->add('title', Column::class, [
3845
'title' => 'Title',
3946
])
47+
->add('boolean', BooleanColumn::class, [
48+
'title' => 'Boolean',
49+
])
50+
->add('attribute', AttributeColumn::class, [
51+
'title' => 'Attribute',
52+
])
53+
->add('datetime', DateTimeColumn::class, [
54+
'title' => 'DateTimeColumn',
55+
])
56+
->add('image', ImageColumn::class, [
57+
'title' => 'ImageColumn',
58+
'imagine_filter' => '',
59+
'relative_path' => '',
60+
])
61+
->add(null, ActionColumn::class, [
62+
'title' => 'ActionColumn',
63+
'actions' => [
64+
],
65+
])
66+
->add('number', NumberColumn::class, [
67+
'title' => 'NumberColumn',
68+
'formatter' => new \NumberFormatter('en_US', \NumberFormatter::DECIMAL),
69+
])
70+
->add('virtual', VirtualColumn::class, [
71+
'title' => 'VirtualColumn',
72+
])
4073
;
4174
}
4275

Tests/Response/DatatableQueryBuilderTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,7 @@ public function testUsingTheSortNameWhenShortNameIsNotAReservedWord()
100100
$this->getDataTableQueryBuilder($entityName, $shortName);
101101
}
102102

103-
/**
104-
* @param string $entityName
105-
* @param string $shortName
106-
*
107-
* @return DatatableQueryBuilder
108-
*/
109-
private function getDataTableQueryBuilder($entityName, $shortName)
103+
private function getDataTableQueryBuilder(string $entityName, string $shortName): DatatableQueryBuilder
110104
{
111105
$this->reflectionClass->getShortName()->willReturn($shortName);
112106
$this->classMetadata->getReflectionClass()->willReturn($this->reflectionClass->reveal());

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@
1919
},
2020
"require": {
2121
"php": ">=7.1",
22-
"symfony/framework-bundle": "^3.0|^4.0",
2322
"doctrine/orm": "^2.5",
24-
"symfony/options-resolver": "^3.0|^4.0",
25-
"symfony/property-access": "^3.0|^4.0",
26-
"friendsofsymfony/jsrouting-bundle": "^1.6|^2.0"
27-
},
28-
"autoload": {
29-
"psr-4": { "Sg\\DatatablesBundle\\": "" }
23+
"friendsofsymfony/jsrouting-bundle": "^1.6|^2.0",
24+
"symfony/framework-bundle": "^3.4|^4.1",
25+
"symfony/options-resolver": "^3.4|^4.1",
26+
"symfony/property-access": "^3.4|^4.1",
27+
"symfony/security": "^3.4|^4.1",
28+
"symfony/translation": "^3.4|^4.1",
29+
"twig/twig": "^2.9"
3030
},
3131
"require-dev": {
32+
"phpunit/phpunit": "5.7.*",
3233
"friendsofphp/php-cs-fixer": "^2.15"
34+
},
35+
"autoload": {
36+
"psr-4": { "Sg\\DatatablesBundle\\": "" }
3337
}
3438
}

0 commit comments

Comments
 (0)