Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
refactor #52 Drop support for PHP 5.5, require PHP 7.0 at minimum (ss…
Browse files Browse the repository at this point in the history
…tok)

This PR was merged into the master branch.

Discussion
----------

|Q            |A  |
|---          |---|
|Bug Fix?     |no |
|New Feature? |no |
|BC Breaks?   |yes|
|Deprecations?|no |
|Fixed Tickets|   |

Commits
-------

76c93a4 Drop support for PHP 5.5, require PHP 7.0 at minimum
aba6116 Fix PHPUnit deprecation warnings
89b0a69 Fix broken tests
cfeae53 No hhvm support for now
  • Loading branch information
sstok committed Sep 20, 2016
2 parents c5d53ac + cfeae53 commit 509250a
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 73 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- hhvm

matrix:
include:
- php: 5.5
env: DEPENDENCIES='low'
- php: 7.0
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
#- php: hhvm-3.12
# sudo: required
# dist: trusty
# group: edge
- php: 7.0
env: DEPENDENCIES='low'
- php: 7.1
env: DEPENDENCIES='dev'
allow_failures:
- env: DEPENDENCIES='dev'
Expand All @@ -29,4 +29,4 @@ install:
- if [ "$DEPENDENCIES" == "low" ]; then travis_retry composer update --prefer-lowest; fi;

script:
- phpunit --configuration phpunit.xml.dist --verbose
- vendor/bin/phpunit --configuration phpunit.xml.dist --verbose
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rollerworks/datagrid",
"description": "A powerful Datagrid component",
"keywords": ["rollerworks", "component", "datagrid", "table"],
"description": "Datagrid system with a modular design and customizable",
"keywords": ["rollerworks", "component", "datagrid", "table", "ui"],
"type": "library",
"license": "MIT",
"authors": [
Expand All @@ -11,14 +11,17 @@
},
{
"name": "Community contributions",
"homepage": "https://github.com/Rollerworks/RollerworksSearch/contributors"
"homepage": "https://github.com/rollerworks/datagrid/contributors"
}
],
"require": {
"php": "~5.5|~7.0",
"symfony/property-access": "~2.8|~3.0",
"symfony/options-resolver": "^2.7.7|~3.0",
"symfony/intl": "~2.3|~3.0"
"php": "^7.0",
"symfony/property-access": "^3.0",
"symfony/options-resolver": "^3.0",
"symfony/intl": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.5"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
Expand Down
8 changes: 4 additions & 4 deletions tests/DatagridFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class DatagridFactoryTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->registry = $this->getMock(ColumnTypeRegistryInterface::class);
$this->resolvedTypeFactory = $this->getMock(ResolvedColumnTypeFactoryInterface::class);
$this->registry = $this->createMock(ColumnTypeRegistryInterface::class);
$this->resolvedTypeFactory = $this->createMock(ResolvedColumnTypeFactoryInterface::class);

$this->factory = new DatagridFactory($this->registry);
}
Expand All @@ -61,9 +61,9 @@ public function testCreateGridBuilder()

public function testCreateColumn()
{
$type = $this->getMock(ResolvedColumnTypeInterface::class);
$type = $this->createMock(ResolvedColumnTypeInterface::class);

$column = $this->getMock(ColumnInterface::class);
$column = $this->createMock(ColumnInterface::class);
$column->expects($this->once())
->method('getOptions')
->will($this->returnValue(['foo' => 'bar']));
Expand Down
2 changes: 1 addition & 1 deletion tests/DatagridRowViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp()
$this->datagridView = $this->getMockBuilder(DatagridView::class)->disableOriginalConstructor()->getMock();
$this->cellView = $this->getMockBuilder(CellView::class)->disableOriginalConstructor()->getMock();

$column = $this->getMock(ColumnInterface::class);
$column = $this->createMock(ColumnInterface::class);

$column->expects($this->once())
->method('getName')
Expand Down
6 changes: 3 additions & 3 deletions tests/DatagridViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DatagridViewTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$column = $this->getMock(ColumnInterface::class);
$column = $this->createMock(ColumnInterface::class);

$column->expects($this->atLeastOnce())
->method('getName')
Expand All @@ -37,7 +37,7 @@ protected function setUp()
->method('createHeaderView')
->willReturn($this->getMockBuilder(HeaderView::class)->disableOriginalConstructor()->getMock());

$datagrid = $this->getMock(DatagridInterface::class);
$datagrid = $this->createMock(DatagridInterface::class);

$datagrid->expects($this->once())
->method('getColumns')
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testGetColumn()

public function testThrowsExceptionWhenGettingUnRegisteredColumn()
{
$this->setExpectedException(InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$this->gridView->getColumn('bar');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public static function assertEquals($expected, $actual, $message = '', $delta =
public function dataProvider()
{
return [
[\IntlDateFormatter::SHORT, null, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::MEDIUM, null, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::LONG, null, null, '03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::FULL, null, null, 'Mittwoch, 03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::SHORT, null, null, '03.02.2010, 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::MEDIUM, null, null, '03.02.2010, 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::LONG, null, null, '3. Februar 2010 um 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::FULL, null, null, 'Mittwoch, 3. Februar 2010 um 04:05', '2010-02-03 04:05:00 UTC'],
[\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, null, '03.02.2010', '2010-02-03 00:00:00 UTC'],
[\IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE, null, '03.02.2010', '2010-02-03 00:00:00 UTC'],
[\IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, '03. Februar 2010', '2010-02-03 00:00:00 UTC'],
[\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 03. Februar 2010', '2010-02-03 00:00:00 UTC'],
[null, \IntlDateFormatter::SHORT, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'],
[null, \IntlDateFormatter::MEDIUM, null, '03.02.2010 04:05:06', '2010-02-03 04:05:06 UTC'],
[null, \IntlDateFormatter::LONG, null, '03.02.2010 04:05:06 GMT', '2010-02-03 04:05:06 UTC'],
[\IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, '3. Februar 2010', '2010-02-03 00:00:00 UTC'],
[\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 3. Februar 2010', '2010-02-03 00:00:00 UTC'],
[null, \IntlDateFormatter::SHORT, null, '03.02.2010, 04:05', '2010-02-03 04:05:00 UTC'],
[null, \IntlDateFormatter::MEDIUM, null, '03.02.2010, 04:05:06', '2010-02-03 04:05:06 UTC'],
[null, \IntlDateFormatter::LONG, null, '03.02.2010, 04:05:06 GMT', '2010-02-03 04:05:06 UTC'],
// see below for extra test case for time format FULL
[\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'],
[\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'],
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testTransformFullTime()
{
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);

$this->assertEquals('03.02.2010 04:05:06 GMT', $transformer->transform($this->dateTime));
$this->assertEquals('03.02.2010, 04:05:06 GMT', $transformer->transform($this->dateTime));
}

public function testTransformToDifferentLocale()
Expand Down Expand Up @@ -134,7 +134,7 @@ public function testTransformWithDifferentTimezones()
$dateTime = clone $input;
$dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));

$this->assertEquals($dateTime->format('d.m.Y H:i'), $transformer->transform($input));
$this->assertEquals($dateTime->format('d.m.Y, H:i'), $transformer->transform($input));
}

public function testTransformWithDifferentPatterns()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function testTransform($from, $to, $locale)
public function provideTransformationsWithGrouping()
{
return [
[1234.5, '1.234,5', 'de_AT'],
[12345.912, '12.345,912', 'de_AT'],
[1234.5, '1 234,5', 'de_AT'],
[12345.912, '12 345,912', 'de_AT'],
[1234.5, '1 234,5', 'fr'],
[1234.5, '1 234,5', 'ru'],
[1234.5, '1 234,5', 'fi'],
Expand Down
25 changes: 0 additions & 25 deletions tests/Extension/Core/Type/BaseTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,4 @@

abstract class BaseTypeTest extends ColumnTypeTestCase
{
public function testPassLabelToView()
{
$column = $this->factory->createColumn(
'id',
$this->getTestedType(),
[
'label' => 'My label',
'data_provider' => function ($data) {
return $data->key;
},
]
);

$datagrid = $this->factory->createDatagrid('grid', [$column]);

$object = new \stdClass();
$object->key = ' foo ';

$datagrid->setData([1 => $object]);

$view = $datagrid->createView();
$view = $column->createHeaderView($view);

$this->assertSame('My label', $view->label);
}
}
26 changes: 26 additions & 0 deletions tests/Extension/Core/Type/ColumnTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@

class ColumnTypeTest extends BaseTypeTest
{
public function testPassLabelToView()
{
$column = $this->factory->createColumn(
'id',
$this->getTestedType(),
[
'label' => 'My label',
'data_provider' => function ($data) {
return $data->key;
},
]
);

$datagrid = $this->factory->createDatagrid('grid', [$column]);

$object = new \stdClass();
$object->key = new \DateTime();

$datagrid->setData([1 => $object]);

$view = $datagrid->createView();
$view = $column->createHeaderView($view);

$this->assertSame('My label', $view->label);
}

public function testAutoConfigurationDataProvider()
{
$object = new \stdClass();
Expand Down
26 changes: 26 additions & 0 deletions tests/Extension/Core/Type/DateTimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@

class DateTimeTypeTest extends BaseTypeTest
{
public function testPassLabelToView()
{
$column = $this->factory->createColumn(
'id',
$this->getTestedType(),
[
'label' => 'My label',
'data_provider' => function ($data) {
return $data->key;
},
]
);

$datagrid = $this->factory->createDatagrid('grid', [$column]);

$object = new \stdClass();
$object->key = new \DateTime();

$datagrid->setData([1 => $object]);

$view = $datagrid->createView();
$view = $column->createHeaderView($view);

$this->assertSame('My label', $view->label);
}

protected function getTestedType()
{
return DateTimeType::class;
Expand Down
66 changes: 56 additions & 10 deletions tests/Extension/Core/Type/MoneyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ protected function setUp()
parent::setUp();
}

public function testPassLabelToView()
{
$column = $this->factory->createColumn(
'id',
$this->getTestedType(),
[
'label' => 'My label',
'data_provider' => function ($data) {
return $data->key;
},
]
);

$datagrid = $this->factory->createDatagrid('grid', [$column]);

$object = new \stdClass();
$object->key = '20.00';

$datagrid->setData([1 => $object]);

$view = $datagrid->createView();
$view = $column->createHeaderView($view);

$this->assertSame('My label', $view->label);
}

public function testEURWithUS()
{
\Locale::setDefault('en_US');
Expand Down Expand Up @@ -62,13 +88,15 @@ public function testForDifferentCurrencies()
$column = $this->factory->createColumn('price', $this->getTestedType(), ['currency' => 'EUR']);
$column2 = $this->factory->createColumn('price2', $this->getTestedType(), ['currency' => 'GBP']);

$datagrid = $this->factory->createDatagrid('grid', [$column, $column2]);

$object = new \stdClass();
$object->price = '1.23';
$object->price2 = '1.23';
$data = [1 => $object];

$this->datagrid->setData($data);
$datagridView = $this->datagrid->createView();
$datagrid->setData($data);
$datagridView = $datagrid->createView();

$view = $column->createCellView($datagridView, $data[1], 1);
$this->assertSame('1,23 €', $view->value);
Expand All @@ -82,28 +110,46 @@ public function testDifferentCurrencyByMapping()
\Locale::setDefault('de_DE');

$column = $this->factory->createColumn('price', $this->getTestedType(), ['currency' => 'EUR']);
$column2 = $this->factory->createColumn('price2', $this->getTestedType(), ['input_field' => 'price2', 'currency_field' => 'currency']);
$column2 = $this->factory->createColumn(
'price2',
$this->getTestedType(),
[
'input_field' => 'price2',
'currency_field' => 'currency',
'data_provider' => function ($value) {
return (array) $value;
},
]
);

$datagrid = $this->factory->createDatagrid('grid', [$column, $column2]);

$object = new \stdClass();
$object->price = '1.23';
$object->price2 = '1.23';
$object->currency = 'GBP';
$data = [1 => $object];
$object->currency = null;

$this->datagrid->setData($data);
$datagridView = $this->datagrid->createView();
$object2 = new \stdClass();
$object2->price = '1.23';
$object2->price2 = '1.23';
$object2->currency = 'GBP';

$data = [1 => $object, 2 => $object2];

$datagrid->setData($data);
$datagridView = $datagrid->createView();

$view = $column->createCellView($datagridView, $data[1], 1);
$this->assertSame('1,23 €', $view->value);

$view = $column2->createCellView($datagridView, $data[1], 1);
$view = $column2->createCellView($datagridView, $data[2], 1);
$this->assertSame('1,23 £', $view->value);
}

public function testPrecision()
{
// Note changing the precision does not work nl and en_US
// I'm unable to find the cause, please provide a fix you have one
// Note changing the precision does not work for nl and en_US
// I'm unable to find the cause, please provide a fix if you have one - Sebastiaan Stok (@sstok)
\Locale::setDefault('de_DE');

$this->assertCellValueEquals('1,2355 €', '1.2355', ['currency' => 'EUR', 'precision' => 4]);
Expand Down

0 comments on commit 509250a

Please sign in to comment.