From bf99ad6dba0a92bb51fec87ba0c0001931a020f2 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 10:43:19 -0500 Subject: [PATCH 01/41] Use Github workflows for automated testing --- .github/workflows/phpunit.yml | 50 +++++ .travis.yml | 45 ---- CHANGELOG.md | 384 ---------------------------------- README.md | 29 ++- Tests/autoload.php.dist | 6 - Tests/bootstrap.php | 7 - UPGRADE-2.0.md | 125 ----------- composer.json | 3 +- php_cs.dist | 91 -------- phpunit.xml.dist | 37 ++-- 10 files changed, 84 insertions(+), 693 deletions(-) create mode 100644 .github/workflows/phpunit.yml delete mode 100644 .travis.yml delete mode 100644 CHANGELOG.md delete mode 100644 Tests/autoload.php.dist delete mode 100644 Tests/bootstrap.php delete mode 100644 UPGRADE-2.0.md delete mode 100644 php_cs.dist diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 00000000..65ba6431 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,50 @@ +name: Tests + +on: + push: + pull_request: + +defaults: + run: + shell: bash + +jobs: + test: + runs-on: ubuntu-20.04 + + strategy: + matrix: + php: ['7.4', '8.0', '8.1'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php }}' + coverage: 'none' + + - name: Display versions + run: | + php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;' + php -i + + - name: Validate composer.json + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ matrix.php }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run test suite + run: vendor/bin/phpunit --verbose diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 84b24eaa..00000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: php - -php: - - 7.3 - - 7.4 - -matrix: - include: - - php: 7.3 - env: SYMFONY_VERSION=^4.4 - - php: 7.3 - env: SYMFONY_VERSION=^5.2 - - php: 7.4 - env: SYMFONY_VERSION=^4.4 - - php: 7.4 - env: SYMFONY_VERSION=^5.2 - -before_install: - - echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - - | - if [ "${SYMFONY_VERSION}" != "" ]; then - packages="form dependency-injection config http-foundation http-kernel options-resolver security-guard serializer" - devpackages="framework-bundle browser-kit templating expression-language" - for package in $packages - do - composer require --no-update symfony/"$package"=${SYMFONY_VERSION}; - done - for package in $devpackages - do - composer require --dev --no-update symfony/"$package"=${SYMFONY_VERSION}; - done - fi; - -install: - - travis_retry composer self-update - - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update ${COMPOSER_FLAGS} --no-interaction - - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev --no-interaction - -script: - - mkdir -p build/logs - - php vendor/bin/phpunit -c phpunit.xml.dist - -after_success: - - php vendor/bin/php-coveralls diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 62be18d3..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,384 +0,0 @@ -CHANGELOG -========= - -2.3 (WIP) ---------- - -### New feature - -* Add `GridBuilder`, `GridConfig` and `GridFactory` to make easier the grid constructor. -* Add `GridType`, `GridRegistry` for build the grid in a separate class, which can then be reused. - -### Bugfix - -- Fix #739 - Fix filters with undefined index error - -2.2 or earlier --------------- - -`14 October 2012` - - * Don't redirect with an AJAX request - -`13 October 2012` - - * Fix bug - Fixed errors with default values in Column __initialize. - * Add escape option for the value of a cell - -`7 October 2012` - - * Fix bug - Fix file Content-Length calculation for export. - -`2 October 2012` - - * Fix bug - Fix field name in DQL for multi level entities - -`21 September 2012` - - * Fix bug - Wrong regex for the eq operator for the vector source and the setData function - * Fix bug - Fix excpetion in ArrayColumn class - * Add pagerfanta to the configuration - * Add a columns order function - -`7 September 2012` - - * Fix #241 - Numeric and boolean filter don't work with Vector source and setData function - * Fix #224 - Fix wrong default junction with multi select feature - * Fix #239 - Fix complexes alias names conflict - * Add #242 feature - Checkbox and radio filter with select filter and selectExpanded=true - * Fix bug - Fix one of the problems of #181 - * Add #244 helper - Grid data to array - * Add DQL function support with non mapped fields - -`4 September 2012` - - * Fix #237 - Add distinct support for DQL aggregate function - * Add abbrevation support with __abbr in translation file - * Fix #236 See https://bugs.php.net/bug.php?id=62464 - -`27 August 2012` - - * Fix #229 - Fix pagerfanta with PHP < 5.4 - -`18 August 2012` - - * Fix #227 - Bug with annotations config groups - -`17 August 2012` - - * Add role control on massAction, rowAction and Export - * Fix bug : grid not found when you export a grid with an searchOnClick column - * Fix persistence with basic authentification - -`14 August 2012` - - * Add grid data conjunction setting - * Fix bug : wrong convert charset for exports - -`9 August 2012` - - * Fix datetime select filter - -`8 August 2012` - - * Add the default size and separator default config - -`31 July 2012` - - * Fix javascript event for IE - * Fix Regular expresion for vector source and setData - -`31 July 2012` - - * Fix data junction for vector source and setData - -`17 July 2012` - - * Add multi select feature - -`15 July 2012` - - * Add default limit (item per page) feature - * Fix total count for vector source and setData - -`12 July 2012` - - * Trim export values - -`10 July 2012` - - * Allow a default order on a non sortable column. - -`7 July 2012` - - * Fix addRouteParameters and manage mapped fields in routeParameters of a rowAction - -`5 July 2012` - - * Fix bug - Manage array values for select populated filter - -`4 July 2012` - - * Add searchOnClick parameter to Column class - -`3 July 2012` - - * Add ajax loading with jquery - * Update composer requirements (Twig >= 1.5.0) - * Lower case the order in Grid::setDefaultOrder - * Add default configuration for no data and no result messages - -`2 July 2012` - - * Fix bug - Blocks are not found with the `_self` template for an export - -`1 July 2012` - - * Fix bug - Don't save empty session! - -`30 Jun 2012` - - * Add configuration files for tests - * Add travis-ci support - -`29 Jun 2012` - - * Add default configuration for limits and persistence - * Fix bug - Fix the guess of a datetime column in vector source - -`28 Jun 2012` - - * Explode grid_pager block into three blocks - * Fix bug - Fix persistence with order and pager - -`27 Jun 2012` - - * Manage empty data with a vector source - * Add a default columns parameters for the vector source - * Update vector source documentation - * Fix bug - Write data to the session when a null operator is selected - -`26 Jun 2012` - - * [Bundle] Push the actuel master branch into the new 2.0 branch and tag. The master branch is now the version 2.1 of this bundle - -**New in 2.1:** No BC Break - - * Rework grid = Lazy loading of all parameters. Every parameters can be set after the source and the code is more understandable - * Fix bug - Fix false values in twig with symfony 2.1 - -`23 Jun 2012` - - * Fix bug - Array values are already unserialized with the new doctrine in Symfony 2.1 - -`20 Jun 2012` - - * Fix bug - Issue with mapped fields on two or more levels - -`19 Jun 2012` - - * Add pagerfanta pager + doc - * Add a blank column - * Allow massaction without selected rows - * Fix bug - Reset templates array when you call a grid - -`18 Jun 2012` - - * Fix bug - Don't show filters row with only massaction and actions column - -`17 Jun 2012` - - * Fix bug - Filterable attribute from a source annotation doesn't work - * Don't show a mapped field column if it has not been defined with a column annotation - * Fix #144 - * Move the checkbox of massaction from the filters row to the titles row - * Add the reset filters feature (#36) - * Add a reset button in the massaction column of the filters row - * Add a reset link in the actions column of the filters row - * Add a reset button in the grid search box - * Update screenshots - * [BC Break] Pass the grid object to the cell and filter blocks instead of the hash of the grid - * Add number of total results - -`16 Jun 2012` - - * [Bundle] Push the actuel master branch into the new 1.0 branch. The master branch is now the version 2.0 of this bundle - -**New in 2.0:** See [UPGRADE-2.0](UPGRADE-2.0.md) documentation. - - * [BC Break][Bundle] Change the namespace of the bundle - * [BC Break][Filters] Add operator selector feature with a default operator - * [Filters] Add operators Equals, Not equal to, Lower than, Lower than or equal to, Greater than, Greater than or equal to, Between exclusive, Between inclusive, Contains, Not contains, Starts with, Ends with, Is not defined, Is defined - * [Filters] Add annotation and php support for the operator selector feature and for the default operator - * [BC Break][Columns] Remove range, select and sourceselect columns (Include now in all columns with the filter attribute) - * [Annotations][Filters] Add an attribute to define the type of the filter (input, select) - * [Select filter] Populate select filters from the query result or the source - * [Annotations][Select filter] Add an attribute to define the source values of the select filter (From values, the source or the query) - * [Annotations][Filters] Add range feature implemented in input and select filter type with the operators between. - * [BC Break][Grid::initFilter] Grid::initFilter rename to setDefaultFilters - * [BC Break][Grid::initOrder] Grid::initOrder rename to setDefaultOrder - * [Columns] Add a way to change the data junction of the filters of a column - * [Mass action] Add templates for massaction filter and cell - * [Mass action] Add additional parameters passed to the callback - * [Columns] Add number column (decimal, money, percent, duration, scientific, spell out) - * [Export] Add export feature - * [Export] Add DSV, CSV, SCSV, TSV, XML, Excel (with PHPExcel library) and html (with PHPExcel library) exports - * [Grid::setLimits] Add support for a simple array to define limits (e.g. $grid->setLimits(5, 10);) - * [BC Break][Sources] Source::setCallBack rename to manipulateRow and manipulateQuery and the first argument is removed - * [BC Break][Columns] Column::setCallBack rename to manipulateRenderCell - * [Row action] Add addRouteParameters method on rowAction class - * [Row action] rowAction::setRouteParameters allows string - * [BC Break][Grid::gridResponse] Grid::gridResponse rename to Grid::getGridResponse - * [BC Break][Grid::gridManagerResponse] GridManager::gridManagerResponse rename to GridManager::getGridManagerResponse - * [Grid::getGridResponse] The view parameters and the view name in Grid::getGridResponse can be set in reverse order to match the Template::render function - * [Grid::getGridResponse] Add array('grid' => $grid) automatically in view parameters with Grid::getGridResponse - * [Grid::getGridManagerResponse] GridManager::getGridManagerResponse can be set in reverse order to match the Template::render function. - * [Grid::getGridManagerResponse] Add array('grid1' => $grid1, 'grid2' => $grid2, ...) automatically in view parameters with GridManager::getGridManagerResponse - * [DQL Functions] Manage a simple parameter for dql aggregate functions (e.g. vars.var:CountIf:3) - * [Entity source] Implement setMaxResults feature - * [Document source] Implement setMaxResults feature - * [Document source] Add all filters with operators - * [Document source] Add populate select filters feature - * [Vector source] Implement setMaxResults feature - * [Vector source] Add guess typing - * [Vector source] Add all filters with operators - * [Vector source] Add guess type sorting - * [Vector source] Add populate select filters feature - * [Grid::setData] Implement setMaxResults feature - * [Grid::setData] Add all filters with operators - * [Grid::setData] Add guess type sorting - * [Grid::setData] Add populate select filters feature - * [Template] Add some css classes - * [Template] Show 'false' in the grid if value === false in boolean column because a false value isn't show in twig) - * [Template] Add width attribute on filter th tag too - * [ActionsColumn] Add the method Grid::setActionsColumnSize to set the size of the actions column - * [ActionsColumn] Add the method Grid::setActionsColumnSeparator to set the separator of the actions column - * [Filter] Disallow url filtering if the column is not filterable - * [Sort] Disallow url sorting if the column is not sortable - * [Limit] Disallow url limit if the value is not in the limits selector - * [Bundle] Update composer - * [Bundle] Clean and optimize code - * [Bundle] Follow Code Standard of Symfony2 - * [Docs] Rework the whole documentation with the new features - -`25 May 2012` - - * Fix bug - XMLHttpRequest force the persistence mode - -`15 May 2012` - - * Allow using controllers as services in mass actions (lstrojny) - * Optimize total count query on entity source - -`13 May 2012` - - * Add DateTimeRange and DateRange column - * Add DateTime and Date column - * Add parentType search for cell render - -`8 May 2012` - - * Nothing private! - -`7 May 2012` - - * Fix bug - Templates are not reset for each grid displayed - * Fix bug - Count of selected visible rows when filters are displayed - * Fix bug - params not initialised to an empty array in twig extension - * Fix bug - Pager not visible when only one limit is defined - * Fix bug - Set false to the filterable attribute of an ActionColumn - * Add a way to pass attributes to RowActions - * Add odd/even css class in tr tags - -`5 May 2012` - - * Allow extended Grid class - -`3 May 2012` - - * Add groupBy support on Source annotation - -`2 May 2012` - - * Don't throw no data message when the grid is filtered - * If noDataMessage = false, the grid is display empty with the noResultMessage - * Add a no result message when a filtered grid has no result - * Add last-column and last-row classes because the css :last-child isn't support by IE7 - * Fix input page setter (Doesn't work when you have a form before the grid) - * Set to the first page if this is an order, limit, mass action or filter request - -`1 May 2012` - - * [BC Break] Show a message instead of an empty grid - * Add a way to pass twig variables to override blocks - -`30 Apr 2012` - - * Add array Column for Entity sources - * Fix createHash when you define a id for the grid - * [BC BREAK] Don't use previous data if the client leave the page during the session. You can turn on the persistence if you want the opposite. - * Fix initFilters method - * Add initOrder method - * Add show and hide columns methods - * Fix render bloc ids and manipulate row field ids with mapping fields. - -`29 Apr 2012` - - * Add Vector source - * Add visible columns mask Helpers - * Add support for additionnal route parameters on row actions - -`23 Apr 2012` - - * Add groups support in annotation + doc - -`21 Apr 2012` - - * Improve configuration doc - * Set the default title of an associated field - * Add support for multi columns on the same JoinColumn property + doc - * Add groupBy feature with aggregate dql functions support in mapping association + doc - -`20 Apr 2012` - - * add initFilters feature - * fix custom actions column - * fix exception not found with setData on the grid - -`13 Apr 2012` - - * japanese translations - -`12 Apr 2012` - - * applying filter now reloads grid to first page - * new SourceSelect column type - -`9 Apr 2012` - - * fix broken confirmation message - * polish translations - -`8 Apr 2012` - - * as far as symfony 2.0 lacks of some important features and 2.1dev is heavily unstable with too many changes every day (which causes too many problems form my company) i've decided to stop using symfony2 for my future projects it basically means that i'll no longer support this bundle, Abhoryo and nurikabe have rights to merge any PR for this bundle - -`20 Oct 2011` - - * new param for column called `role` * column is visible only when access is granted by security.context - * removed column->hide() and column->show() and added column->isVisible() and column->setVisible(bool) - -`19 Oct 2011` - - * when rendering template calling `prepare` function is not needed - * removed custom route for filtering and ordering grid columns - * added events to modify source data query building and data hydration - * added column->setAlign('left/right/center') - * support relations in Entity source - * support custom mapping divers - * form type guesser from Source column - * own columns can be added by annotations - * possible registrations of custom column types in container * look at Resources/Config/services - * grid need to be created as service - * annotations - * ODM support diff --git a/README.md b/README.md index 5c63a565..b55bc0f7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,6 @@ -Datagrid for Symfony inspired by Zfdatagrid and Magento Grid. -This bundle was initiated by Stanislav Turza (Sorien). - -[![Build Status](https://secure.travis-ci.org/northernco/NorthernDataGridBundle.png?branch=master)](http://travis-ci.org/northernco/NorthernDataGridBundle) -[![Coverage Status](https://coveralls.io/repos/github/northernco/NorthernDataGridBundle/badge.svg?branch=test-improvement)](https://coveralls.io/github/northernco/NorthernDataGridBundle?branch=test-improvement) -[![Stories in Ready](https://badge.waffle.io/northernco/NorthernDataGridBundle.svg?label=ready&title=Ready)](http://waffle.io/northernco/NorthernDataGridBundle) -[![Gitter](https://badges.gitter.im/northernco/NorthernDataGridBundle.svg)](https://gitter.im/northernco/NorthernDataGridBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +Datagrid for Symfony inspired by Zfdatagrid and Magento Grid. -See [CHANGELOG](https://github.com/northernco/NorthernDataGridBundle/blob/master/CHANGELOG.md) and [UPGRADE 2.0](https://github.com/northernco/NorthernDataGridBundle/blob/master/UPGRADE-2.0.md) +This bundle was initiated by Stanislav Turza (Sorien). ## Features @@ -34,30 +28,31 @@ See [CHANGELOG](https://github.com/northernco/NorthernDataGridBundle/blob/master ## Documentation -See the [summary](https://github.com/northernco/NorthernDataGridBundle/blob/master/Resources/doc/summary.md). +See the [summary](https://github.com/northernco/NorthernDataGridBundle/blob/v5.0/Resources/doc/summary.md). ## Screenshot -Full example with this [CSS style file](https://github.com/northernco/NorthernDataGridBundle/blob/master/Resources/doc/grid_configuration/working_example.css): +Full example with this [CSS style file](https://github.com/northernco/NorthernDataGridBundle/blob/v5.0/Resources/doc/grid_configuration/working_example.css): -![test](https://github.com/northernco/NorthernDataGridBundle/blob/master/Resources/doc/images/screenshot_full.png?raw=true) +![test](https://github.com/northernco/NorthernDataGridBundle/blob/v5.0/Resources/doc/images/screenshot_full.png?raw=true) Simple example with the external filter box in english: -![test](https://github.com/northernco/NorthernDataGridBundle/blob/master/Resources/doc/images/screenshot_en.png?raw=true) +![test](https://github.com/northernco/NorthernDataGridBundle/blob/v5.0/Resources/doc/images/screenshot_en.png?raw=true) Same example in french: -![test](https://github.com/northernco/NorthernDataGridBundle/blob/master/Resources/doc/images/screenshot_fr.png?raw=true) +![test](https://github.com/northernco/NorthernDataGridBundle/blob/v5.0/Resources/doc/images/screenshot_fr.png?raw=true) Data used in these screenshots (this is a phpMyAdmin screenshot): -![test](https://github.com/northernco/NorthernDataGridBundle/blob/master/Resources/doc/images/screenshot_database.png?raw=true) +![test](https://github.com/northernco/NorthernDataGridBundle/blob/v5.0/Resources/doc/images/screenshot_database.png?raw=true) ## Simple grid with an ORM source ```php __DIR__.'/../vendor/bundles',` -After: `'APY' => __DIR__.'/../vendor/bundles',` - -Then in your files change all your `APY` use statements to `APY` - -Change your include block template. - -Before: `SorienDataGridBundle::blocks.html.twig` -After: `'@APYDataGrid/blocks.html.twig` - -Example: - -Before: `use Sorien\DataGridBundle\Grid\Source\Entity;` -After: `use APY\DataGridBundle\Grid\Source\Entity;` - -You call safely replace all `Sorien` occurences by `APY`. - -## New columns types and filters in annotations - -The version 1.0 desn't know the type of the data for the select, sourceselect and range columns. -In 2.0, these columns don't exist because they are not types of data, but types of filter. - -#### Select columns - -Before: `@Grid\Column(type="select", values={"type1"="Type 1", "type2"="Type 2"})` -After: `@Grid\Column(type="text", filter="select", selectFrom="values", values={"type1"="Type 1", "type2"="Type 2"})` - -See [annotation type attribute](https://github.com/Abhoryo/APYDataGridBundle/blob/master/Resources/doc/columns_configuration/annotations/column_annotation_property.md) for others types. - -#### SourceSelect columns - -Before: `@Grid\Column(type="sourceselect")` -After: `@Grid\Column(type="text", filter="select", selectFrom="source")` OR `@Grid\Column(type="text", filter="select", selectFrom="query")` - -In 2.0, you don't have to declare a repository method `findDistinctByField($field)` to get your values for the selector. - -* `query` means that the selectors of the select filter will be populated by the values found in the current search. If no result is found, they will be populated with all values found in the source. - -* `source` means that the selectors of the select filter will be populated by all values found in the source. - -#### Range, DateTimeRange and DateRange columns - -In 2.0, a operator selector is available. When you select one of the between operators, a new field appears. -A second input field appears if you have define `input` in the `filter` attribute. - -Before: `@Grid\Column(type="range")` -After: `@Grid\Column(type="text", filter="input")` OR `@Grid\Column(type="text", filter="select")` - -Before: `@Grid\Column(type="datetimerange")` -After: `@Grid\Column(type="datetime", filter="input")` OR `@Grid\Column(type="datetime", filter="select")` - -Before: `@Grid\Column(type="daterange")` -After: `@Grid\Column(type="date", filter="input")` OR `@Grid\Column(type="date", filter="select")` - -Range works for the type `number` too. - -`@Grid\Column(type="number", filter="input")` OR `@Grid\Column(type="number", filter="filter")` - -## Methods renamed - - * Source::setCallBack rename to manipulateRow and manipulateQuery - - Before: - - ``` - $source->setCallBack($source::EVENT_PREPARE_ROW, function ($row) {}); - $source->setCallBack($source::EVENT_PREPARE_QUERY, function ($row) {}); - ``` - - After: - - ``` - $source->manipulateRow(function ($row) {}); - $source->manipulateQuery(function ($row) {}); - ``` - - * Column::setCallBack rename to manipulateRenderCell - - Before: `$column->manipulateRenderCell(function ($value, $row, $router) {});` - After: `$column->manipulateRenderCell(function ($value, $row, $router) {});` - - * Grid::initFilter rename to setDefaultFilters - - Before: `$grid->initFilter(array());` - After: `$grid->setDefaultFilters(array());` - - * Grid::initOrder rename to setDefaultOrder - - Before: `$grid->initOrder($columnId, $order);` - After: `$grid->setDefaultOrder($columnId, $order);` - - * Grid::gridResponse rename to Grid::getGridResponse - - Before: `$grid->gridResponse();` - After: `$grid->getGridResponse();` - - * GridManager::gridManagerResponse rename to GridManager::getGridManagerResponse - - Before: `$grid->gridManagerResponse();` - After: `$grid->getGridManagerResponse();` - -## Set data on the source instead of the grid - -Before: `$grid->setData($array);` -After: `$source->setData($array);` - -## Pass the grid object to the cell and filter blocks instead of the hash of the grid - -Before: `{{ hash }}` -After: `{{ grid.hash }}` - -**And Clear your cache!** diff --git a/composer.json b/composer.json index f5f35475..01c84587 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "type": "symfony-bundle", "license": "MIT", "require": { - "php": ">=7.3", + "php": ">=7.4", "symfony/form": "^4.4|^5.2", "symfony/dependency-injection": "^4.4|^5.2", "symfony/config": "^4.4|^5.2", @@ -22,6 +22,7 @@ "symfony/browser-kit": "^4.4|^5.2", "symfony/templating": "^4.4|^5.2", "symfony/expression-language": "^4.4|^5.2", + "symfony/phpunit-bridge": "^4.4|^5.2", "phpunit/phpunit": "~5.7", "friendsofphp/php-cs-fixer": "^2.0", "php-coveralls/php-coveralls": "^2.0", diff --git a/php_cs.dist b/php_cs.dist deleted file mode 100644 index 73e99907..00000000 --- a/php_cs.dist +++ /dev/null @@ -1,91 +0,0 @@ -in([__DIR__]) - ->exclude('vendor') - ->name('*.php'); - -return Symfony\CS\Config\Config::create() - ->finder($finder) - ->setUsingCache(true) - ->fixers([ - // 'psr0', // [PSR-0] Classes must be in a path that matches their namespace, be at least one namespace deep, and the class name should match the file name. - - 'encoding', // [PSR-1] PHP code MUST use only UTF-8 without BOM (remove BOM). - 'short_tag', // [PSR-1] PHP code must use the long should not be arounded by multi-line whitespaces. - 'duplicate_semicolon', // [symfony] Remove duplicated semicolons. - 'empty_return', // [symfony] A return statement wishing to return nothing should be simply "return". - 'extra_empty_lines', // [symfony] Removes extra empty lines - 'function_typehint_space', - 'include', // [symfony] Include and file path should be divided with a single space. File path should not be placed under brackets. - 'join_function', // [symfony] Implode function should be used instead of join function. - 'list_commas', // [symfony] Remove trailing commas in list function calls. - 'multiline_array_trailing_comma', // [symfony] PHP multi-line arrays should have a trailing comma. - 'namespace_no_leading_whitespace', // [symfony] The namespace declaration line shouldn't contain leading whitespace. - // 'new_with_braces', // [symfony] All instances created with new keyword must be followed by braces. - 'no_blank_lines_after_class_opening', // [symfony] There should be no empty lines after class opening brace. - 'no_empty_lines_after_phpdocs', // [symfony] There should not be blank lines between docblock and the documented element. - 'object_operator', // [symfony] There should not be space before or after object T_OBJECT_OPERATOR. - 'operators_spaces', // [symfony] Binary operators should be arounded by at least one space. - 'phpdoc_indent', // [symfony] Docblocks should have the same indentation as the documented subject. - 'phpdoc_inline_tag', - 'phpdoc_no_access', // [symfony] @access annotations should be omitted from phpdocs. - 'phpdoc_no_empty_return', // [symfony] @return void and @return null annotations should be omitted from phpdocs. - 'phpdoc_no_package', // [symfony] @package and @subpackage annotations should be omitted from phpdocs. - 'phpdoc_params', // [symfony] All items of the @param, @throws, @return, @var, and @type phpdoc tags must be aligned vertically. - 'phpdoc_scalar', // [symfony] Scalar types should always be written in the same form. "int", not "integer"; "bool", not "boolean"; "float", not "real" or "double". - 'phpdoc_separation', // [symfony] Annotations in phpdocs should be grouped together so that annotations of the same type immediately follow each other, and annotations of a different type are separated by a single blank line. - 'phpdoc_short_description', // [symfony] Phpdocs short descriptions should end in either a full stop, exclamation mark, or question mark. - 'phpdoc_to_comment', // [symfony] Docblocks should only be used on structural elements. - 'phpdoc_trim', // [symfony] Phpdocs should start and end with content, excluding the very first and last line of the docblocks. - 'phpdoc_type_to_var', // [symfony] @type should always be written as @var. - 'phpdoc_var_without_name', // [symfony] @var and @type annotations should not contain the variable name. - 'pre_increment', // [symfony] Pre incrementation/decrementation should be used if possible. - 'remove_leading_slash_use', // [symfony] Remove leading slashes in use clauses. - 'remove_lines_between_uses', // [symfony] Removes line breaks between use statements. - 'return', // [symfony] An empty line feed should precede a return statement. - 'self_accessor', // [symfony] Inside a classy element "self" should be preferred to the class name itself. - //'single_array_no_trailing_comma', // [symfony] PHP single-line arrays should not have trailing comma. - 'single_blank_line_before_namespace', // [symfony] There should be exactly one blank line before a namespace declaration. - 'single_quote', // [symfony] Convert double quotes to single quotes for simple strings. - 'spaces_before_semicolon', // [symfony] Single-line whitespace before closing semicolon are prohibited. - 'spaces_cast', // [symfony] A single space should be between cast and variable. - 'standardize_not_equal', // [symfony] Replace all <> with !=. - 'ternary_spaces', // [symfony] Standardize spaces around ternary operator. - 'trim_array_spaces', // [symfony] Arrays should be formatted like function/method arguments, without leading or trailing single line space. - // 'unalign_double_arrow', // [symfony] Unalign double arrow symbols. - 'unalign_equals', // [symfony] Unalign equals symbols. - 'unneeded_control_parentheses', - 'unary_operators_spaces', // [symfony] Unary operators should be placed adjacent to their operands. - 'unused_use', // [symfony] Unused use statements must be removed. - 'whitespacy_lines', // [symfony] Remove trailing whitespace at the end of blank lines. - - 'concat_with_spaces', - 'align_double_arrow', - 'multiline_spaces_before_semicolon', - 'ordered_use', - 'phpdoc_order', - 'short_array_syntax', - ]); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a12d102f..0c004fcc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,22 +1,25 @@ - + + + + + + + - - ./Tests + Tests - - - ./ - - ./Resources - ./Tests - ./vendor - - - - - - - \ No newline at end of file + + + + + From 28c817de0a0449d0483fa80651ee86b69e8f0dd6 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 10:47:03 -0500 Subject: [PATCH 02/41] Only allow php 7.4 for testing --- .github/workflows/phpunit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 65ba6431..8855b076 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -14,7 +14,8 @@ jobs: strategy: matrix: - php: ['7.4', '8.0', '8.1'] +# php: ['7.4', '8.0', '8.1'] + php: ['7.4'] steps: - name: Checkout From ac6515e7e1d40bb368bed35a643b7e0247d74a48 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 11:26:35 -0500 Subject: [PATCH 03/41] Update tests --- Tests/Grid/Column/TextColumnTest.php | 4 +- Tests/Grid/GridBuilderTest.php | 79 ++++++++------- Tests/Grid/GridFactoryTest.php | 3 + Tests/Grid/GridManagerTest.php | 1 - Tests/Grid/GridTest.php | 144 ++++++++++++++------------- Tests/Grid/Source/DocumentTest.php | 2 +- Tests/Twig/DataGridExtensionTest.php | 2 +- Twig/DataGridExtension.php | 68 ++++++------- 8 files changed, 155 insertions(+), 148 deletions(-) diff --git a/Tests/Grid/Column/TextColumnTest.php b/Tests/Grid/Column/TextColumnTest.php index 8608bb49..6940f952 100644 --- a/Tests/Grid/Column/TextColumnTest.php +++ b/Tests/Grid/Column/TextColumnTest.php @@ -5,9 +5,9 @@ use APY\DataGridBundle\Grid\Column\Column; use APY\DataGridBundle\Grid\Column\TextColumn; use APY\DataGridBundle\Grid\Filter; -use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -class TextColumnTest extends TestCase +class TextColumnTest extends WebTestCase { /** @var TextColumn */ private $column; diff --git a/Tests/Grid/GridBuilderTest.php b/Tests/Grid/GridBuilderTest.php index c8a9d67c..b9463b35 100755 --- a/Tests/Grid/GridBuilderTest.php +++ b/Tests/Grid/GridBuilderTest.php @@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -35,6 +36,46 @@ class GridBuilderTest extends TestCase */ private $builder; + /** + * {@inheritdoc} + */ + protected function setUp() + { + $self = $this; + + $this->container = $this->createMock(Container::class); + $this->container->expects($this->any()) + ->method('get') + ->will($this->returnCallback(function ($param) use ($self) { + switch ($param) { + case 'router': + return $self->createMock(RouterInterface::class); + break; + case 'request_stack': + $request = new Request([], [], ['key' => 'value']); + $session = new Session(); + $request->setSession($session); + $requestStack = new RequestStack(); + $requestStack->push($request); + + return $requestStack; + break; + case 'security.authorization_checker': + return $self->createMock(AuthorizationCheckerInterface::class); + break; + } + })); + + $this->factory = $this->createMock(GridFactoryInterface::class); + $this->builder = new GridBuilder($this->container, $this->factory, 'name'); + } + + protected function tearDown() + { + $this->factory = null; + $this->builder = null; + } + public function testAddUnexpectedType() { $this->expectException(UnexpectedTypeException::class); @@ -139,42 +180,4 @@ public function testGetGrid() { $this->assertInstanceOf(Grid::class, $this->builder->getGrid()); } - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $self = $this; - - $this->container = $this->createMock(Container::class); - $this->container->expects($this->any()) - ->method('get') - ->will($this->returnCallback(function ($param) use ($self) { - switch ($param) { - case 'router': - return $self->createMock(RouterInterface::class); - break; - case 'request_stack': - $request = new Request([], [], ['key' => 'value']); - $requestStack = new RequestStack(); - $requestStack->push($request); - - return $requestStack; - break; - case 'security.authorization_checker': - return $self->createMock(AuthorizationCheckerInterface::class); - break; - } - })); - - $this->factory = $this->createMock(GridFactoryInterface::class); - $this->builder = new GridBuilder($this->container, $this->factory, 'name'); - } - - protected function tearDown() - { - $this->factory = null; - $this->builder = null; - } } diff --git a/Tests/Grid/GridFactoryTest.php b/Tests/Grid/GridFactoryTest.php index 399309ae..b6518d72 100755 --- a/Tests/Grid/GridFactoryTest.php +++ b/Tests/Grid/GridFactoryTest.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -172,6 +173,8 @@ protected function setUp() break; case 'request_stack': $request = new Request([], [], ['key' => 'value']); + $session = new Session(); + $request->setSession($session); $requestStack = new RequestStack(); $requestStack->push($request); diff --git a/Tests/Grid/GridManagerTest.php b/Tests/Grid/GridManagerTest.php index 3392fa5a..41ee7666 100644 --- a/Tests/Grid/GridManagerTest.php +++ b/Tests/Grid/GridManagerTest.php @@ -7,7 +7,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\BrowserKit\Response; use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpFoundation\RedirectResponse; use Twig\Environment; class GridManagerTest extends TestCase diff --git a/Tests/Grid/GridTest.php b/Tests/Grid/GridTest.php index bab15010..930c4143 100644 --- a/Tests/Grid/GridTest.php +++ b/Tests/Grid/GridTest.php @@ -31,6 +31,7 @@ use Symfony\Component\Routing\Router; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Twig\Environment; +use Twig\TemplateWrapper; class GridTest extends TestCase { @@ -734,47 +735,44 @@ public function testGetRowActions() $this->assertEquals([$colId => [$rowAction]], $this->grid->getRowActions()); } - /** - * FIXME: Restore this test with Symfony 5 update - */ - // public function testSetExportTwigTemplateInstance() - // { - // $templateName = 'templateName'; - // - // $template = $this - // ->getMockBuilder(\Twig\TemplateWrapper::class) - // ->disableOriginalConstructor() - // ->getMock(); - // $template - // ->method('getTemplateName') - // ->willReturn($templateName); - // - // $result = '__SELF__' . $templateName; - // - // $this - // ->session - // ->expects($this->once()) - // ->method('set') - // ->with($this->anything(), [Grid::REQUEST_QUERY_TEMPLATE => $result]); - // - // $this->grid->setTemplate($template); - // } + public function testSetExportTwigTemplateInstance() + { + $templateName = 'templateName'; - /** - * FIXME: Restore this test with Symfony 5 update - */ - // public function testSetExportStringTemplate() - // { - // $template = 'templateString'; - // - // $this - // ->session - // ->expects($this->once()) - // ->method('set') - // ->with($this->anything(), [Grid::REQUEST_QUERY_TEMPLATE => $template]); - // - // $this->grid->setTemplate($template); - // } + $template = $this + ->getMockBuilder(TemplateWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + $template + ->method('getTemplateName') + ->willReturn($templateName); + + $result = '__SELF__' . $templateName; + + $this + ->session + ->expects($this->once()) + ->method('set') + ->with($this->anything(), [Grid::REQUEST_QUERY_TEMPLATE => $result]); + + $this->grid->setTemplate($template); + } + + public function testSetExportStringTemplate() + { + $template = 'templateString'; + + $this + ->session + ->expects($this->once()) + ->method('set') + ->with($this->anything(), [Grid::REQUEST_QUERY_TEMPLATE => $template]); + + $this->arrangeGridSourceDataLoadedWithEmptyRows(); + $this->arrangeGridPrimaryColumn(); + $this->grid->handleRequest($this->request); + $this->grid->setTemplate($template); + } public function testRaiseExceptionIfSetTemplateWithNoValidValue() { @@ -801,27 +799,24 @@ public function testSetExportNullTemplate() $this->grid->setTemplate(null); } - /** - * FIXME: Restore this test with Symfony 5 update - */ - // public function testReturnTwigTemplate() - // { - // $templateName = 'templateName'; - // - // $template = $this - // ->getMockBuilder(\Twig\TemplateWrapper::class) - // ->disableOriginalConstructor() - // ->getMock(); - // $template - // ->method('getTemplateName') - // ->willReturn($templateName); - // - // $result = '__SELF__' . $templateName; - // - // $this->grid->setTemplate($template); - // - // $this->assertEquals($result, $this->grid->getTemplate()); - // } + public function testReturnTwigTemplate() + { + $templateName = 'templateName'; + + $template = $this + ->getMockBuilder(TemplateWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + $template + ->method('getTemplateName') + ->willReturn($templateName); + + $result = '__SELF__' . $templateName; + + $this->grid->setTemplate($template); + + $this->assertEquals($result, $this->grid->getTemplate()); + } public function testReturnStringTemplate() { @@ -2602,6 +2597,9 @@ public function testRaiseExceptionIfGetNonExistentTweak() $tweakId = 'aValidTweakId'; $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; + $routeUrl = 'https://www.foo.com'; + $this->grid->setRouteUrl($routeUrl); + $this->grid->addTweak('title', $tweak, $tweakId, 'group'); $this->grid->getTweak($nonExistentTweak); @@ -2612,8 +2610,12 @@ public function testGetTweak() $title = 'aTweak'; $id = 'aValidTweakId'; $group = 'tweakGroup'; + + $routeUrl = 'http://www.foo.com'; + $this->grid->setRouteUrl($routeUrl); + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; - $tweakUrl = sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); + $tweakUrl = $routeUrl . sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); $this->grid->addTweak($title, $tweak, $id, $group); @@ -2627,8 +2629,12 @@ public function testGetTweaksByGroupExcludingThoseWhoDoNotHaveTheGroup() $title = 'aTweak'; $id = 'aValidTweakId'; $group = 'tweakGroup'; + + $routeUrl = 'http://www.foo.com'; + $this->grid->setRouteUrl($routeUrl); + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; - $tweakUrl = sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); + $tweakUrl = $routeUrl . sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); $tweakResult = [$id => array_merge(['title' => $title, 'id' => $id, 'group' => $group, 'url' => $tweakUrl], $tweak)]; $this->grid->addTweak($title, $tweak, $id, $group); @@ -3681,7 +3687,7 @@ public function testSetDefaultSessionFiltersIfSessionDataXmlHttpRequestAndNotExp $col5From = 'foo'; $col5To = 'bar'; - list($column1, $column2, $column3, $column4, $column5) = $this->arrangeColumnsFilters( + [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, $col2Id, $col3Id, @@ -3764,7 +3770,7 @@ public function testNotSetDefaultSessionFiltersIfHasRequestDataNotXmlHttpButExpo $col5From = 'foo'; $col5To = 'bar'; - list($column1, $column2, $column3, $column4, $column5) = $this->arrangeColumnsFilters( + [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, $col2Id, $col3Id, @@ -3834,7 +3840,7 @@ public function testNotSetDefaultSessionFiltersIfHasRequestDataNotXmlHttpAndNotE $col5From = 'foo'; $col5To = 'bar'; - list($column1, $column2, $column3, $column4, $column5) = $this->arrangeColumnsFilters( + [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, $col2Id, $col3Id, @@ -4265,7 +4271,7 @@ public function testProcessDefaultTweaksIfNotRequestDataDuringRedirect() $this->arrangeGridSourceDataLoadedWithEmptyRows(); $this->arrangeGridPrimaryColumn(); - list($group, $tweakId) = $this->arrangeDefaultTweaks(1); + [$group, $tweakId] = $this->arrangeDefaultTweaks(1); $this ->session @@ -4282,7 +4288,7 @@ public function testProcessDefaultTweaksIfRequestDataXmlHttpRequestAndNotExportD $this->arrangeGridPrimaryColumn(); $tweakPage = 1; - list($group, $tweakId) = $this->arrangeDefaultTweaks($tweakPage); + [$group, $tweakId] = $this->arrangeDefaultTweaks($tweakPage); $requestPage = 2; $this @@ -5599,7 +5605,7 @@ private function mockDefaultSessionFiltersWithoutRequestData() $col5From = 'foo'; $col5To = 'bar'; - list($column1, $column2, $column3, $column4, $column5) = $this->arrangeColumnsFilters( + [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, $col2Id, $col3Id, diff --git a/Tests/Grid/Source/DocumentTest.php b/Tests/Grid/Source/DocumentTest.php index 4c46e04a..afee7202 100644 --- a/Tests/Grid/Source/DocumentTest.php +++ b/Tests/Grid/Source/DocumentTest.php @@ -1033,7 +1033,7 @@ private function stubBuilder(array $documents = []) $builder ->method('getQuery') ->willReturn($query); - + $this ->manager ->method('createQueryBuilder') diff --git a/Tests/Twig/DataGridExtensionTest.php b/Tests/Twig/DataGridExtensionTest.php index 693a20e5..d891e62a 100644 --- a/Tests/Twig/DataGridExtensionTest.php +++ b/Tests/Twig/DataGridExtensionTest.php @@ -29,7 +29,7 @@ public function setUp() public function testGetGridUrl() { - $baseUrl = 'http://localhost'; + $baseUrl = 'https://localhost'; $gridHash = 'my_grid'; // Creates grid diff --git a/Twig/DataGridExtension.php b/Twig/DataGridExtension.php index f8484e04..33044fb7 100644 --- a/Twig/DataGridExtension.php +++ b/Twig/DataGridExtension.php @@ -16,6 +16,7 @@ use Pagerfanta\Adapter\NullAdapter; use Pagerfanta\Pagerfanta; use Symfony\Component\Routing\RouterInterface; +use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\Extension\GlobalsInterface; use Twig\TemplateWrapper; @@ -170,14 +171,14 @@ public function initGrid($grid, $theme = null, $id = '', array $params = []) /** * Render grid block. * - * @param \Twig\Environment $environment + * @param \Twig\Environment $environment * @param \APY\DataGridBundle\Grid\Grid $grid * @param string $theme * @param string $id * * @return string */ - public function getGrid(\Twig\Environment $environment, $grid, $theme = null, $id = '', array $params = [], $withjs = true) + public function getGrid(Environment $environment, $grid, $theme = null, $id = '', array $params = [], $withjs = true) { $this->initGrid($grid, $theme, $id, $params); @@ -190,37 +191,37 @@ public function getGrid(\Twig\Environment $environment, $grid, $theme = null, $i /** * Render grid block (html only). * - * @param \Twig\Environment $environment + * @param \Twig\Environment $environment * @param \APY\DataGridBundle\Grid\Grid $grid * @param string $theme * @param string $id * * @return string */ - public function getGridHtml(\Twig\Environment $environment, $grid, $theme = null, $id = '', array $params = []) + public function getGridHtml(Environment $environment, $grid, $theme = null, $id = '', array $params = []) { return $this->getGrid($environment, $grid, $theme, $id, $params, false); } /** * @param \Twig\Environment $environment - * @param string $name - * @param unknown $grid + * @param string $name + * @param unknown $grid * * @return string */ - public function getGrid_(\Twig\Environment $environment, $name, $grid) + public function getGrid_(Environment $environment, $name, $grid) { return $this->renderBlock($environment, 'grid_' . $name, ['grid' => $grid]); } /** * @param \Twig\Environment $environment - * @param unknown $grid + * @param unknown $grid * * @return string */ - public function getGridPager(\Twig\Environment $environment, $grid) + public function getGridPager(Environment $environment, $grid) { return $this->renderBlock($environment, 'grid_pager', ['grid' => $grid, 'pagerfanta' => $this->pagerFantaDefs['enable']]); } @@ -228,14 +229,14 @@ public function getGridPager(\Twig\Environment $environment, $grid) /** * Cell Drawing override. * - * @param \Twig\Environment $environment + * @param \Twig\Environment $environment * @param \APY\DataGridBundle\Grid\Column\Column $column * @param \APY\DataGridBundle\Grid\Row $row * @param \APY\DataGridBundle\Grid\Grid $grid * * @return string */ - public function getGridCell(\Twig\Environment $environment, $column, $row, $grid) + public function getGridCell(Environment $environment, $column, $row, $grid) { $value = $column->renderCell($row->getField($column->getId()), $row, $this->router); @@ -263,13 +264,13 @@ public function getGridCell(\Twig\Environment $environment, $column, $row, $grid /** * Filter Drawing override. * - * @param \Twig\Environment $environment + * @param \Twig\Environment $environment * @param \APY\DataGridBundle\Grid\Column\Column $column * @param \APY\DataGridBundle\Grid\Grid $grid * * @return string */ - public function getGridFilter(\Twig\Environment $environment, $column, $grid, $submitOnChange = true) + public function getGridFilter(Environment $environment, $column, $grid, $submitOnChange = true) { $id = $this->names[$grid->getHash()]; @@ -293,13 +294,13 @@ public function getGridFilter(\Twig\Environment $environment, $column, $grid, $s /** * Column Operator Drawing override. * - * @param \Twig\Environment $environment + * @param \Twig\Environment $environment * @param \APY\DataGridBundle\Grid\Column\Column $column * @param \APY\DataGridBundle\Grid\Grid $grid * * @return string */ - public function getGridColumnOperator(\Twig\Environment $environment, $column, $grid, $operator, $submitOnChange = true) + public function getGridColumnOperator(Environment $environment, $column, $grid, $operator, $submitOnChange = true) { return $this->renderBlock($environment, 'grid_column_operator', ['grid' => $grid, 'column' => $column, 'submitOnChange' => $submitOnChange, 'op' => $operator]); } @@ -335,14 +336,14 @@ public function getGridUrl($section, $grid, $param = null) /** * @param \Twig\Environment $environment - * @param unknown $grid - * @param unknown $theme - * @param string $id - * @param array $params + * @param unknown $grid + * @param unknown $theme + * @param string $id + * @param array $params * * @return string */ - public function getGridSearch(\Twig\Environment $environment, $grid, $theme = null, $id = '', array $params = []) + public function getGridSearch(Environment $environment, $grid, $theme = null, $id = '', array $params = []) { $this->initGrid($grid, $theme, $id, $params); @@ -375,14 +376,13 @@ public function getPagerfanta($grid) * Render block. * * @param \Twig\Environment $environment - * @param string $name - * @param array $parameters - * - * @throws \InvalidArgumentException If the block could not be found + * @param string $name + * @param array $parameters * * @return string + * @throws \InvalidArgumentException If the block could not be found */ - protected function renderBlock(\Twig\Environment $environment, $name, $parameters) + protected function renderBlock(Environment $environment, $name, $parameters) { foreach ($this->getTemplates($environment) as $template) { if ($template->hasBlock($name, [])) { @@ -397,11 +397,11 @@ protected function renderBlock(\Twig\Environment $environment, $name, $parameter * Has block. * * @param \Twig\Environment $environment - * @param $name string + * @param $name string * * @return bool */ - protected function hasBlock(\Twig\Environment $environment, $name) + protected function hasBlock(Environment $environment, $name) { foreach ($this->getTemplates($environment) as $template) { /** @var $template TemplateWrapper */ @@ -418,11 +418,10 @@ protected function hasBlock(\Twig\Environment $environment, $name) * * @param \Twig\Environment $environment * - * @throws \Exception - * * @return TemplateWrapper[] + * @throws \Exception */ - protected function getTemplates(\Twig\Environment $environment) + protected function getTemplates(Environment $environment) { if (empty($this->templates)) { if ($this->theme instanceof TemplateWrapper) { @@ -446,15 +445,12 @@ protected function getTemplates(\Twig\Environment $environment) * * @return array */ - protected function getTemplatesFromString(\Twig\Environment $environment, $theme) + protected function getTemplatesFromString(Environment $environment, $theme) { $this->templates = []; + $template = $environment->load($theme); - while ($template instanceof TemplateWrapper) { - $template = $template->unwrap(); - $this->templates[] = $template; - $template = $template->getParent([]); - } + $this->templates[] = $template; return $this->templates; } From d941c8f9f37231a32a2d7caaba6c20ed672cf779 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 11:52:42 -0500 Subject: [PATCH 04/41] Fix tests --- Grid/Column/Column.php | 4 ++++ Tests/Grid/GridManagerTest.php | 10 +++------- Tests/Grid/GridTest.php | 8 ++------ Tests/Twig/DataGridExtensionTest.php | 1 + composer.json | 6 ++---- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Grid/Column/Column.php b/Grid/Column/Column.php index da0e3b8c..157e41fe 100644 --- a/Grid/Column/Column.php +++ b/Grid/Column/Column.php @@ -175,6 +175,10 @@ public function __initialize(array $params) self::OPERATOR_NLIKE, self::OPERATOR_RLIKE, self::OPERATOR_LLIKE, + self::OPERATOR_SLIKE, + self::OPERATOR_NSLIKE, + self::OPERATOR_RSLIKE, + self::OPERATOR_LSLIKE, self::OPERATOR_ISNULL, self::OPERATOR_ISNOTNULL, ])); diff --git a/Tests/Grid/GridManagerTest.php b/Tests/Grid/GridManagerTest.php index 41ee7666..7d2b22cb 100644 --- a/Tests/Grid/GridManagerTest.php +++ b/Tests/Grid/GridManagerTest.php @@ -5,8 +5,8 @@ use APY\DataGridBundle\Grid\Grid; use APY\DataGridBundle\Grid\GridManager; use PHPUnit\Framework\TestCase; -use Symfony\Component\BrowserKit\Response; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\HttpFoundation\Response; use Twig\Environment; class GridManagerTest extends TestCase @@ -433,9 +433,7 @@ public function testGetGridWithViewWithoutParams() $view = 'aView'; - $response = $this->createMock(Response::class); - - $this->assertEquals($response, $this->gridManager->getGridManagerResponse($view)); + $this->assertEquals(Response::class, get_class($this->gridManager->getGridManagerResponse($view))); } public function testGetGridWithViewWithViewAndParams() @@ -467,9 +465,7 @@ public function testGetGridWithViewWithViewAndParams() $param2 = 'bar'; $params = [$param1, $param2]; - $response = $this->createMock(Response::class); - - $this->assertEquals($response, $this->gridManager->getGridManagerResponse($view, $params)); + $this->assertEquals(Response::class, get_class($this->gridManager->getGridManagerResponse($view, $params))); } public function setUp() diff --git a/Tests/Grid/GridTest.php b/Tests/Grid/GridTest.php index 930c4143..cb4de373 100644 --- a/Tests/Grid/GridTest.php +++ b/Tests/Grid/GridTest.php @@ -4417,9 +4417,7 @@ public function testGetGridWithViewWithoutParams() $view = 'aView'; - $response = $this->createMock(Response::class); - - $this->assertEquals($response, $this->grid->getGridResponse($view)); + $this->assertSame(Response::class, get_class($this->grid->getGridResponse($view))); } public function testGetGridWithViewWithViewAndParams() @@ -4433,9 +4431,7 @@ public function testGetGridWithViewWithViewAndParams() $param2 = 'bar'; $params = [$param1, $param2]; - $response = $this->createMock(Response::class); - - $this->assertEquals($response, $this->grid->getGridResponse($view, $params)); + $this->assertSame(Response::class, get_class($this->grid->getGridResponse($view, $params))); } public function setUp() diff --git a/Tests/Twig/DataGridExtensionTest.php b/Tests/Twig/DataGridExtensionTest.php index d891e62a..ee00fa8a 100644 --- a/Tests/Twig/DataGridExtensionTest.php +++ b/Tests/Twig/DataGridExtensionTest.php @@ -41,6 +41,7 @@ public function testGetGridUrl() // Creates column $column = $this->createMock(Column::class); + $column->expects($this->any())->method('getDefaultOrder')->willReturn('asc'); // Limit $this->assertEquals($prefix . '[_limit]=', $this->extension->getGridUrl('limit', $grid, $column)); diff --git a/composer.json b/composer.json index 01c84587..ce002715 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,12 @@ "twig/twig": "^2.4|^3.0" }, "require-dev": { + "ext-intl": "*", + "ext-mongodb": "*", "symfony/framework-bundle": "^4.4|^5.2", - "symfony/browser-kit": "^4.4|^5.2", - "symfony/templating": "^4.4|^5.2", "symfony/expression-language": "^4.4|^5.2", "symfony/phpunit-bridge": "^4.4|^5.2", "phpunit/phpunit": "~5.7", - "friendsofphp/php-cs-fixer": "^2.0", - "php-coveralls/php-coveralls": "^2.0", "doctrine/orm": "~2.4,>=2.4.5", "doctrine/mongodb-odm": "^1.1.5" }, From f1033a33ed68b83cc7a1c707bf626ec8d453efe6 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 11:59:53 -0500 Subject: [PATCH 05/41] Upgrade to phpunit 6 --- Tests/Grid/Action/RowActionTest.php | 5 ++- Tests/Grid/Column/DateTimeColumnTest.php | 3 +- Tests/Grid/ColumnsTest.php | 2 +- Tests/Grid/GridBuilderTest.php | 4 +- Tests/Grid/GridFactoryTest.php | 6 +-- Tests/Grid/GridManagerTest.php | 2 +- Tests/Grid/GridTest.php | 54 +++++++++++------------ Tests/Grid/Helper/ColumnsIteratorTest.php | 2 +- Tests/Grid/Source/DocumentTest.php | 12 ++--- Tests/Test.php | 4 +- composer.json | 2 +- 11 files changed, 50 insertions(+), 46 deletions(-) diff --git a/Tests/Grid/Action/RowActionTest.php b/Tests/Grid/Action/RowActionTest.php index 57c60318..8d026bb9 100644 --- a/Tests/Grid/Action/RowActionTest.php +++ b/Tests/Grid/Action/RowActionTest.php @@ -4,8 +4,9 @@ use APY\DataGridBundle\Grid\Action\RowAction; use APY\DataGridBundle\Grid\Row; +use PHPUnit\Framework\TestCase; -class RowActionTest extends \PHPUnit_Framework_TestCase +class RowActionTest extends TestCase { /** @var string */ private $title = 'title'; @@ -31,7 +32,7 @@ class RowActionTest extends \PHPUnit_Framework_TestCase /** @var RowAction */ private $rowAction; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \PHPUnit\Framework\MockObject\MockObject */ private $row; public function testSetTitle() diff --git a/Tests/Grid/Column/DateTimeColumnTest.php b/Tests/Grid/Column/DateTimeColumnTest.php index 6fb20043..b2082f8e 100644 --- a/Tests/Grid/Column/DateTimeColumnTest.php +++ b/Tests/Grid/Column/DateTimeColumnTest.php @@ -6,9 +6,10 @@ use APY\DataGridBundle\Grid\Column\DateTimeColumn; use APY\DataGridBundle\Grid\Filter; use APY\DataGridBundle\Grid\Row; +use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Routing\Router; -class DateTimeColumnTest extends \PHPUnit_Framework_TestCase +class DateTimeColumnTest extends TestCase { public function testGetType() { diff --git a/Tests/Grid/ColumnsTest.php b/Tests/Grid/ColumnsTest.php index f284f8a4..adc4cd4b 100644 --- a/Tests/Grid/ColumnsTest.php +++ b/Tests/Grid/ColumnsTest.php @@ -210,7 +210,7 @@ public function testPartialSetColumnsOrderWithoutKeepOthers() /** * @param int $number * - * @return array|\PHPUnit_Framework_MockObject_MockObject[]|\PHPUnit_Framework_MockObject_MockObject + * @return array|\PHPUnit\Framework\MockObject\MockObject[]|\PHPUnit\Framework\MockObject\MockObject */ private function buildColumnMocks($number) { diff --git a/Tests/Grid/GridBuilderTest.php b/Tests/Grid/GridBuilderTest.php index b9463b35..99385335 100755 --- a/Tests/Grid/GridBuilderTest.php +++ b/Tests/Grid/GridBuilderTest.php @@ -22,12 +22,12 @@ class GridBuilderTest extends TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $container; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $factory; diff --git a/Tests/Grid/GridFactoryTest.php b/Tests/Grid/GridFactoryTest.php index b6518d72..486e3520 100755 --- a/Tests/Grid/GridFactoryTest.php +++ b/Tests/Grid/GridFactoryTest.php @@ -26,17 +26,17 @@ class GridFactoryTest extends TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $container; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $registry; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $builder; diff --git a/Tests/Grid/GridManagerTest.php b/Tests/Grid/GridManagerTest.php index 7d2b22cb..868583ba 100644 --- a/Tests/Grid/GridManagerTest.php +++ b/Tests/Grid/GridManagerTest.php @@ -17,7 +17,7 @@ class GridManagerTest extends TestCase private $gridManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $container; diff --git a/Tests/Grid/GridTest.php b/Tests/Grid/GridTest.php index cb4de373..f740d674 100644 --- a/Tests/Grid/GridTest.php +++ b/Tests/Grid/GridTest.php @@ -41,37 +41,37 @@ class GridTest extends TestCase private $grid; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $router; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $container; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $authChecker; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $request; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $requestStack; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $session; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $environment; @@ -4442,7 +4442,7 @@ public function setUp() /** * @param $gridConfigInterface * @param string $id - * @param \PHPUnit_Framework_MockObject_MockObject $httpKernel + * @param \PHPUnit\Framework\MockObject\MockObject $httpKernel */ private function arrange($gridConfigInterface = null, $id = 'id', $httpKernel = null) { @@ -4708,7 +4708,7 @@ private function mockResetPageAndLimitIfMassActionAndAllKeys() } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockMassActionCallbackResponse() { @@ -4739,7 +4739,7 @@ function () use ($callbackResponse) { } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockMassActionControllerResponse() { @@ -4820,7 +4820,7 @@ private function mockMassActionControllerResponse() } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockExports() { @@ -5493,7 +5493,7 @@ private function mockPageColumnNotSelectMultiRequestData() * @param string $columnId * @param string $order * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockOrderRequestData($columnId, $order) { @@ -5780,7 +5780,7 @@ private function mockDefaultLimit() * @param int $totalCount * @param string $sourceHash * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function arrangeGridSourceDataLoadedWithEmptyRows($totalCount = 0, $sourceHash = null) { @@ -5826,7 +5826,7 @@ private function arrangeGridSourceDataLoadedWithRows(Rows $rows, $totalCount = 0 /** * @param int $totalCount * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function arrangeGridSourceDataLoadedWithoutRowsReturned($totalCount = 0) { @@ -5844,7 +5844,7 @@ private function arrangeGridSourceDataLoadedWithoutRowsReturned($totalCount = 0) } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function arrangeGridSourceDataNotLoadedWithoutRowsReturned() { @@ -5864,7 +5864,7 @@ private function arrangeGridSourceDataNotLoadedWithoutRowsReturned() /** * @param int $totalCount * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function arrangeGridSourceDataNotLoadedWithEmptyRows($totalCount = 0) { @@ -5885,7 +5885,7 @@ private function arrangeGridSourceDataNotLoadedWithEmptyRows($totalCount = 0) } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function arrangeGridPrimaryColumn() { @@ -5896,7 +5896,7 @@ private function arrangeGridPrimaryColumn() } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubPrimaryColumn() { @@ -5914,7 +5914,7 @@ private function stubPrimaryColumn() /** * @param string $columnId * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubFilteredColumn($columnId = null) { @@ -5929,7 +5929,7 @@ private function stubFilteredColumn($columnId = null) /** * @param mixed $columnId * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubTitledColumn($columnId = null) { @@ -5945,7 +5945,7 @@ private function stubTitledColumn($columnId = null) * @param string $type * @param mixed $columnId * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubFilterableColumn($type, $columnId = null) { @@ -5964,7 +5964,7 @@ private function stubFilterableColumn($type, $columnId = null) * @param string $defaultOp * @param mixed $columnId * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubColumnWithDefaultOperator($defaultOp, $columnId = null) { @@ -5979,7 +5979,7 @@ private function stubColumnWithDefaultOperator($defaultOp, $columnId = null) /** * @param mixed $columnId * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubColumn($columnId = null) { @@ -5995,7 +5995,7 @@ private function stubColumn($columnId = null) } /** - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function arrangeGridWithColumnsIterator() { @@ -6026,7 +6026,7 @@ private function arrangeGridWithColumnsIterator() * @param mixed $aCallback * @param array $params * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubMassActionWithCallback($aCallback, array $params = []) { @@ -6044,7 +6044,7 @@ private function stubMassActionWithCallback($aCallback, array $params = []) /** * @param string $role * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubMassAction($role = null) { @@ -6064,7 +6064,7 @@ private function stubMassAction($role = null) * @param string $role * @param mixed $colId * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function stubRowAction($role = null, $colId = null) { diff --git a/Tests/Grid/Helper/ColumnsIteratorTest.php b/Tests/Grid/Helper/ColumnsIteratorTest.php index dce0e726..3aeb2fb3 100644 --- a/Tests/Grid/Helper/ColumnsIteratorTest.php +++ b/Tests/Grid/Helper/ColumnsIteratorTest.php @@ -8,7 +8,7 @@ class ColumnsIteratorTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \PHPUnit\Framework\MockObject\MockObject */ private $iterator; public function testAcceptAnyColumn() diff --git a/Tests/Grid/Source/DocumentTest.php b/Tests/Grid/Source/DocumentTest.php index afee7202..041aacd4 100644 --- a/Tests/Grid/Source/DocumentTest.php +++ b/Tests/Grid/Source/DocumentTest.php @@ -29,17 +29,17 @@ class DocumentTest extends TestCase private $document; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $manager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $odmMetadata; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit\Framework\MockObject\MockObject */ private $metadata; @@ -1115,7 +1115,7 @@ private function arrangeGetFieldsMetadata($name, array $fieldMapping) /** * @param array $elements * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockColumnsIterator(array $elements) { @@ -1153,7 +1153,7 @@ private function mockColumnsIterator(array $elements) /** * @param array $resources * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockCursor(array $resources) { @@ -1191,7 +1191,7 @@ private function mockCursor(array $resources) /** * @param array $resources * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ private function mockHelperCursor(array $resources) { diff --git a/Tests/Test.php b/Tests/Test.php index 7582f1f0..3caa11e1 100644 --- a/Tests/Test.php +++ b/Tests/Test.php @@ -2,7 +2,9 @@ namespace APY\DataGridBundle\Tests; -class Test extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class Test extends TestCase { public function testPHPUnit() { diff --git a/composer.json b/composer.json index ce002715..043679fc 100644 --- a/composer.json +++ b/composer.json @@ -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": "~5.7", + "phpunit/phpunit": "^6.5", "doctrine/orm": "~2.4,>=2.4.5", "doctrine/mongodb-odm": "^1.1.5" }, From 1d9e0fbd6875c83bd7610c3e8d759c8e7b64991a Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 12:03:51 -0500 Subject: [PATCH 06/41] Upgrade to phpunit 7 --- Tests/Grid/Source/DocumentTest.php | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Grid/Source/DocumentTest.php b/Tests/Grid/Source/DocumentTest.php index 041aacd4..3b6f1335 100644 --- a/Tests/Grid/Source/DocumentTest.php +++ b/Tests/Grid/Source/DocumentTest.php @@ -957,7 +957,7 @@ public function testReturnsColumns() $columns ->expects($this->exactly(2)) ->method('addColumn') - ->withConsecutive($column, $column2); + ->withConsecutive([$column], [$column2]); $this->document->getColumns($columns); } diff --git a/composer.json b/composer.json index 043679fc..d5a2d0cc 100644 --- a/composer.json +++ b/composer.json @@ -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": "^6.5", + "phpunit/phpunit": "^7.5", "doctrine/orm": "~2.4,>=2.4.5", "doctrine/mongodb-odm": "^1.1.5" }, From 9177dd826380a12eb74963983888ce217b6e183c Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 12:12:25 -0500 Subject: [PATCH 07/41] Update gitignore --- .gitignore | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 62690a29..e01bc6ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,4 @@ -nbproject/ -catalog.xml -/vendor +/vendor/ +/.phpunit.result.cache /composer.lock /phpunit.xml -/composer.phar -*~ -*.orig -.buildpath -.project -.settings/ -.idea \ No newline at end of file From 194eb0840655bbae8a3ab778b9dc193fd3bbafb2 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 12:12:38 -0500 Subject: [PATCH 08/41] Upgrade to phpunit 8 --- Tests/Grid/Action/MassActionTest.php | 10 +- Tests/Grid/Action/RowActionTest.php | 16 +-- Tests/Grid/Column/ActionsColumnTest.php | 20 ++-- Tests/Grid/Column/ArrayColumnTest.php | 10 +- Tests/Grid/Column/BooleanColumnTest.php | 10 +- Tests/Grid/Column/DateColumnTest.php | 10 +- Tests/Grid/Column/JoinColumnTest.php | 10 +- Tests/Grid/Column/MassActionColumnTest.php | 10 +- Tests/Grid/Column/NumberColumnTest.php | 10 +- Tests/Grid/Column/RankColumnTest.php | 10 +- Tests/Grid/Column/SimpleArrayColumnTest.php | 8 +- Tests/Grid/Column/TextColumnTest.php | 10 +- Tests/Grid/ColumnsTest.php | 12 +-- Tests/Grid/GridBuilderTest.php | 4 +- Tests/Grid/GridConfigBuilderTest.php | 16 +-- Tests/Grid/GridFactoryTest.php | 64 +++++------ Tests/Grid/GridManagerTest.php | 12 +-- Tests/Grid/GridRegistryTest.php | 10 +- Tests/Grid/GridTest.php | 10 +- Tests/Grid/Mapping/ColumnTest.php | 2 +- Tests/Grid/Mapping/Metadata/ManagerTest.php | 2 +- Tests/Grid/Mapping/Metadata/MetadataTest.php | 2 +- Tests/Grid/Mapping/SourceTest.php | 2 +- Tests/Grid/RowTest.php | 10 +- Tests/Grid/RowsTest.php | 12 +-- Tests/Grid/Source/DocumentTest.php | 106 +++++++++---------- Tests/Grid/Source/VectorTest.php | 10 +- Tests/Twig/DataGridExtensionTest.php | 2 +- composer.json | 2 +- 29 files changed, 206 insertions(+), 206 deletions(-) diff --git a/Tests/Grid/Action/MassActionTest.php b/Tests/Grid/Action/MassActionTest.php index 71da8c44..3ba6551f 100644 --- a/Tests/Grid/Action/MassActionTest.php +++ b/Tests/Grid/Action/MassActionTest.php @@ -25,6 +25,11 @@ class MassActionTest extends TestCase /** @var string */ private $role = 'ROLE_FOO'; + public function setUp(): void + { + $this->massAction = new MassAction($this->title, $this->callback, $this->confirm, $this->parameters, $this->role); + } + public function testMassActionConstruct() { $this->assertAttributeEquals($this->title, 'title', $this->massAction); @@ -134,9 +139,4 @@ public function testGetRole() $this->assertEquals($role, $this->massAction->getRole()); } - - public function setUp() - { - $this->massAction = new MassAction($this->title, $this->callback, $this->confirm, $this->parameters, $this->role); - } } diff --git a/Tests/Grid/Action/RowActionTest.php b/Tests/Grid/Action/RowActionTest.php index 8d026bb9..77961340 100644 --- a/Tests/Grid/Action/RowActionTest.php +++ b/Tests/Grid/Action/RowActionTest.php @@ -35,6 +35,14 @@ class RowActionTest extends TestCase /** @var \PHPUnit\Framework\MockObject\MockObject */ private $row; + protected function setUp(): void + { + $this->rowAction = new RowAction( + $this->title, $this->route, $this->confirm, $this->target, $this->attributes, $this->role + ); + $this->row = $this->createMock(Row::class); + } + public function testSetTitle() { $title = 'foo_title'; @@ -327,12 +335,4 @@ public function testGetEnabled() $this->assertTrue($this->rowAction->getEnabled()); } - - protected function setUp() - { - $this->rowAction = new RowAction( - $this->title, $this->route, $this->confirm, $this->target, $this->attributes, $this->role - ); - $this->row = $this->createMock(Row::class); - } } diff --git a/Tests/Grid/Column/ActionsColumnTest.php b/Tests/Grid/Column/ActionsColumnTest.php index 42a4264d..5ec0097a 100644 --- a/Tests/Grid/Column/ActionsColumnTest.php +++ b/Tests/Grid/Column/ActionsColumnTest.php @@ -14,6 +14,16 @@ class ActionsColumnTest extends TestCase /** @var ActionsColumn */ private $column; + public function setUp(): void + { + $rowAction1 = $this->createMock(RowAction::class); + $rowAction2 = $this->createMock(RowAction::class); + $this->column = new ActionsColumn('columnId', 'columnTitle', [ + $rowAction1, + $rowAction2, + ]); + } + public function testConstructor() { $columnId = 'columnId'; @@ -161,14 +171,4 @@ public function testGetRouteParameters() 'aName' => 'aValue', ], $this->column->getRouteParameters($row, $rowAction)); } - - public function setUp() - { - $rowAction1 = $this->createMock(RowAction::class); - $rowAction2 = $this->createMock(RowAction::class); - $this->column = new ActionsColumn('columnId', 'columnTitle', [ - $rowAction1, - $rowAction2, - ]); - } } diff --git a/Tests/Grid/Column/ArrayColumnTest.php b/Tests/Grid/Column/ArrayColumnTest.php index 3405835d..88b1ae2e 100644 --- a/Tests/Grid/Column/ArrayColumnTest.php +++ b/Tests/Grid/Column/ArrayColumnTest.php @@ -14,6 +14,11 @@ class ArrayColumnTest extends TestCase /** @var ArrayColumn */ private $column; + public function setUp(): void + { + $this->column = new ArrayColumn(); + } + public function testGetType() { $this->assertEquals('array', $this->column->getType()); @@ -141,9 +146,4 @@ public function testRenderCellWithCallback() $this->assertEquals($result, ['bar' => 'a', 'foo' => 'b']); } - - public function setUp() - { - $this->column = new ArrayColumn(); - } } diff --git a/Tests/Grid/Column/BooleanColumnTest.php b/Tests/Grid/Column/BooleanColumnTest.php index a694a713..83ad730c 100644 --- a/Tests/Grid/Column/BooleanColumnTest.php +++ b/Tests/Grid/Column/BooleanColumnTest.php @@ -13,6 +13,11 @@ class BooleanColumnTest extends TestCase /** @var BooleanColumn */ private $column; + public function setUp(): void + { + $this->column = new BooleanColumn(); + } + public function testGetType() { $this->assertEquals('boolean', $this->column->getType()); @@ -128,9 +133,4 @@ function ($value, $row, $router) { 1, $this->createMock(Row::class), $this->createMock(Router::class) )); } - - public function setUp() - { - $this->column = new BooleanColumn(); - } } diff --git a/Tests/Grid/Column/DateColumnTest.php b/Tests/Grid/Column/DateColumnTest.php index b41eaa18..fc320f51 100644 --- a/Tests/Grid/Column/DateColumnTest.php +++ b/Tests/Grid/Column/DateColumnTest.php @@ -12,6 +12,11 @@ class DateColumnTest extends TestCase /** @var DateColumn */ private $column; + public function setUp(): void + { + $this->column = new DateColumn(); + } + public function testGetType() { $this->assertEquals('date', $this->column->getType()); @@ -118,9 +123,4 @@ public function testGetFiltersOperatorLte() $this->column->getFilters('asource') ); } - - public function setUp() - { - $this->column = new DateColumn(); - } } diff --git a/Tests/Grid/Column/JoinColumnTest.php b/Tests/Grid/Column/JoinColumnTest.php index 5c9ee46c..a465fe22 100644 --- a/Tests/Grid/Column/JoinColumnTest.php +++ b/Tests/Grid/Column/JoinColumnTest.php @@ -12,6 +12,11 @@ class JoinColumnTest extends TestCase /** @var JoinColumn */ private $column; + public function setUp(): void + { + $this->column = new JoinColumn(); + } + public function testGetType() { $this->assertEquals('join', $this->column->getType()); @@ -87,9 +92,4 @@ public function testSetColumnNameOnFilters() new Filter(Column::OPERATOR_NEQ, null, $col2), ], $column->getFilters('asource')); } - - public function setUp() - { - $this->column = new JoinColumn(); - } } diff --git a/Tests/Grid/Column/MassActionColumnTest.php b/Tests/Grid/Column/MassActionColumnTest.php index 508425cb..2891e55c 100644 --- a/Tests/Grid/Column/MassActionColumnTest.php +++ b/Tests/Grid/Column/MassActionColumnTest.php @@ -11,6 +11,11 @@ class MassActionColumnTest extends TestCase /** @var MassActionColumn */ private $column; + public function setUp(): void + { + $this->column = new MassActionColumn(); + } + public function testGetType() { $this->assertEquals('massaction', $this->column->getType()); @@ -39,9 +44,4 @@ public function testInitialize() 'align' => Column::ALIGN_CENTER, ], 'params', $this->column); } - - public function setUp() - { - $this->column = new MassActionColumn(); - } } diff --git a/Tests/Grid/Column/NumberColumnTest.php b/Tests/Grid/Column/NumberColumnTest.php index 2a1fe23c..8816f706 100644 --- a/Tests/Grid/Column/NumberColumnTest.php +++ b/Tests/Grid/Column/NumberColumnTest.php @@ -16,6 +16,11 @@ class NumberColumnTest extends TestCase */ private $column; + public function setUp(): void + { + $this->column = new NumberColumn(); + } + public function testGetType() { $this->assertEquals('number', $this->column->getType()); @@ -306,9 +311,4 @@ public function getMaxFractionDigits() $column = new NumberColumn(['maxFractionDigits' => 3]); $this->assertEquals(3, $column->getMaxFractionDigits()); } - - public function setUp() - { - $this->column = new NumberColumn(); - } } diff --git a/Tests/Grid/Column/RankColumnTest.php b/Tests/Grid/Column/RankColumnTest.php index 7ad72940..c4b2e71a 100644 --- a/Tests/Grid/Column/RankColumnTest.php +++ b/Tests/Grid/Column/RankColumnTest.php @@ -13,6 +13,11 @@ class RankColumnTest extends TestCase /** @var RankColumn */ private $column; + public function setUp(): void + { + $this->column = new RankColumn(); + } + public function testGetType() { $this->assertEquals('rank', $this->column->getType()); @@ -80,9 +85,4 @@ public function testRenderCell() $this->assertEquals(2, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(Router::class))); $this->assertAttributeEquals(3, 'rank', $this->column); } - - public function setUp() - { - $this->column = new RankColumn(); - } } diff --git a/Tests/Grid/Column/SimpleArrayColumnTest.php b/Tests/Grid/Column/SimpleArrayColumnTest.php index 20d17844..69303625 100644 --- a/Tests/Grid/Column/SimpleArrayColumnTest.php +++ b/Tests/Grid/Column/SimpleArrayColumnTest.php @@ -14,14 +14,14 @@ class SimpleArrayColumnTest extends TestCase /** @var SimpleArrayColumn */ private $column; - public function testGetType() + public function setUp(): void { - $this->assertEquals('simple_array', $this->column->getType()); + $this->column = new SimpleArrayColumn(); } - public function setUp() + public function testGetType() { - $this->column = new SimpleArrayColumn(); + $this->assertEquals('simple_array', $this->column->getType()); } public function testInitializeDefaultParams() diff --git a/Tests/Grid/Column/TextColumnTest.php b/Tests/Grid/Column/TextColumnTest.php index 6940f952..defcec23 100644 --- a/Tests/Grid/Column/TextColumnTest.php +++ b/Tests/Grid/Column/TextColumnTest.php @@ -12,6 +12,11 @@ class TextColumnTest extends WebTestCase /** @var TextColumn */ private $column; + public function setUp(): void + { + $this->column = new TextColumn(); + } + public function testGetType() { $this->assertEquals('text', $this->column->getType()); @@ -54,9 +59,4 @@ public function testOtherOperatorFilters() $this->assertEmpty($this->column->getFilters('asource')); } } - - public function setUp() - { - $this->column = new TextColumn(); - } } diff --git a/Tests/Grid/ColumnsTest.php b/Tests/Grid/ColumnsTest.php index adc4cd4b..168e736d 100644 --- a/Tests/Grid/ColumnsTest.php +++ b/Tests/Grid/ColumnsTest.php @@ -16,6 +16,12 @@ class ColumnsTest extends TestCase /** @var AuthorizationCheckerInterface */ private $authChecker; + public function setUp(): void + { + $this->authChecker = $this->createMock(AuthorizationCheckerInterface::class); + $this->columns = new Columns($this->authChecker); + } + public function testGetIterator() { $iterator = $this->columns->getIterator(); @@ -231,10 +237,4 @@ private function buildColumnMocks($number) return $mocks; } - - public function setUp() - { - $this->authChecker = $this->createMock(AuthorizationCheckerInterface::class); - $this->columns = new Columns($this->authChecker); - } } diff --git a/Tests/Grid/GridBuilderTest.php b/Tests/Grid/GridBuilderTest.php index 99385335..0c4cae28 100755 --- a/Tests/Grid/GridBuilderTest.php +++ b/Tests/Grid/GridBuilderTest.php @@ -39,7 +39,7 @@ class GridBuilderTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $self = $this; @@ -70,7 +70,7 @@ protected function setUp() $this->builder = new GridBuilder($this->container, $this->factory, 'name'); } - protected function tearDown() + protected function tearDown(): void { $this->factory = null; $this->builder = null; diff --git a/Tests/Grid/GridConfigBuilderTest.php b/Tests/Grid/GridConfigBuilderTest.php index 38511baa..6c5c8bac 100644 --- a/Tests/Grid/GridConfigBuilderTest.php +++ b/Tests/Grid/GridConfigBuilderTest.php @@ -19,6 +19,14 @@ class GridConfigBuilderTest extends TestCase /** @var GridConfigBuilder */ private $gridConfigBuilder; + /** + * {@inheritdoc} + */ + protected function setUp(): void + { + $this->gridConfigBuilder = new GridConfigBuilder($this->name, $this->options); + } + public function testGetName() { $this->assertEquals($this->name, $this->gridConfigBuilder->getName()); @@ -273,12 +281,4 @@ public function testGetGridConfig() { $this->assertInstanceOf(GridConfigBuilder::class, $this->gridConfigBuilder->getGridConfig()); } - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->gridConfigBuilder = new GridConfigBuilder($this->name, $this->options); - } } diff --git a/Tests/Grid/GridFactoryTest.php b/Tests/Grid/GridFactoryTest.php index 486e3520..75915e3b 100755 --- a/Tests/Grid/GridFactoryTest.php +++ b/Tests/Grid/GridFactoryTest.php @@ -45,6 +45,38 @@ class GridFactoryTest extends TestCase */ private $factory; + protected function setUp(): void + { + $self = $this; + + $this->container = $this->createMock(Container::class); + $this->container->expects($this->any()) + ->method('get') + ->will($this->returnCallback(function ($param) use ($self) { + switch ($param) { + case 'router': + return $self->createMock(RouterInterface::class); + break; + case 'request_stack': + $request = new Request([], [], ['key' => 'value']); + $session = new Session(); + $request->setSession($session); + $requestStack = new RequestStack(); + $requestStack->push($request); + + return $requestStack; + break; + case 'security.authorization_checker': + return $self->createMock(AuthorizationCheckerInterface::class); + break; + } + })); + + $this->registry = $this->createMock(GridRegistryInterface::class); + $this->builder = $this->createMock(GridBuilderInterface::class); + $this->factory = new GridFactory($this->container, $this->registry); + } + public function testCreateWithUnexpectedType() { $this->expectException(UnexpectedTypeException::class); @@ -158,36 +190,4 @@ public function testCreateColumnWithObject() $this->assertNull($column->getField()); $this->assertFalse($column->isVisibleForSource()); } - - protected function setUp() - { - $self = $this; - - $this->container = $this->createMock(Container::class); - $this->container->expects($this->any()) - ->method('get') - ->will($this->returnCallback(function ($param) use ($self) { - switch ($param) { - case 'router': - return $self->createMock(RouterInterface::class); - break; - case 'request_stack': - $request = new Request([], [], ['key' => 'value']); - $session = new Session(); - $request->setSession($session); - $requestStack = new RequestStack(); - $requestStack->push($request); - - return $requestStack; - break; - case 'security.authorization_checker': - return $self->createMock(AuthorizationCheckerInterface::class); - break; - } - })); - - $this->registry = $this->createMock(GridRegistryInterface::class); - $this->builder = $this->createMock(GridBuilderInterface::class); - $this->factory = new GridFactory($this->container, $this->registry); - } } diff --git a/Tests/Grid/GridManagerTest.php b/Tests/Grid/GridManagerTest.php index 868583ba..855aa48d 100644 --- a/Tests/Grid/GridManagerTest.php +++ b/Tests/Grid/GridManagerTest.php @@ -21,6 +21,12 @@ class GridManagerTest extends TestCase */ private $container; + public function setUp(): void + { + $this->container = $this->createMock(Container::class); + $this->gridManager = new GridManager($this->container); + } + public function testGetIterator() { $this->assertInstanceOf(\SplObjectStorage::class, $this->gridManager->getIterator()); @@ -468,12 +474,6 @@ public function testGetGridWithViewWithViewAndParams() $this->assertEquals(Response::class, get_class($this->gridManager->getGridManagerResponse($view, $params))); } - public function setUp() - { - $this->container = $this->createMock(Container::class); - $this->gridManager = new GridManager($this->container); - } - /** * @param string $grid1Hash * @param string $route1Url diff --git a/Tests/Grid/GridRegistryTest.php b/Tests/Grid/GridRegistryTest.php index 3de7283a..72dad564 100755 --- a/Tests/Grid/GridRegistryTest.php +++ b/Tests/Grid/GridRegistryTest.php @@ -21,6 +21,11 @@ class GridRegistryTest extends TestCase */ private $registry; + protected function setUp(): void + { + $this->registry = new GridRegistry(); + } + public function testAddTypeAlreadyExists() { $this->expectException(TypeAlreadyExistsException::class); @@ -94,11 +99,6 @@ public function testGetColumnType() $this->assertSame($expectedColumnType, $this->registry->getColumn('type')); } - protected function setUp() - { - $this->registry = new GridRegistry(); - } - protected function createTypeMock() { $mock = $this->createMock(GridTypeInterface::class); diff --git a/Tests/Grid/GridTest.php b/Tests/Grid/GridTest.php index f740d674..b2241227 100644 --- a/Tests/Grid/GridTest.php +++ b/Tests/Grid/GridTest.php @@ -85,6 +85,11 @@ class GridTest extends TestCase */ private $gridHash; + public function setUp(): void + { + $this->arrange($this->createMock(GridConfigInterface::class)); + } + public function testInitializeWithoutAnyConfiguration() { $this->arrange(); @@ -4434,11 +4439,6 @@ public function testGetGridWithViewWithViewAndParams() $this->assertSame(Response::class, get_class($this->grid->getGridResponse($view, $params))); } - public function setUp() - { - $this->arrange($this->createMock(GridConfigInterface::class)); - } - /** * @param $gridConfigInterface * @param string $id diff --git a/Tests/Grid/Mapping/ColumnTest.php b/Tests/Grid/Mapping/ColumnTest.php index a1b9b89e..a77750ce 100644 --- a/Tests/Grid/Mapping/ColumnTest.php +++ b/Tests/Grid/Mapping/ColumnTest.php @@ -7,7 +7,7 @@ class ColumnTest extends TestCase { - public function setUp() + public function setUp(): void { $this->stringMetadata = 'foo'; $this->arrayMetadata = ['foo' => 'bar', 'groups' => 'baz']; diff --git a/Tests/Grid/Mapping/Metadata/ManagerTest.php b/Tests/Grid/Mapping/Metadata/ManagerTest.php index 9312cf49..17121e06 100644 --- a/Tests/Grid/Mapping/Metadata/ManagerTest.php +++ b/Tests/Grid/Mapping/Metadata/ManagerTest.php @@ -10,7 +10,7 @@ class ManagerTest extends TestCase { - public function setUp() + public function setUp(): void { $this->manager = new Manager(); } diff --git a/Tests/Grid/Mapping/Metadata/MetadataTest.php b/Tests/Grid/Mapping/Metadata/MetadataTest.php index 0b0e679c..7fd33f84 100644 --- a/Tests/Grid/Mapping/Metadata/MetadataTest.php +++ b/Tests/Grid/Mapping/Metadata/MetadataTest.php @@ -9,7 +9,7 @@ class MetadataTest extends TestCase { - public function setUp() + public function setUp(): void { $this->metadata = new Metadata(); } diff --git a/Tests/Grid/Mapping/SourceTest.php b/Tests/Grid/Mapping/SourceTest.php index d73af415..57c608e6 100644 --- a/Tests/Grid/Mapping/SourceTest.php +++ b/Tests/Grid/Mapping/SourceTest.php @@ -7,7 +7,7 @@ class SourceTest extends TestCase { - public function setUp() + public function setUp(): void { $this->source = new Source([]); } diff --git a/Tests/Grid/RowTest.php b/Tests/Grid/RowTest.php index c19e5811..1847a26b 100644 --- a/Tests/Grid/RowTest.php +++ b/Tests/Grid/RowTest.php @@ -11,6 +11,11 @@ class RowTest extends TestCase /** @var Row */ private $row; + public function setUp(): void + { + $this->row = new Row(); + } + public function testSetRepository() { $repo = $this->createMock(EntityRepository::class); @@ -202,9 +207,4 @@ public function testGetLegend() $this->assertEquals($legend, $this->row->getLegend()); } - - public function setUp() - { - $this->row = new Row(); - } } diff --git a/Tests/Grid/RowsTest.php b/Tests/Grid/RowsTest.php index 1779b0af..17610c74 100644 --- a/Tests/Grid/RowsTest.php +++ b/Tests/Grid/RowsTest.php @@ -14,6 +14,12 @@ class RowsTest extends TestCase /** @var array */ private $rows; + public function setUp(): void + { + $this->rows = [$this->createMock(Row::class), $this->createMock(Row::class), $this->createMock(Row::class)]; + $this->rowsSUT = new Rows($this->rows); + } + public function testAddRowsOnConstruct() { $this->assertEquals(3, $this->rowsSUT->count()); @@ -34,10 +40,4 @@ public function testToArray() { $this->assertEquals($this->rows, $this->rowsSUT->toArray()); } - - public function setUp() - { - $this->rows = [$this->createMock(Row::class), $this->createMock(Row::class), $this->createMock(Row::class)]; - $this->rowsSUT = new Rows($this->rows); - } } diff --git a/Tests/Grid/Source/DocumentTest.php b/Tests/Grid/Source/DocumentTest.php index 3b6f1335..b72963df 100644 --- a/Tests/Grid/Source/DocumentTest.php +++ b/Tests/Grid/Source/DocumentTest.php @@ -43,6 +43,59 @@ class DocumentTest extends TestCase */ private $metadata; + public function setUp(): void + { + $name = 'name'; + $this->document = new Document($name); + + $reflectionClassName = 'aName'; + $reflectionClass = $this->createMock(\ReflectionClass::class); + $reflectionClass + ->method('getName') + ->willReturn($reflectionClassName); + + $odmMetadata = $this->createMock(ClassMetadata::class); + $odmMetadata + ->method('getReflectionClass') + ->willReturn($reflectionClass); + + $this->odmMetadata = $odmMetadata; + + $documentManager = $this->createMock(DocumentManager::class); + $documentManager + ->method('getClassMetadata') + ->with($name) + ->willReturn($odmMetadata); + + $this->manager = $documentManager; + + $metadata = $this->createMock(Metadata::class); + $this->metadata = $metadata; + + $mapping = $this->createMock(Manager::class); + $mapping + ->method('getMetadata') + ->with($reflectionClassName, 'default') + ->willReturn($metadata); + + $containerGetMap = [ + ['doctrine.odm.mongodb.document_manager', Container::EXCEPTION_ON_INVALID_REFERENCE, $documentManager], + ['grid.mapping.manager', Container::EXCEPTION_ON_INVALID_REFERENCE, $mapping] + ]; + + $container = $this->createMock(Container::class); + $container + ->method('get') + ->will($this->returnValueMap($containerGetMap)); + + $mapping + ->expects($this->once()) + ->method('addDriver') + ->with($this->document, -1); + + $this->document->initialise($container); + } + public function testConstructedWithDefaultGroup() { $name = 'name'; @@ -967,59 +1020,6 @@ public function testPopulateSelectFilters() // @todo Don't know how to move on with __clone method on stubs / mocks } - public function setUp() - { - $name = 'name'; - $this->document = new Document($name); - - $reflectionClassName = 'aName'; - $reflectionClass = $this->createMock(\ReflectionClass::class); - $reflectionClass - ->method('getName') - ->willReturn($reflectionClassName); - - $odmMetadata = $this->createMock(ClassMetadata::class); - $odmMetadata - ->method('getReflectionClass') - ->willReturn($reflectionClass); - - $this->odmMetadata = $odmMetadata; - - $documentManager = $this->createMock(DocumentManager::class); - $documentManager - ->method('getClassMetadata') - ->with($name) - ->willReturn($odmMetadata); - - $this->manager = $documentManager; - - $metadata = $this->createMock(Metadata::class); - $this->metadata = $metadata; - - $mapping = $this->createMock(Manager::class); - $mapping - ->method('getMetadata') - ->with($reflectionClassName, 'default') - ->willReturn($metadata); - - $containerGetMap = [ - ['doctrine.odm.mongodb.document_manager', Container::EXCEPTION_ON_INVALID_REFERENCE, $documentManager], - ['grid.mapping.manager', Container::EXCEPTION_ON_INVALID_REFERENCE, $mapping] - ]; - - $container = $this->createMock(Container::class); - $container - ->method('get') - ->will($this->returnValueMap($containerGetMap)); - - $mapping - ->expects($this->once()) - ->method('addDriver') - ->with($this->document, -1); - - $this->document->initialise($container); - } - private function stubBuilder(array $documents = []) { $cursor = $this->mockCursor($documents); diff --git a/Tests/Grid/Source/VectorTest.php b/Tests/Grid/Source/VectorTest.php index 639a2fc4..1f0f03cc 100644 --- a/Tests/Grid/Source/VectorTest.php +++ b/Tests/Grid/Source/VectorTest.php @@ -17,6 +17,11 @@ class VectorTest extends TestCase */ private $vector; + public function setUp(): void + { + $this->vector = new Vector([], []); + } + public function testCreateVectorWithEmptyData() { $this->assertAttributeEmpty('data', $this->vector); @@ -243,11 +248,6 @@ public function guessedColumnProvider() 'Date and time' => [[['c1Id' => '2017-07-22'], ['c1Id' => '2017-07-22 11:00:00']], $uc, 'datetime'] ]; } - - public function setUp() - { - $this->vector = new Vector([], []); - } } class VectorObj diff --git a/Tests/Twig/DataGridExtensionTest.php b/Tests/Twig/DataGridExtensionTest.php index ee00fa8a..47b3429a 100644 --- a/Tests/Twig/DataGridExtensionTest.php +++ b/Tests/Twig/DataGridExtensionTest.php @@ -21,7 +21,7 @@ class DataGridExtensionTest extends TestCase */ private $extension; - public function setUp() + public function setUp(): void { $router = $this->createMock(RouterInterface::class); $this->extension = new DataGridExtension($router, ''); diff --git a/composer.json b/composer.json index d5a2d0cc..934ab24e 100644 --- a/composer.json +++ b/composer.json @@ -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": "^7.5", + "phpunit/phpunit": "^8.5", "doctrine/orm": "~2.4,>=2.4.5", "doctrine/mongodb-odm": "^1.1.5" }, From 41788298831c8663827a52fe4e1f7352d2dc9c76 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 12:24:43 -0500 Subject: [PATCH 09/41] Remove non-standard settings --- .editorconfig | 469 -------------------------------------------------- 1 file changed, 469 deletions(-) diff --git a/.editorconfig b/.editorconfig index da88383a..fd7914a1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,472 +8,3 @@ indent_style = space insert_final_newline = true max_line_length = 200 tab_width = 4 -ij_continuation_indent_size = 4 -ij_formatter_off_tag = @formatter:off -ij_formatter_on_tag = @formatter:on -ij_formatter_tags_enabled = false -ij_smart_tabs = false -ij_wrap_on_typing = false - -[*.css] -ij_css_align_closing_brace_with_properties = false -ij_css_blank_lines_around_nested_selector = 1 -ij_css_blank_lines_between_blocks = 1 -ij_css_brace_placement = 0 -ij_css_enforce_quotes_on_format = false -ij_css_hex_color_long_format = true -ij_css_hex_color_lower_case = true -ij_css_hex_color_short_format = false -ij_css_hex_color_upper_case = false -ij_css_keep_blank_lines_in_code = 2 -ij_css_keep_indents_on_empty_lines = false -ij_css_keep_single_line_blocks = false -ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow -ij_css_space_after_colon = true -ij_css_space_before_opening_brace = true -ij_css_use_double_quotes = true -ij_css_value_alignment = 0 - -[*.scss] -ij_scss_align_closing_brace_with_properties = false -ij_scss_blank_lines_around_nested_selector = 1 -ij_scss_blank_lines_between_blocks = 1 -ij_scss_brace_placement = 0 -ij_scss_enforce_quotes_on_format = false -ij_scss_hex_color_long_format = false -ij_scss_hex_color_lower_case = false -ij_scss_hex_color_short_format = false -ij_scss_hex_color_upper_case = false -ij_scss_keep_blank_lines_in_code = 2 -ij_scss_keep_indents_on_empty_lines = false -ij_scss_keep_single_line_blocks = false -ij_scss_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow -ij_scss_space_after_colon = true -ij_scss_space_before_opening_brace = true -ij_scss_use_double_quotes = true -ij_scss_value_alignment = 0 - -[*.twig] -ij_twig_keep_indents_on_empty_lines = false -ij_twig_spaces_inside_delimiters = true -ij_twig_spaces_inside_variable_delimiters = true - -[.editorconfig] -ij_editorconfig_align_group_field_declarations = false -ij_editorconfig_space_after_colon = false -ij_editorconfig_space_after_comma = true -ij_editorconfig_space_before_colon = false -ij_editorconfig_space_before_comma = false -ij_editorconfig_spaces_around_assignment_operators = true - -[{*.cjs,*.js}] -ij_javascript_align_imports = false -ij_javascript_align_multiline_array_initializer_expression = true -ij_javascript_align_multiline_binary_operation = true -ij_javascript_align_multiline_chained_methods = true -ij_javascript_align_multiline_extends_list = true -ij_javascript_align_multiline_for = true -ij_javascript_align_multiline_parameters = true -ij_javascript_align_multiline_parameters_in_calls = false -ij_javascript_align_multiline_ternary_operation = true -ij_javascript_align_object_properties = 2 -ij_javascript_align_union_types = false -ij_javascript_align_var_statements = 2 -ij_javascript_array_initializer_new_line_after_left_brace = true -ij_javascript_array_initializer_right_brace_on_new_line = true -ij_javascript_array_initializer_wrap = off -ij_javascript_assignment_wrap = off -ij_javascript_binary_operation_sign_on_next_line = false -ij_javascript_binary_operation_wrap = off -ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**/*,@angular/material,@angular/material/typings/**,~/node_modules/**/*,@/node_modules/**/* -ij_javascript_blank_lines_after_imports = 1 -ij_javascript_blank_lines_around_class = 1 -ij_javascript_blank_lines_around_field = 0 -ij_javascript_blank_lines_around_function = 1 -ij_javascript_blank_lines_around_method = 1 -ij_javascript_block_brace_style = end_of_line -ij_javascript_call_parameters_new_line_after_left_paren = true -ij_javascript_call_parameters_right_paren_on_new_line = true -ij_javascript_call_parameters_wrap = off -ij_javascript_catch_on_new_line = false -ij_javascript_chained_call_dot_on_new_line = true -ij_javascript_class_brace_style = end_of_line -ij_javascript_comma_on_new_line = false -ij_javascript_do_while_brace_force = always -ij_javascript_else_on_new_line = false -ij_javascript_enforce_trailing_comma = keep -ij_javascript_extends_keyword_wrap = off -ij_javascript_extends_list_wrap = off -ij_javascript_field_prefix = _ -ij_javascript_file_name_style = relaxed -ij_javascript_finally_on_new_line = false -ij_javascript_for_brace_force = always -ij_javascript_for_statement_new_line_after_left_paren = true -ij_javascript_for_statement_right_paren_on_new_line = true -ij_javascript_for_statement_wrap = off -ij_javascript_force_quote_style = true -ij_javascript_force_semicolon_style = true -ij_javascript_function_expression_brace_style = end_of_line -ij_javascript_if_brace_force = always -ij_javascript_import_merge_members = global -ij_javascript_import_prefer_absolute_path = global -ij_javascript_import_sort_members = true -ij_javascript_import_sort_module_name = false -ij_javascript_import_use_node_resolution = true -ij_javascript_imports_wrap = off -ij_javascript_indent_case_from_switch = true -ij_javascript_indent_chained_calls = true -ij_javascript_indent_package_children = 0 -ij_javascript_jsx_attribute_value = braces -ij_javascript_keep_blank_lines_in_code = 1 -ij_javascript_keep_first_column_comment = true -ij_javascript_keep_indents_on_empty_lines = false -ij_javascript_keep_line_breaks = true -ij_javascript_keep_simple_blocks_in_one_line = false -ij_javascript_keep_simple_methods_in_one_line = false -ij_javascript_line_comment_add_space = false -ij_javascript_line_comment_at_first_column = false -ij_javascript_method_brace_style = end_of_line -ij_javascript_method_call_chain_wrap = off -ij_javascript_method_parameters_new_line_after_left_paren = true -ij_javascript_method_parameters_right_paren_on_new_line = true -ij_javascript_method_parameters_wrap = off -ij_javascript_object_literal_wrap = off -ij_javascript_parentheses_expression_new_line_after_left_paren = false -ij_javascript_parentheses_expression_right_paren_on_new_line = false -ij_javascript_place_assignment_sign_on_next_line = false -ij_javascript_prefer_as_type_cast = false -ij_javascript_prefer_parameters_wrap = false -ij_javascript_reformat_c_style_comments = false -ij_javascript_space_after_colon = true -ij_javascript_space_after_comma = true -ij_javascript_space_after_dots_in_rest_parameter = false -ij_javascript_space_after_generator_mult = true -ij_javascript_space_after_property_colon = true -ij_javascript_space_after_quest = true -ij_javascript_space_after_type_colon = true -ij_javascript_space_after_unary_not = false -ij_javascript_space_before_async_arrow_lparen = true -ij_javascript_space_before_catch_keyword = true -ij_javascript_space_before_catch_left_brace = true -ij_javascript_space_before_catch_parentheses = true -ij_javascript_space_before_class_lbrace = true -ij_javascript_space_before_class_left_brace = true -ij_javascript_space_before_colon = true -ij_javascript_space_before_comma = false -ij_javascript_space_before_do_left_brace = true -ij_javascript_space_before_else_keyword = true -ij_javascript_space_before_else_left_brace = true -ij_javascript_space_before_finally_keyword = true -ij_javascript_space_before_finally_left_brace = true -ij_javascript_space_before_for_left_brace = true -ij_javascript_space_before_for_parentheses = true -ij_javascript_space_before_for_semicolon = false -ij_javascript_space_before_function_left_parenth = true -ij_javascript_space_before_generator_mult = false -ij_javascript_space_before_if_left_brace = true -ij_javascript_space_before_if_parentheses = true -ij_javascript_space_before_method_call_parentheses = false -ij_javascript_space_before_method_left_brace = true -ij_javascript_space_before_method_parentheses = false -ij_javascript_space_before_property_colon = false -ij_javascript_space_before_quest = true -ij_javascript_space_before_switch_left_brace = true -ij_javascript_space_before_switch_parentheses = true -ij_javascript_space_before_try_left_brace = true -ij_javascript_space_before_type_colon = false -ij_javascript_space_before_unary_not = false -ij_javascript_space_before_while_keyword = true -ij_javascript_space_before_while_left_brace = true -ij_javascript_space_before_while_parentheses = true -ij_javascript_spaces_around_additive_operators = true -ij_javascript_spaces_around_arrow_function_operator = true -ij_javascript_spaces_around_assignment_operators = true -ij_javascript_spaces_around_bitwise_operators = true -ij_javascript_spaces_around_equality_operators = true -ij_javascript_spaces_around_logical_operators = true -ij_javascript_spaces_around_multiplicative_operators = true -ij_javascript_spaces_around_relational_operators = true -ij_javascript_spaces_around_shift_operators = true -ij_javascript_spaces_around_unary_operator = false -ij_javascript_spaces_within_array_initializer_brackets = false -ij_javascript_spaces_within_brackets = false -ij_javascript_spaces_within_catch_parentheses = false -ij_javascript_spaces_within_for_parentheses = false -ij_javascript_spaces_within_if_parentheses = false -ij_javascript_spaces_within_imports = false -ij_javascript_spaces_within_interpolation_expressions = false -ij_javascript_spaces_within_method_call_parentheses = false -ij_javascript_spaces_within_method_parentheses = false -ij_javascript_spaces_within_object_literal_braces = false -ij_javascript_spaces_within_object_type_braces = true -ij_javascript_spaces_within_parentheses = false -ij_javascript_spaces_within_switch_parentheses = false -ij_javascript_spaces_within_type_assertion = false -ij_javascript_spaces_within_union_types = true -ij_javascript_spaces_within_while_parentheses = false -ij_javascript_special_else_if_treatment = true -ij_javascript_ternary_operation_signs_on_next_line = false -ij_javascript_ternary_operation_wrap = off -ij_javascript_union_types_wrap = on_every_item -ij_javascript_use_chained_calls_group_indents = true -ij_javascript_use_double_quotes = false -ij_javascript_use_explicit_js_extension = global -ij_javascript_use_path_mapping = always -ij_javascript_use_public_modifier = false -ij_javascript_use_semicolon_after_statement = true -ij_javascript_var_declaration_wrap = off -ij_javascript_while_brace_force = always -ij_javascript_while_on_new_line = false -ij_javascript_wrap_comments = false - -[{*.ctp,*.hphp,*.phtml,*.module,*.php,*.php5,*.php4,*.inc}] -ij_php_align_assignments = true -ij_php_align_class_constants = true -ij_php_align_group_field_declarations = false -ij_php_align_inline_comments = false -ij_php_align_key_value_pairs = true -ij_php_align_multiline_array_initializer_expression = true -ij_php_align_multiline_binary_operation = true -ij_php_align_multiline_chained_methods = true -ij_php_align_multiline_extends_list = true -ij_php_align_multiline_for = true -ij_php_align_multiline_parameters = false -ij_php_align_multiline_parameters_in_calls = false -ij_php_align_multiline_ternary_operation = false -ij_php_align_phpdoc_comments = true -ij_php_align_phpdoc_param_names = true -ij_php_anonymous_brace_style = end_of_line -ij_php_api_weight = 28 -ij_php_array_initializer_new_line_after_left_brace = true -ij_php_array_initializer_right_brace_on_new_line = true -ij_php_array_initializer_wrap = on_every_item -ij_php_assignment_wrap = off -ij_php_author_weight = 28 -ij_php_binary_operation_sign_on_next_line = false -ij_php_binary_operation_wrap = off -ij_php_blank_lines_after_class_header = 0 -ij_php_blank_lines_after_function = 1 -ij_php_blank_lines_after_imports = 1 -ij_php_blank_lines_after_opening_tag = 0 -ij_php_blank_lines_after_package = 1 -ij_php_blank_lines_around_class = 0 -ij_php_blank_lines_around_constants = 0 -ij_php_blank_lines_around_field = 1 -ij_php_blank_lines_around_method = 1 -ij_php_blank_lines_before_class_end = 0 -ij_php_blank_lines_before_imports = 1 -ij_php_blank_lines_before_method_body = 0 -ij_php_blank_lines_before_package = 0 -ij_php_blank_lines_before_return_statement = 1 -ij_php_blank_lines_between_imports = 0 -ij_php_block_brace_style = end_of_line -ij_php_call_parameters_new_line_after_left_paren = false -ij_php_call_parameters_right_paren_on_new_line = false -ij_php_call_parameters_wrap = normal -ij_php_catch_on_new_line = false -ij_php_category_weight = 28 -ij_php_class_brace_style = next_line -ij_php_comma_after_last_array_element = true -ij_php_concat_spaces = true -ij_php_copyright_weight = 28 -ij_php_deprecated_weight = 28 -ij_php_do_while_brace_force = always -ij_php_else_if_style = combine -ij_php_else_on_new_line = false -ij_php_example_weight = 28 -ij_php_extends_keyword_wrap = off -ij_php_extends_list_wrap = off -ij_php_fields_default_visibility = private -ij_php_filesource_weight = 28 -ij_php_finally_on_new_line = false -ij_php_for_brace_force = always -ij_php_for_statement_new_line_after_left_paren = true -ij_php_for_statement_right_paren_on_new_line = true -ij_php_for_statement_wrap = off -ij_php_force_short_declaration_array_style = true -ij_php_global_weight = 28 -ij_php_group_use_wrap = on_every_item -ij_php_if_brace_force = always -ij_php_if_lparen_on_next_line = false -ij_php_if_rparen_on_next_line = false -ij_php_ignore_weight = 28 -ij_php_import_sorting = alphabetic -ij_php_indent_break_from_case = true -ij_php_indent_case_from_switch = true -ij_php_indent_code_in_php_tags = false -ij_php_internal_weight = 28 -ij_php_keep_blank_lines_after_lbrace = 1 -ij_php_keep_blank_lines_before_right_brace = 0 -ij_php_keep_blank_lines_in_code = 1 -ij_php_keep_blank_lines_in_declarations = 1 -ij_php_keep_control_statement_in_one_line = false -ij_php_keep_first_column_comment = true -ij_php_keep_indents_on_empty_lines = false -ij_php_keep_line_breaks = true -ij_php_keep_rparen_and_lbrace_on_one_line = true -ij_php_keep_simple_methods_in_one_line = false -ij_php_lambda_brace_style = end_of_line -ij_php_license_weight = 28 -ij_php_line_comment_add_space = true -ij_php_line_comment_at_first_column = false -ij_php_link_weight = 28 -ij_php_lower_case_boolean_const = true -ij_php_lower_case_null_const = true -ij_php_method_brace_style = next_line -ij_php_method_call_chain_wrap = off -ij_php_method_parameters_new_line_after_left_paren = true -ij_php_method_parameters_right_paren_on_new_line = true -ij_php_method_parameters_wrap = on_every_item -ij_php_method_weight = 28 -ij_php_modifier_list_wrap = false -ij_php_multiline_chained_calls_semicolon_on_new_line = false -ij_php_namespace_brace_style = 1 -ij_php_null_type_position = in_the_end -ij_php_package_weight = 28 -ij_php_param_weight = 0 -ij_php_parentheses_expression_new_line_after_left_paren = true -ij_php_parentheses_expression_right_paren_on_new_line = true -ij_php_phpdoc_blank_line_before_tags = true -ij_php_phpdoc_blank_lines_around_parameters = true -ij_php_phpdoc_keep_blank_lines = true -ij_php_phpdoc_param_spaces_between_name_and_description = 1 -ij_php_phpdoc_param_spaces_between_tag_and_type = 1 -ij_php_phpdoc_param_spaces_between_type_and_name = 1 -ij_php_phpdoc_use_fqcn = true -ij_php_phpdoc_wrap_long_lines = false -ij_php_place_assignment_sign_on_next_line = false -ij_php_place_parens_for_constructor = 1 -ij_php_property_read_weight = 28 -ij_php_property_weight = 28 -ij_php_property_write_weight = 28 -ij_php_return_type_on_new_line = false -ij_php_return_weight = 1 -ij_php_see_weight = 28 -ij_php_since_weight = 28 -ij_php_sort_phpdoc_elements = true -ij_php_space_after_colon = true -ij_php_space_after_colon_in_return_type = true -ij_php_space_after_comma = true -ij_php_space_after_for_semicolon = true -ij_php_space_after_quest = true -ij_php_space_after_type_cast = false -ij_php_space_after_unary_not = false -ij_php_space_before_array_initializer_left_brace = false -ij_php_space_before_catch_keyword = true -ij_php_space_before_catch_left_brace = true -ij_php_space_before_catch_parentheses = true -ij_php_space_before_class_left_brace = true -ij_php_space_before_closure_left_parenthesis = true -ij_php_space_before_colon = true -ij_php_space_before_colon_in_return_type = false -ij_php_space_before_comma = false -ij_php_space_before_do_left_brace = true -ij_php_space_before_else_keyword = true -ij_php_space_before_else_left_brace = true -ij_php_space_before_finally_keyword = true -ij_php_space_before_finally_left_brace = true -ij_php_space_before_for_left_brace = true -ij_php_space_before_for_parentheses = true -ij_php_space_before_for_semicolon = false -ij_php_space_before_if_left_brace = true -ij_php_space_before_if_parentheses = true -ij_php_space_before_method_call_parentheses = false -ij_php_space_before_method_left_brace = true -ij_php_space_before_method_parentheses = false -ij_php_space_before_quest = true -ij_php_space_before_switch_left_brace = true -ij_php_space_before_switch_parentheses = true -ij_php_space_before_try_left_brace = true -ij_php_space_before_unary_not = false -ij_php_space_before_while_keyword = true -ij_php_space_before_while_left_brace = true -ij_php_space_before_while_parentheses = true -ij_php_space_between_ternary_quest_and_colon = true -ij_php_spaces_around_additive_operators = true -ij_php_spaces_around_arrow = false -ij_php_spaces_around_assignment_in_declare = false -ij_php_spaces_around_assignment_operators = true -ij_php_spaces_around_bitwise_operators = true -ij_php_spaces_around_equality_operators = true -ij_php_spaces_around_logical_operators = true -ij_php_spaces_around_multiplicative_operators = true -ij_php_spaces_around_null_coalesce_operator = true -ij_php_spaces_around_relational_operators = true -ij_php_spaces_around_shift_operators = true -ij_php_spaces_around_unary_operator = false -ij_php_spaces_around_var_within_brackets = false -ij_php_spaces_within_array_initializer_braces = false -ij_php_spaces_within_brackets = false -ij_php_spaces_within_catch_parentheses = false -ij_php_spaces_within_for_parentheses = false -ij_php_spaces_within_if_parentheses = false -ij_php_spaces_within_method_call_parentheses = false -ij_php_spaces_within_method_parentheses = false -ij_php_spaces_within_parentheses = false -ij_php_spaces_within_short_echo_tags = true -ij_php_spaces_within_switch_parentheses = false -ij_php_spaces_within_while_parentheses = false -ij_php_special_else_if_treatment = true -ij_php_subpackage_weight = 28 -ij_php_ternary_operation_signs_on_next_line = false -ij_php_ternary_operation_wrap = off -ij_php_throws_weight = 2 -ij_php_todo_weight = 28 -ij_php_unknown_tag_weight = 28 -ij_php_upper_case_boolean_const = false -ij_php_upper_case_null_const = false -ij_php_uses_weight = 28 -ij_php_var_weight = 28 -ij_php_variable_naming_style = camel_case -ij_php_version_weight = 28 -ij_php_while_brace_force = always -ij_php_while_on_new_line = false - -[{*.ng,*.sht,*.html,*.shtm,*.shtml,*.htm}] -ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 -ij_html_align_attributes = true -ij_html_align_text = false -ij_html_attribute_wrap = off -ij_html_block_comment_at_first_column = true -ij_html_do_not_align_children_of_min_lines = 9000 -ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p -ij_html_do_not_indent_children_of_tags = script -ij_html_enforce_quotes = false -ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var -ij_html_keep_blank_lines = 1 -ij_html_keep_indents_on_empty_lines = false -ij_html_keep_line_breaks = true -ij_html_keep_line_breaks_in_text = true -ij_html_keep_whitespaces = false -ij_html_keep_whitespaces_inside = pre,textarea -ij_html_line_comment_at_first_column = true -ij_html_new_line_after_last_attribute = never -ij_html_new_line_before_first_attribute = never -ij_html_quote_style = double -ij_html_remove_new_line_before_tags = br -ij_html_space_after_tag_name = false -ij_html_space_around_equality_in_attribute = false -ij_html_space_inside_empty_tag = true -ij_html_text_wrap = off - -[{*.yml,*.yaml}] -ij_yaml_keep_indents_on_empty_lines = false -ij_yaml_keep_line_breaks = true - -[{.babelrc,composer.lock,.stylelintrc,jest.config,.eslintrc,bowerrc,*.json,*.jsb3,*.jsb2}] -ij_json_keep_blank_lines_in_code = 0 -ij_json_keep_indents_on_empty_lines = false -ij_json_keep_line_breaks = true -ij_json_space_after_colon = true -ij_json_space_after_comma = true -ij_json_space_before_colon = true -ij_json_space_before_comma = false -ij_json_spaces_within_braces = false -ij_json_spaces_within_brackets = false -ij_json_wrap_long_lines = false - -[{phpunit.xml.dist,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.jhm,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}] -ij_xml_block_comment_at_first_column = true -ij_xml_keep_indents_on_empty_lines = false -ij_xml_line_comment_at_first_column = true From 29c3e118fc146b5014a55b55f9ade9fe9f28c2fe Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 13:04:47 -0500 Subject: [PATCH 10/41] Fix some deprecations --- Tests/Grid/ColumnsTest.php | 23 ++++++++++++----------- Tests/Grid/GridManagerTest.php | 4 ++-- Tests/Grid/GridTest.php | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Tests/Grid/ColumnsTest.php b/Tests/Grid/ColumnsTest.php index 168e736d..ffc77114 100644 --- a/Tests/Grid/ColumnsTest.php +++ b/Tests/Grid/ColumnsTest.php @@ -38,7 +38,7 @@ public function testAddColumn() public function testAddColumnsOrder() { - list($column1, $column2, $column3, $column4, $column5) = $this->buildColumnMocks(5); + [$column1, $column2, $column3, $column4, $column5] = $this->buildColumnMocks(5); $this->columns ->addColumn($column1) @@ -47,7 +47,7 @@ public function testAddColumnsOrder() ->addColumn($column4, -1) ->addColumn($column5, 'foo'); - $this->assertAttributeSame([$column2, $column3, $column4, $column1, $column5], 'columns', $this->columns); + $this->assertSame([$column2, $column3, $column4, $column1, $column5], iterator_to_array($this->columns->getIterator())); } public function testRaiseExceptionIfGetColumnByIdDoesNotExists() @@ -92,7 +92,7 @@ public function testRaiseExceptionIfGetPrimaryColumnDoesNotExists() public function testGetPrimaryColumn() { - list($column1, $column2, $column3) = $this->buildColumnMocks(3); + [$column1, $column2, $column3] = $this->buildColumnMocks(3); $column1->method('isPrimary')->willReturn(false); $this->columns->addColumn($column1); @@ -118,7 +118,8 @@ public function testAddExtension() ->addExtension($column1) ->addExtension($column2); - $this->assertAttributeEquals(['foo' => $column1, 'bar' => $column2], 'extensions', $this->columns); + $this->assertSame($column1, $this->columns->getExtensionForColumnType('foo')); + $this->assertSame($column2, $this->columns->getExtensionForColumnType('bar')); } public function testHasExtensionForColumnType() @@ -146,7 +147,7 @@ public function testGetHash() { $this->assertEquals('', $this->columns->getHash()); - list($column1, $column2, $column3, $column4) = $this->buildColumnMocks(4); + [$column1, $column2, $column3, $column4] = $this->buildColumnMocks(4); $column1->method('getId')->willReturn('this'); $column2->method('getId')->willReturn('Is'); @@ -164,7 +165,7 @@ public function testGetHash() public function testSetColumnsOrder() { - list($column1, $column2, $column3) = $this->buildColumnMocks(3); + [$column1, $column2, $column3] = $this->buildColumnMocks(3); $column1->method('getId')->willReturn('col1'); $column2->method('getId')->willReturn('col2'); @@ -176,12 +177,12 @@ public function testSetColumnsOrder() ->addColumn($column3); $this->columns->setColumnsOrder(['col3', 'col1', 'col2']); - $this->assertAttributeSame([$column3, $column1, $column2], 'columns', $this->columns); + $this->assertSame([$column3, $column1, $column2], iterator_to_array($this->columns->getIterator())); } public function testPartialSetColumnsOrderAndKeepOthers() { - list($column1, $column2, $column3) = $this->buildColumnMocks(3); + [$column1, $column2, $column3] = $this->buildColumnMocks(3); $column1->method('getId')->willReturn('col1'); $column2->method('getId')->willReturn('col2'); @@ -193,12 +194,12 @@ public function testPartialSetColumnsOrderAndKeepOthers() ->addColumn($column3); $this->columns->setColumnsOrder(['col3', 'col2'], true); - $this->assertAttributeSame([$column3, $column2, $column1], 'columns', $this->columns); + $this->assertSame([$column3, $column2, $column1], iterator_to_array($this->columns->getIterator())); } public function testPartialSetColumnsOrderWithoutKeepOthers() { - list($column1, $column2, $column3) = $this->buildColumnMocks(3); + [$column1, $column2, $column3] = $this->buildColumnMocks(3); $column1->method('getId')->willReturn('col1'); $column2->method('getId')->willReturn('col2'); @@ -210,7 +211,7 @@ public function testPartialSetColumnsOrderWithoutKeepOthers() ->addColumn($column3); $this->columns->setColumnsOrder(['col3', 'col2'], false); - $this->assertAttributeSame([$column3, $column2], 'columns', $this->columns); + $this->assertSame([$column3, $column2], iterator_to_array($this->columns->getIterator())); } /** diff --git a/Tests/Grid/GridManagerTest.php b/Tests/Grid/GridManagerTest.php index 855aa48d..47e70fc0 100644 --- a/Tests/Grid/GridManagerTest.php +++ b/Tests/Grid/GridManagerTest.php @@ -439,7 +439,7 @@ public function testGetGridWithViewWithoutParams() $view = 'aView'; - $this->assertEquals(Response::class, get_class($this->gridManager->getGridManagerResponse($view))); + $this->assertInstanceOf(Response::class, $this->gridManager->getGridManagerResponse($view)); } public function testGetGridWithViewWithViewAndParams() @@ -471,7 +471,7 @@ public function testGetGridWithViewWithViewAndParams() $param2 = 'bar'; $params = [$param1, $param2]; - $this->assertEquals(Response::class, get_class($this->gridManager->getGridManagerResponse($view, $params))); + $this->assertInstanceOf(Response::class, $this->gridManager->getGridManagerResponse($view, $params)); } /** diff --git a/Tests/Grid/GridTest.php b/Tests/Grid/GridTest.php index b2241227..57c02e98 100644 --- a/Tests/Grid/GridTest.php +++ b/Tests/Grid/GridTest.php @@ -4422,7 +4422,7 @@ public function testGetGridWithViewWithoutParams() $view = 'aView'; - $this->assertSame(Response::class, get_class($this->grid->getGridResponse($view))); + $this->assertInstanceOf(Response::class, $this->grid->getGridResponse($view)); } public function testGetGridWithViewWithViewAndParams() @@ -4436,7 +4436,7 @@ public function testGetGridWithViewWithViewAndParams() $param2 = 'bar'; $params = [$param1, $param2]; - $this->assertSame(Response::class, get_class($this->grid->getGridResponse($view, $params))); + $this->assertInstanceOf(Response::class, $this->grid->getGridResponse($view, $params)); } /** From 7c71ffb42220e822ac20e404c5b35e2234dd41b1 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 13:05:08 -0500 Subject: [PATCH 11/41] Re-enable php 8 --- .github/workflows/phpunit.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 8855b076..65ba6431 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -14,8 +14,7 @@ jobs: strategy: matrix: -# php: ['7.4', '8.0', '8.1'] - php: ['7.4'] + php: ['7.4', '8.0', '8.1'] steps: - name: Checkout From 0888f111933d2e80d2c5bd3ff08a7c30b0295461 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 13:10:55 -0500 Subject: [PATCH 12/41] Update mongo lib --- Tests/Grid/Source/DocumentTest.php | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Grid/Source/DocumentTest.php b/Tests/Grid/Source/DocumentTest.php index b72963df..31bb6fc0 100644 --- a/Tests/Grid/Source/DocumentTest.php +++ b/Tests/Grid/Source/DocumentTest.php @@ -10,14 +10,14 @@ use APY\DataGridBundle\Grid\Mapping\Metadata\Metadata; use APY\DataGridBundle\Grid\Rows; use APY\DataGridBundle\Grid\Source\Document; -use Doctrine\ODM\MongoDB\Cursor; use Doctrine\ODM\MongoDB\DocumentManager; -use Doctrine\ODM\MongoDB\DocumentRepository; use Doctrine\ODM\MongoDB\Mapping\ClassMetadata; use Doctrine\ODM\MongoDB\Query\Builder; use Doctrine\ODM\MongoDB\Query\Expr; use Doctrine\ODM\MongoDB\Query\Query; +use Doctrine\ODM\MongoDB\Repository\DocumentRepository; use MongoDB\BSON\Regex; +use MongoDB\Driver\Cursor; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Container; diff --git a/composer.json b/composer.json index 934ab24e..670a2b4e 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "symfony/phpunit-bridge": "^4.4|^5.2", "phpunit/phpunit": "^8.5", "doctrine/orm": "~2.4,>=2.4.5", - "doctrine/mongodb-odm": "^1.1.5" + "doctrine/mongodb-odm": "^2.3" }, "suggest": { "ext-intl": "Translate the grid", From dcf7fd94daf7c5c0fc99bb2598fddd43da99a1e8 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 13:25:23 -0500 Subject: [PATCH 13/41] Rename test folder --- composer.json | 10 +++++++--- phpunit.xml.dist | 2 +- {Tests => tests}/Grid/Action/DeleteMassActionTest.php | 0 {Tests => tests}/Grid/Action/MassActionTest.php | 0 {Tests => tests}/Grid/Action/RowActionTest.php | 0 {Tests => tests}/Grid/Column/ActionsColumnTest.php | 0 {Tests => tests}/Grid/Column/ArrayColumnTest.php | 0 {Tests => tests}/Grid/Column/BlankColumnTest.php | 0 {Tests => tests}/Grid/Column/BooleanColumnTest.php | 0 {Tests => tests}/Grid/Column/ColumnTest.php | 0 {Tests => tests}/Grid/Column/DateColumnTest.php | 0 {Tests => tests}/Grid/Column/DateTimeColumnTest.php | 0 {Tests => tests}/Grid/Column/JoinColumnTest.php | 0 {Tests => tests}/Grid/Column/MassActionColumnTest.php | 0 {Tests => tests}/Grid/Column/NumberColumnTest.php | 0 {Tests => tests}/Grid/Column/RankColumnTest.php | 0 {Tests => tests}/Grid/Column/SimpleArrayColumnTest.php | 0 {Tests => tests}/Grid/Column/TextColumnTest.php | 0 {Tests => tests}/Grid/Column/TimeColumnTest.php | 0 {Tests => tests}/Grid/Column/UntypedColumnTest.php | 0 {Tests => tests}/Grid/ColumnsTest.php | 0 {Tests => tests}/Grid/FilterTest.php | 0 {Tests => tests}/Grid/GridBuilderTest.php | 0 {Tests => tests}/Grid/GridConfigBuilderTest.php | 0 {Tests => tests}/Grid/GridFactoryTest.php | 0 {Tests => tests}/Grid/GridManagerTest.php | 0 {Tests => tests}/Grid/GridRegistryTest.php | 0 {Tests => tests}/Grid/GridTest.php | 0 {Tests => tests}/Grid/Helper/ColumnsIteratorTest.php | 0 {Tests => tests}/Grid/Mapping/ColumnTest.php | 0 .../Grid/Mapping/Metadata/DriverHeapTest.php | 0 {Tests => tests}/Grid/Mapping/Metadata/ManagerTest.php | 0 .../Grid/Mapping/Metadata/MetadataTest.php | 0 {Tests => tests}/Grid/Mapping/SourceTest.php | 0 {Tests => tests}/Grid/RowTest.php | 0 {Tests => tests}/Grid/RowsTest.php | 0 {Tests => tests}/Grid/Source/DocumentTest.php | 0 {Tests => tests}/Grid/Source/VectorTest.php | 0 {Tests => tests}/Test.php | 0 {Tests => tests}/Twig/DataGridExtensionTest.php | 0 40 files changed, 8 insertions(+), 4 deletions(-) rename {Tests => tests}/Grid/Action/DeleteMassActionTest.php (100%) rename {Tests => tests}/Grid/Action/MassActionTest.php (100%) rename {Tests => tests}/Grid/Action/RowActionTest.php (100%) rename {Tests => tests}/Grid/Column/ActionsColumnTest.php (100%) rename {Tests => tests}/Grid/Column/ArrayColumnTest.php (100%) rename {Tests => tests}/Grid/Column/BlankColumnTest.php (100%) rename {Tests => tests}/Grid/Column/BooleanColumnTest.php (100%) rename {Tests => tests}/Grid/Column/ColumnTest.php (100%) rename {Tests => tests}/Grid/Column/DateColumnTest.php (100%) rename {Tests => tests}/Grid/Column/DateTimeColumnTest.php (100%) rename {Tests => tests}/Grid/Column/JoinColumnTest.php (100%) rename {Tests => tests}/Grid/Column/MassActionColumnTest.php (100%) rename {Tests => tests}/Grid/Column/NumberColumnTest.php (100%) rename {Tests => tests}/Grid/Column/RankColumnTest.php (100%) rename {Tests => tests}/Grid/Column/SimpleArrayColumnTest.php (100%) rename {Tests => tests}/Grid/Column/TextColumnTest.php (100%) rename {Tests => tests}/Grid/Column/TimeColumnTest.php (100%) rename {Tests => tests}/Grid/Column/UntypedColumnTest.php (100%) rename {Tests => tests}/Grid/ColumnsTest.php (100%) rename {Tests => tests}/Grid/FilterTest.php (100%) rename {Tests => tests}/Grid/GridBuilderTest.php (100%) rename {Tests => tests}/Grid/GridConfigBuilderTest.php (100%) rename {Tests => tests}/Grid/GridFactoryTest.php (100%) rename {Tests => tests}/Grid/GridManagerTest.php (100%) rename {Tests => tests}/Grid/GridRegistryTest.php (100%) rename {Tests => tests}/Grid/GridTest.php (100%) rename {Tests => tests}/Grid/Helper/ColumnsIteratorTest.php (100%) rename {Tests => tests}/Grid/Mapping/ColumnTest.php (100%) rename {Tests => tests}/Grid/Mapping/Metadata/DriverHeapTest.php (100%) rename {Tests => tests}/Grid/Mapping/Metadata/ManagerTest.php (100%) rename {Tests => tests}/Grid/Mapping/Metadata/MetadataTest.php (100%) rename {Tests => tests}/Grid/Mapping/SourceTest.php (100%) rename {Tests => tests}/Grid/RowTest.php (100%) rename {Tests => tests}/Grid/RowsTest.php (100%) rename {Tests => tests}/Grid/Source/DocumentTest.php (100%) rename {Tests => tests}/Grid/Source/VectorTest.php (100%) rename {Tests => tests}/Test.php (100%) rename {Tests => tests}/Twig/DataGridExtensionTest.php (100%) diff --git a/composer.json b/composer.json index 670a2b4e..57ac4276 100644 --- a/composer.json +++ b/composer.json @@ -35,9 +35,13 @@ "doctrine/mongodb-odm": "If you want to use Document as source, please require doctrine/mongodb-odm" }, "autoload": { - "psr-4": { "APY\\DataGridBundle\\": "" } + "psr-4": { + "APY\\DataGridBundle\\": "" + } }, - "provide": { - "ext-mongo": "1.5" + "autoload-dev": { + "psr-4": { + "APY\\DataGridBundle\\Tests\\": "tests" + } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0c004fcc..f8b9a6ab 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,7 +15,7 @@ - Tests + tests diff --git a/Tests/Grid/Action/DeleteMassActionTest.php b/tests/Grid/Action/DeleteMassActionTest.php similarity index 100% rename from Tests/Grid/Action/DeleteMassActionTest.php rename to tests/Grid/Action/DeleteMassActionTest.php diff --git a/Tests/Grid/Action/MassActionTest.php b/tests/Grid/Action/MassActionTest.php similarity index 100% rename from Tests/Grid/Action/MassActionTest.php rename to tests/Grid/Action/MassActionTest.php diff --git a/Tests/Grid/Action/RowActionTest.php b/tests/Grid/Action/RowActionTest.php similarity index 100% rename from Tests/Grid/Action/RowActionTest.php rename to tests/Grid/Action/RowActionTest.php diff --git a/Tests/Grid/Column/ActionsColumnTest.php b/tests/Grid/Column/ActionsColumnTest.php similarity index 100% rename from Tests/Grid/Column/ActionsColumnTest.php rename to tests/Grid/Column/ActionsColumnTest.php diff --git a/Tests/Grid/Column/ArrayColumnTest.php b/tests/Grid/Column/ArrayColumnTest.php similarity index 100% rename from Tests/Grid/Column/ArrayColumnTest.php rename to tests/Grid/Column/ArrayColumnTest.php diff --git a/Tests/Grid/Column/BlankColumnTest.php b/tests/Grid/Column/BlankColumnTest.php similarity index 100% rename from Tests/Grid/Column/BlankColumnTest.php rename to tests/Grid/Column/BlankColumnTest.php diff --git a/Tests/Grid/Column/BooleanColumnTest.php b/tests/Grid/Column/BooleanColumnTest.php similarity index 100% rename from Tests/Grid/Column/BooleanColumnTest.php rename to tests/Grid/Column/BooleanColumnTest.php diff --git a/Tests/Grid/Column/ColumnTest.php b/tests/Grid/Column/ColumnTest.php similarity index 100% rename from Tests/Grid/Column/ColumnTest.php rename to tests/Grid/Column/ColumnTest.php diff --git a/Tests/Grid/Column/DateColumnTest.php b/tests/Grid/Column/DateColumnTest.php similarity index 100% rename from Tests/Grid/Column/DateColumnTest.php rename to tests/Grid/Column/DateColumnTest.php diff --git a/Tests/Grid/Column/DateTimeColumnTest.php b/tests/Grid/Column/DateTimeColumnTest.php similarity index 100% rename from Tests/Grid/Column/DateTimeColumnTest.php rename to tests/Grid/Column/DateTimeColumnTest.php diff --git a/Tests/Grid/Column/JoinColumnTest.php b/tests/Grid/Column/JoinColumnTest.php similarity index 100% rename from Tests/Grid/Column/JoinColumnTest.php rename to tests/Grid/Column/JoinColumnTest.php diff --git a/Tests/Grid/Column/MassActionColumnTest.php b/tests/Grid/Column/MassActionColumnTest.php similarity index 100% rename from Tests/Grid/Column/MassActionColumnTest.php rename to tests/Grid/Column/MassActionColumnTest.php diff --git a/Tests/Grid/Column/NumberColumnTest.php b/tests/Grid/Column/NumberColumnTest.php similarity index 100% rename from Tests/Grid/Column/NumberColumnTest.php rename to tests/Grid/Column/NumberColumnTest.php diff --git a/Tests/Grid/Column/RankColumnTest.php b/tests/Grid/Column/RankColumnTest.php similarity index 100% rename from Tests/Grid/Column/RankColumnTest.php rename to tests/Grid/Column/RankColumnTest.php diff --git a/Tests/Grid/Column/SimpleArrayColumnTest.php b/tests/Grid/Column/SimpleArrayColumnTest.php similarity index 100% rename from Tests/Grid/Column/SimpleArrayColumnTest.php rename to tests/Grid/Column/SimpleArrayColumnTest.php diff --git a/Tests/Grid/Column/TextColumnTest.php b/tests/Grid/Column/TextColumnTest.php similarity index 100% rename from Tests/Grid/Column/TextColumnTest.php rename to tests/Grid/Column/TextColumnTest.php diff --git a/Tests/Grid/Column/TimeColumnTest.php b/tests/Grid/Column/TimeColumnTest.php similarity index 100% rename from Tests/Grid/Column/TimeColumnTest.php rename to tests/Grid/Column/TimeColumnTest.php diff --git a/Tests/Grid/Column/UntypedColumnTest.php b/tests/Grid/Column/UntypedColumnTest.php similarity index 100% rename from Tests/Grid/Column/UntypedColumnTest.php rename to tests/Grid/Column/UntypedColumnTest.php diff --git a/Tests/Grid/ColumnsTest.php b/tests/Grid/ColumnsTest.php similarity index 100% rename from Tests/Grid/ColumnsTest.php rename to tests/Grid/ColumnsTest.php diff --git a/Tests/Grid/FilterTest.php b/tests/Grid/FilterTest.php similarity index 100% rename from Tests/Grid/FilterTest.php rename to tests/Grid/FilterTest.php diff --git a/Tests/Grid/GridBuilderTest.php b/tests/Grid/GridBuilderTest.php similarity index 100% rename from Tests/Grid/GridBuilderTest.php rename to tests/Grid/GridBuilderTest.php diff --git a/Tests/Grid/GridConfigBuilderTest.php b/tests/Grid/GridConfigBuilderTest.php similarity index 100% rename from Tests/Grid/GridConfigBuilderTest.php rename to tests/Grid/GridConfigBuilderTest.php diff --git a/Tests/Grid/GridFactoryTest.php b/tests/Grid/GridFactoryTest.php similarity index 100% rename from Tests/Grid/GridFactoryTest.php rename to tests/Grid/GridFactoryTest.php diff --git a/Tests/Grid/GridManagerTest.php b/tests/Grid/GridManagerTest.php similarity index 100% rename from Tests/Grid/GridManagerTest.php rename to tests/Grid/GridManagerTest.php diff --git a/Tests/Grid/GridRegistryTest.php b/tests/Grid/GridRegistryTest.php similarity index 100% rename from Tests/Grid/GridRegistryTest.php rename to tests/Grid/GridRegistryTest.php diff --git a/Tests/Grid/GridTest.php b/tests/Grid/GridTest.php similarity index 100% rename from Tests/Grid/GridTest.php rename to tests/Grid/GridTest.php diff --git a/Tests/Grid/Helper/ColumnsIteratorTest.php b/tests/Grid/Helper/ColumnsIteratorTest.php similarity index 100% rename from Tests/Grid/Helper/ColumnsIteratorTest.php rename to tests/Grid/Helper/ColumnsIteratorTest.php diff --git a/Tests/Grid/Mapping/ColumnTest.php b/tests/Grid/Mapping/ColumnTest.php similarity index 100% rename from Tests/Grid/Mapping/ColumnTest.php rename to tests/Grid/Mapping/ColumnTest.php diff --git a/Tests/Grid/Mapping/Metadata/DriverHeapTest.php b/tests/Grid/Mapping/Metadata/DriverHeapTest.php similarity index 100% rename from Tests/Grid/Mapping/Metadata/DriverHeapTest.php rename to tests/Grid/Mapping/Metadata/DriverHeapTest.php diff --git a/Tests/Grid/Mapping/Metadata/ManagerTest.php b/tests/Grid/Mapping/Metadata/ManagerTest.php similarity index 100% rename from Tests/Grid/Mapping/Metadata/ManagerTest.php rename to tests/Grid/Mapping/Metadata/ManagerTest.php diff --git a/Tests/Grid/Mapping/Metadata/MetadataTest.php b/tests/Grid/Mapping/Metadata/MetadataTest.php similarity index 100% rename from Tests/Grid/Mapping/Metadata/MetadataTest.php rename to tests/Grid/Mapping/Metadata/MetadataTest.php diff --git a/Tests/Grid/Mapping/SourceTest.php b/tests/Grid/Mapping/SourceTest.php similarity index 100% rename from Tests/Grid/Mapping/SourceTest.php rename to tests/Grid/Mapping/SourceTest.php diff --git a/Tests/Grid/RowTest.php b/tests/Grid/RowTest.php similarity index 100% rename from Tests/Grid/RowTest.php rename to tests/Grid/RowTest.php diff --git a/Tests/Grid/RowsTest.php b/tests/Grid/RowsTest.php similarity index 100% rename from Tests/Grid/RowsTest.php rename to tests/Grid/RowsTest.php diff --git a/Tests/Grid/Source/DocumentTest.php b/tests/Grid/Source/DocumentTest.php similarity index 100% rename from Tests/Grid/Source/DocumentTest.php rename to tests/Grid/Source/DocumentTest.php diff --git a/Tests/Grid/Source/VectorTest.php b/tests/Grid/Source/VectorTest.php similarity index 100% rename from Tests/Grid/Source/VectorTest.php rename to tests/Grid/Source/VectorTest.php diff --git a/Tests/Test.php b/tests/Test.php similarity index 100% rename from Tests/Test.php rename to tests/Test.php diff --git a/Tests/Twig/DataGridExtensionTest.php b/tests/Twig/DataGridExtensionTest.php similarity index 100% rename from Tests/Twig/DataGridExtensionTest.php rename to tests/Twig/DataGridExtensionTest.php From f33ef7aa4e48e165ae08e9e948214bfa75cfe00b Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 15:14:22 -0500 Subject: [PATCH 14/41] Move code into src dir --- composer.json | 2 +- APYDataGridBundle.php => src/APYDataGridBundle.php | 0 .../DependencyInjection}/APYDataGridExtension.php | 0 .../Compiler/GridExtensionPass.php | 0 .../DependencyInjection}/Compiler/GridPass.php | 0 .../Compiler/TranslationPass.php | 0 .../DependencyInjection}/Configuration.php | 0 {Grid => src/Grid}/AbstractType.php | 0 {Grid => src/Grid}/Action/DeleteMassAction.php | 0 {Grid => src/Grid}/Action/MassAction.php | 0 {Grid => src/Grid}/Action/MassActionInterface.php | 0 {Grid => src/Grid}/Action/RowAction.php | 0 {Grid => src/Grid}/Action/RowActionInterface.php | 0 {Grid => src/Grid}/Column/ActionsColumn.php | 0 {Grid => src/Grid}/Column/ArrayColumn.php | 0 {Grid => src/Grid}/Column/BlankColumn.php | 0 {Grid => src/Grid}/Column/BooleanColumn.php | 0 {Grid => src/Grid}/Column/Column.php | 0 {Grid => src/Grid}/Column/DateColumn.php | 0 {Grid => src/Grid}/Column/DateTimeColumn.php | 0 {Grid => src/Grid}/Column/JoinColumn.php | 0 {Grid => src/Grid}/Column/MassActionColumn.php | 0 {Grid => src/Grid}/Column/NumberColumn.php | 0 {Grid => src/Grid}/Column/RankColumn.php | 0 {Grid => src/Grid}/Column/SimpleArrayColumn.php | 0 {Grid => src/Grid}/Column/TextColumn.php | 0 {Grid => src/Grid}/Column/TimeColumn.php | 0 {Grid => src/Grid}/Column/UntypedColumn.php | 0 {Grid => src/Grid}/Columns.php | 0 .../Exception/ColumnAlreadyExistsException.php | 0 .../Grid}/Exception/ColumnNotFoundException.php | 0 .../Grid}/Exception/InvalidArgumentException.php | 0 .../Exception/PropertyAccessDeniedException.php | 0 .../Grid}/Exception/TypeAlreadyExistsException.php | 0 .../Grid}/Exception/TypeNotFoundException.php | 0 .../Grid}/Exception/UnexpectedTypeException.php | 0 {Grid => src/Grid}/Export/CSVExport.php | 0 {Grid => src/Grid}/Export/DSVExport.php | 0 {Grid => src/Grid}/Export/ExcelExport.php | 0 {Grid => src/Grid}/Export/Export.php | 0 {Grid => src/Grid}/Export/ExportInterface.php | 0 {Grid => src/Grid}/Export/JSONExport.php | 0 {Grid => src/Grid}/Export/PHPExcel2003Export.php | 0 {Grid => src/Grid}/Export/PHPExcel2007Export.php | 0 {Grid => src/Grid}/Export/PHPExcel5Export.php | 0 {Grid => src/Grid}/Export/PHPExcelHTMLExport.php | 0 {Grid => src/Grid}/Export/PHPExcelPDFExport.php | 0 {Grid => src/Grid}/Export/SCSVExport.php | 0 {Grid => src/Grid}/Export/TSVExport.php | 0 {Grid => src/Grid}/Export/XMLExport.php | 0 {Grid => src/Grid}/Filter.php | 0 {Grid => src/Grid}/Grid.php | 5 +++++ {Grid => src/Grid}/GridBuilder.php | 0 {Grid => src/Grid}/GridBuilderInterface.php | 0 {Grid => src/Grid}/GridConfigBuilder.php | 0 {Grid => src/Grid}/GridConfigBuilderInterface.php | 0 {Grid => src/Grid}/GridConfigInterface.php | 0 {Grid => src/Grid}/GridFactory.php | 0 {Grid => src/Grid}/GridFactoryInterface.php | 0 {Grid => src/Grid}/GridInterface.php | 0 {Grid => src/Grid}/GridManager.php | 0 {Grid => src/Grid}/GridRegistry.php | 0 {Grid => src/Grid}/GridRegistryInterface.php | 0 {Grid => src/Grid}/GridTypeInterface.php | 0 {Grid => src/Grid}/Helper/ColumnsIterator.php | 0 {Grid => src/Grid}/Helper/ORMCountWalker.php | 0 {Grid => src/Grid}/Mapping/Column.php | 0 {Grid => src/Grid}/Mapping/Driver/Annotation.php | 0 .../Grid}/Mapping/Driver/DriverInterface.php | 0 {Grid => src/Grid}/Mapping/Metadata/DriverHeap.php | 0 {Grid => src/Grid}/Mapping/Metadata/Manager.php | 0 {Grid => src/Grid}/Mapping/Metadata/Metadata.php | 0 {Grid => src/Grid}/Mapping/Source.php | 0 {Grid => src/Grid}/Row.php | 0 {Grid => src/Grid}/Rows.php | 0 {Grid => src/Grid}/Source/Document.php | 0 {Grid => src/Grid}/Source/Entity.php | 0 {Grid => src/Grid}/Source/Source.php | 0 {Grid => src/Grid}/Source/Vector.php | 0 {Grid => src/Grid}/Type/GridType.php | 0 {Resources => src/Resources}/config/columns.xml | 0 {Resources => src/Resources}/config/grid.yml | 0 {Resources => src/Resources}/config/services.xml | 0 .../annotations/association_mapping.md | 0 .../annotations/column_annotation_class.md | 0 .../annotations/column_annotation_property.md | 0 .../annotations/dql_function.md | 0 .../annotations/source_annotation.md | 0 .../columns_configuration/filters/create_filter.md | 0 .../columns_configuration/filters/input_filter.md | 0 .../columns_configuration/filters/select_filter.md | 0 .../Resources}/doc/columns_configuration/index.md | 0 .../doc/columns_configuration/types/array_column.md | 0 .../doc/columns_configuration/types/blank_column.md | 0 .../columns_configuration/types/boolean_column.md | 0 .../columns_configuration/types/create_column.md | 0 .../doc/columns_configuration/types/date_column.md | 0 .../columns_configuration/types/datetime_column.md | 0 .../doc/columns_configuration/types/join_column.md | 0 .../columns_configuration/types/number_column.md | 0 .../doc/columns_configuration/types/rank_column.md | 0 .../doc/columns_configuration/types/text_column.md | 0 .../doc/columns_configuration/types/time_column.md | 0 {Resources => src/Resources}/doc/configuration.md | 0 .../Resources}/doc/export/create_export.md | 0 {Resources => src/Resources}/doc/export/index.md | 0 .../PHPExcel/PHPExcel_HTML_export.md | 0 .../PHPExcel/PHPExcel_PDF_export.md | 0 .../PHPExcel/PHPExcel_excel2003_export.md | 0 .../PHPExcel/PHPExcel_excel2007_export.md | 0 .../PHPExcel/PHPExcel_excel5_export.md | 0 .../doc/export/native_exports/CSV_export.md | 0 .../doc/export/native_exports/DSV_export.md | 0 .../doc/export/native_exports/Excel_export.md | 0 .../doc/export/native_exports/JSON_export.md | 0 .../doc/export/native_exports/SCSV_export.md | 0 .../doc/export/native_exports/TSV_export.md | 0 .../doc/export/native_exports/XML_export.md | 0 {Resources => src/Resources}/doc/features.md | 0 {Resources => src/Resources}/doc/getting_started.md | 0 {Resources => src/Resources}/doc/grid.md | 0 .../doc/grid_configuration/add_actions_column.md | 0 .../Resources}/doc/grid_configuration/add_column.md | 0 .../grid_configuration/add_delete_mass_action.md | 0 .../Resources}/doc/grid_configuration/add_export.md | 0 .../doc/grid_configuration/add_mass_action.md | 0 .../doc/grid_configuration/add_row_action.md | 0 .../doc/grid_configuration/always_show_grid.md | 0 .../doc/grid_configuration/grid_response.md | 0 .../doc/grid_configuration/hide_show_columns.md | 0 .../Resources}/doc/grid_configuration/index.md | 0 .../doc/grid_configuration/manipulate_column.md | 0 .../manipulate_column_render_cell.md | 0 .../grid_configuration/manipulate_count_query.md | 0 .../doc/grid_configuration/manipulate_query.md | 0 .../manipulate_row_action_rendering.md | 0 .../doc/grid_configuration/manipulate_rows_data.md | 0 .../doc/grid_configuration/multi_grid_manager.md | 0 .../doc/grid_configuration/set_columns_order.md | 0 .../Resources}/doc/grid_configuration/set_data.md | 0 .../doc/grid_configuration/set_default_filters.md | 0 .../doc/grid_configuration/set_default_limit.md | 0 .../doc/grid_configuration/set_default_order.md | 0 .../doc/grid_configuration/set_default_page.md | 0 .../doc/grid_configuration/set_grid_identifier.md | 0 .../doc/grid_configuration/set_grid_persistence.md | 0 .../doc/grid_configuration/set_grid_route.md | 0 .../Resources}/doc/grid_configuration/set_limits.md | 0 .../doc/grid_configuration/set_max_results.md | 0 .../doc/grid_configuration/set_no_data_message.md | 0 .../doc/grid_configuration/set_no_result_message.md | 0 .../doc/grid_configuration/set_permanent_filters.md | 0 .../doc/grid_configuration/set_prefix_titles.md | 0 .../grid_configuration/set_size_actions_column.md | 0 .../grid_configuration/set_title_actions_column.md | 0 .../doc/grid_configuration/working_example.css | 0 .../doc/grid_configuration/working_example.md | 0 {Resources => src/Resources}/doc/images/false.png | Bin .../Resources}/doc/images/pagerfanta.png | Bin .../Resources}/doc/images/screenshot_database.png | Bin .../Resources}/doc/images/screenshot_en.png | Bin .../Resources}/doc/images/screenshot_fr.png | Bin .../Resources}/doc/images/screenshot_full.png | Bin .../Resources}/doc/images/sort_down.gif | Bin {Resources => src/Resources}/doc/images/sort_up.gif | Bin {Resources => src/Resources}/doc/images/true.png | Bin {Resources => src/Resources}/doc/index.md | 0 .../Resources}/doc/source/document_source.md | 0 .../Resources}/doc/source/entity_source.md | 0 {Resources => src/Resources}/doc/source/index.md | 0 .../Resources}/doc/source/vector_source.md | 0 {Resources => src/Resources}/doc/summary.md | 0 .../Resources}/doc/template/cell_rendering.md | 0 .../Resources}/doc/template/filter_rendering.md | 0 {Resources => src/Resources}/doc/template/index.md | 0 .../doc/template/overriding_internal_blocks.md | 0 .../Resources}/doc/template/pagerfanta_example.css | 0 .../Resources}/doc/template/render_an_ajax_grid.md | 0 .../doc/template/render_external_filters.md | 0 .../doc/template/render_pagerfanta_pager.md | 0 .../Resources}/translations/messages.cs.xliff | 0 .../Resources}/translations/messages.de.xliff | 0 .../Resources}/translations/messages.en.xliff | 0 .../Resources}/translations/messages.es.xliff | 0 .../Resources}/translations/messages.fr.xliff | 0 .../Resources}/translations/messages.it.xliff | 0 .../Resources}/translations/messages.ja.xliff | 0 .../Resources}/translations/messages.nl.xliff | 0 .../Resources}/translations/messages.pl.xliff | 0 .../Resources}/translations/messages.pt_BR.xliff | 0 .../Resources}/translations/messages.ru.xliff | 0 .../Resources}/translations/messages.sk.xliff | 0 .../Resources}/translations/messages.tr.xliff | 0 {Resources => src/Resources}/views/blocks.html.twig | 0 .../Resources}/views/blocks_js.jquery.html.twig | 0 .../ColumnTitleAnnotationTranslationExtractor.php | 0 {Twig => src/Twig}/DataGridExtension.php | 0 197 files changed, 6 insertions(+), 1 deletion(-) rename APYDataGridBundle.php => src/APYDataGridBundle.php (100%) rename {DependencyInjection => src/DependencyInjection}/APYDataGridExtension.php (100%) rename {DependencyInjection => src/DependencyInjection}/Compiler/GridExtensionPass.php (100%) rename {DependencyInjection => src/DependencyInjection}/Compiler/GridPass.php (100%) rename {DependencyInjection => src/DependencyInjection}/Compiler/TranslationPass.php (100%) rename {DependencyInjection => src/DependencyInjection}/Configuration.php (100%) rename {Grid => src/Grid}/AbstractType.php (100%) rename {Grid => src/Grid}/Action/DeleteMassAction.php (100%) rename {Grid => src/Grid}/Action/MassAction.php (100%) rename {Grid => src/Grid}/Action/MassActionInterface.php (100%) rename {Grid => src/Grid}/Action/RowAction.php (100%) rename {Grid => src/Grid}/Action/RowActionInterface.php (100%) rename {Grid => src/Grid}/Column/ActionsColumn.php (100%) rename {Grid => src/Grid}/Column/ArrayColumn.php (100%) rename {Grid => src/Grid}/Column/BlankColumn.php (100%) rename {Grid => src/Grid}/Column/BooleanColumn.php (100%) rename {Grid => src/Grid}/Column/Column.php (100%) rename {Grid => src/Grid}/Column/DateColumn.php (100%) rename {Grid => src/Grid}/Column/DateTimeColumn.php (100%) rename {Grid => src/Grid}/Column/JoinColumn.php (100%) rename {Grid => src/Grid}/Column/MassActionColumn.php (100%) rename {Grid => src/Grid}/Column/NumberColumn.php (100%) rename {Grid => src/Grid}/Column/RankColumn.php (100%) rename {Grid => src/Grid}/Column/SimpleArrayColumn.php (100%) rename {Grid => src/Grid}/Column/TextColumn.php (100%) rename {Grid => src/Grid}/Column/TimeColumn.php (100%) rename {Grid => src/Grid}/Column/UntypedColumn.php (100%) rename {Grid => src/Grid}/Columns.php (100%) rename {Grid => src/Grid}/Exception/ColumnAlreadyExistsException.php (100%) rename {Grid => src/Grid}/Exception/ColumnNotFoundException.php (100%) rename {Grid => src/Grid}/Exception/InvalidArgumentException.php (100%) rename {Grid => src/Grid}/Exception/PropertyAccessDeniedException.php (100%) rename {Grid => src/Grid}/Exception/TypeAlreadyExistsException.php (100%) rename {Grid => src/Grid}/Exception/TypeNotFoundException.php (100%) rename {Grid => src/Grid}/Exception/UnexpectedTypeException.php (100%) rename {Grid => src/Grid}/Export/CSVExport.php (100%) rename {Grid => src/Grid}/Export/DSVExport.php (100%) rename {Grid => src/Grid}/Export/ExcelExport.php (100%) rename {Grid => src/Grid}/Export/Export.php (100%) rename {Grid => src/Grid}/Export/ExportInterface.php (100%) rename {Grid => src/Grid}/Export/JSONExport.php (100%) rename {Grid => src/Grid}/Export/PHPExcel2003Export.php (100%) rename {Grid => src/Grid}/Export/PHPExcel2007Export.php (100%) rename {Grid => src/Grid}/Export/PHPExcel5Export.php (100%) rename {Grid => src/Grid}/Export/PHPExcelHTMLExport.php (100%) rename {Grid => src/Grid}/Export/PHPExcelPDFExport.php (100%) rename {Grid => src/Grid}/Export/SCSVExport.php (100%) rename {Grid => src/Grid}/Export/TSVExport.php (100%) rename {Grid => src/Grid}/Export/XMLExport.php (100%) rename {Grid => src/Grid}/Filter.php (100%) rename {Grid => src/Grid}/Grid.php (99%) rename {Grid => src/Grid}/GridBuilder.php (100%) rename {Grid => src/Grid}/GridBuilderInterface.php (100%) rename {Grid => src/Grid}/GridConfigBuilder.php (100%) rename {Grid => src/Grid}/GridConfigBuilderInterface.php (100%) rename {Grid => src/Grid}/GridConfigInterface.php (100%) rename {Grid => src/Grid}/GridFactory.php (100%) rename {Grid => src/Grid}/GridFactoryInterface.php (100%) rename {Grid => src/Grid}/GridInterface.php (100%) rename {Grid => src/Grid}/GridManager.php (100%) rename {Grid => src/Grid}/GridRegistry.php (100%) rename {Grid => src/Grid}/GridRegistryInterface.php (100%) rename {Grid => src/Grid}/GridTypeInterface.php (100%) rename {Grid => src/Grid}/Helper/ColumnsIterator.php (100%) rename {Grid => src/Grid}/Helper/ORMCountWalker.php (100%) rename {Grid => src/Grid}/Mapping/Column.php (100%) rename {Grid => src/Grid}/Mapping/Driver/Annotation.php (100%) rename {Grid => src/Grid}/Mapping/Driver/DriverInterface.php (100%) rename {Grid => src/Grid}/Mapping/Metadata/DriverHeap.php (100%) rename {Grid => src/Grid}/Mapping/Metadata/Manager.php (100%) rename {Grid => src/Grid}/Mapping/Metadata/Metadata.php (100%) rename {Grid => src/Grid}/Mapping/Source.php (100%) rename {Grid => src/Grid}/Row.php (100%) rename {Grid => src/Grid}/Rows.php (100%) rename {Grid => src/Grid}/Source/Document.php (100%) rename {Grid => src/Grid}/Source/Entity.php (100%) rename {Grid => src/Grid}/Source/Source.php (100%) rename {Grid => src/Grid}/Source/Vector.php (100%) rename {Grid => src/Grid}/Type/GridType.php (100%) rename {Resources => src/Resources}/config/columns.xml (100%) rename {Resources => src/Resources}/config/grid.yml (100%) rename {Resources => src/Resources}/config/services.xml (100%) rename {Resources => src/Resources}/doc/columns_configuration/annotations/association_mapping.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/annotations/column_annotation_class.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/annotations/column_annotation_property.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/annotations/dql_function.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/annotations/source_annotation.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/filters/create_filter.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/filters/input_filter.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/filters/select_filter.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/index.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/array_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/blank_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/boolean_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/create_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/date_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/datetime_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/join_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/number_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/rank_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/text_column.md (100%) rename {Resources => src/Resources}/doc/columns_configuration/types/time_column.md (100%) rename {Resources => src/Resources}/doc/configuration.md (100%) rename {Resources => src/Resources}/doc/export/create_export.md (100%) rename {Resources => src/Resources}/doc/export/index.md (100%) rename {Resources => src/Resources}/doc/export/library-dependent_exports/PHPExcel/PHPExcel_HTML_export.md (100%) rename {Resources => src/Resources}/doc/export/library-dependent_exports/PHPExcel/PHPExcel_PDF_export.md (100%) rename {Resources => src/Resources}/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2003_export.md (100%) rename {Resources => src/Resources}/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2007_export.md (100%) rename {Resources => src/Resources}/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel5_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/CSV_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/DSV_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/Excel_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/JSON_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/SCSV_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/TSV_export.md (100%) rename {Resources => src/Resources}/doc/export/native_exports/XML_export.md (100%) rename {Resources => src/Resources}/doc/features.md (100%) rename {Resources => src/Resources}/doc/getting_started.md (100%) rename {Resources => src/Resources}/doc/grid.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/add_actions_column.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/add_column.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/add_delete_mass_action.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/add_export.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/add_mass_action.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/add_row_action.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/always_show_grid.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/grid_response.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/hide_show_columns.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/index.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/manipulate_column.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/manipulate_column_render_cell.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/manipulate_count_query.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/manipulate_query.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/manipulate_row_action_rendering.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/manipulate_rows_data.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/multi_grid_manager.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_columns_order.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_data.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_default_filters.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_default_limit.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_default_order.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_default_page.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_grid_identifier.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_grid_persistence.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_grid_route.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_limits.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_max_results.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_no_data_message.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_no_result_message.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_permanent_filters.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_prefix_titles.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_size_actions_column.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/set_title_actions_column.md (100%) rename {Resources => src/Resources}/doc/grid_configuration/working_example.css (100%) rename {Resources => src/Resources}/doc/grid_configuration/working_example.md (100%) rename {Resources => src/Resources}/doc/images/false.png (100%) rename {Resources => src/Resources}/doc/images/pagerfanta.png (100%) rename {Resources => src/Resources}/doc/images/screenshot_database.png (100%) rename {Resources => src/Resources}/doc/images/screenshot_en.png (100%) rename {Resources => src/Resources}/doc/images/screenshot_fr.png (100%) rename {Resources => src/Resources}/doc/images/screenshot_full.png (100%) rename {Resources => src/Resources}/doc/images/sort_down.gif (100%) rename {Resources => src/Resources}/doc/images/sort_up.gif (100%) rename {Resources => src/Resources}/doc/images/true.png (100%) rename {Resources => src/Resources}/doc/index.md (100%) rename {Resources => src/Resources}/doc/source/document_source.md (100%) rename {Resources => src/Resources}/doc/source/entity_source.md (100%) rename {Resources => src/Resources}/doc/source/index.md (100%) rename {Resources => src/Resources}/doc/source/vector_source.md (100%) rename {Resources => src/Resources}/doc/summary.md (100%) rename {Resources => src/Resources}/doc/template/cell_rendering.md (100%) rename {Resources => src/Resources}/doc/template/filter_rendering.md (100%) rename {Resources => src/Resources}/doc/template/index.md (100%) rename {Resources => src/Resources}/doc/template/overriding_internal_blocks.md (100%) rename {Resources => src/Resources}/doc/template/pagerfanta_example.css (100%) rename {Resources => src/Resources}/doc/template/render_an_ajax_grid.md (100%) rename {Resources => src/Resources}/doc/template/render_external_filters.md (100%) rename {Resources => src/Resources}/doc/template/render_pagerfanta_pager.md (100%) rename {Resources => src/Resources}/translations/messages.cs.xliff (100%) rename {Resources => src/Resources}/translations/messages.de.xliff (100%) rename {Resources => src/Resources}/translations/messages.en.xliff (100%) rename {Resources => src/Resources}/translations/messages.es.xliff (100%) rename {Resources => src/Resources}/translations/messages.fr.xliff (100%) rename {Resources => src/Resources}/translations/messages.it.xliff (100%) rename {Resources => src/Resources}/translations/messages.ja.xliff (100%) rename {Resources => src/Resources}/translations/messages.nl.xliff (100%) rename {Resources => src/Resources}/translations/messages.pl.xliff (100%) rename {Resources => src/Resources}/translations/messages.pt_BR.xliff (100%) rename {Resources => src/Resources}/translations/messages.ru.xliff (100%) rename {Resources => src/Resources}/translations/messages.sk.xliff (100%) rename {Resources => src/Resources}/translations/messages.tr.xliff (100%) rename {Resources => src/Resources}/views/blocks.html.twig (100%) rename {Resources => src/Resources}/views/blocks_js.jquery.html.twig (100%) rename {Translation => src/Translation}/ColumnTitleAnnotationTranslationExtractor.php (100%) rename {Twig => src/Twig}/DataGridExtension.php (100%) diff --git a/composer.json b/composer.json index 57ac4276..4f340485 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ }, "autoload": { "psr-4": { - "APY\\DataGridBundle\\": "" + "APY\\DataGridBundle\\": "src" } }, "autoload-dev": { diff --git a/APYDataGridBundle.php b/src/APYDataGridBundle.php similarity index 100% rename from APYDataGridBundle.php rename to src/APYDataGridBundle.php diff --git a/DependencyInjection/APYDataGridExtension.php b/src/DependencyInjection/APYDataGridExtension.php similarity index 100% rename from DependencyInjection/APYDataGridExtension.php rename to src/DependencyInjection/APYDataGridExtension.php diff --git a/DependencyInjection/Compiler/GridExtensionPass.php b/src/DependencyInjection/Compiler/GridExtensionPass.php similarity index 100% rename from DependencyInjection/Compiler/GridExtensionPass.php rename to src/DependencyInjection/Compiler/GridExtensionPass.php diff --git a/DependencyInjection/Compiler/GridPass.php b/src/DependencyInjection/Compiler/GridPass.php similarity index 100% rename from DependencyInjection/Compiler/GridPass.php rename to src/DependencyInjection/Compiler/GridPass.php diff --git a/DependencyInjection/Compiler/TranslationPass.php b/src/DependencyInjection/Compiler/TranslationPass.php similarity index 100% rename from DependencyInjection/Compiler/TranslationPass.php rename to src/DependencyInjection/Compiler/TranslationPass.php diff --git a/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php similarity index 100% rename from DependencyInjection/Configuration.php rename to src/DependencyInjection/Configuration.php diff --git a/Grid/AbstractType.php b/src/Grid/AbstractType.php similarity index 100% rename from Grid/AbstractType.php rename to src/Grid/AbstractType.php diff --git a/Grid/Action/DeleteMassAction.php b/src/Grid/Action/DeleteMassAction.php similarity index 100% rename from Grid/Action/DeleteMassAction.php rename to src/Grid/Action/DeleteMassAction.php diff --git a/Grid/Action/MassAction.php b/src/Grid/Action/MassAction.php similarity index 100% rename from Grid/Action/MassAction.php rename to src/Grid/Action/MassAction.php diff --git a/Grid/Action/MassActionInterface.php b/src/Grid/Action/MassActionInterface.php similarity index 100% rename from Grid/Action/MassActionInterface.php rename to src/Grid/Action/MassActionInterface.php diff --git a/Grid/Action/RowAction.php b/src/Grid/Action/RowAction.php similarity index 100% rename from Grid/Action/RowAction.php rename to src/Grid/Action/RowAction.php diff --git a/Grid/Action/RowActionInterface.php b/src/Grid/Action/RowActionInterface.php similarity index 100% rename from Grid/Action/RowActionInterface.php rename to src/Grid/Action/RowActionInterface.php diff --git a/Grid/Column/ActionsColumn.php b/src/Grid/Column/ActionsColumn.php similarity index 100% rename from Grid/Column/ActionsColumn.php rename to src/Grid/Column/ActionsColumn.php diff --git a/Grid/Column/ArrayColumn.php b/src/Grid/Column/ArrayColumn.php similarity index 100% rename from Grid/Column/ArrayColumn.php rename to src/Grid/Column/ArrayColumn.php diff --git a/Grid/Column/BlankColumn.php b/src/Grid/Column/BlankColumn.php similarity index 100% rename from Grid/Column/BlankColumn.php rename to src/Grid/Column/BlankColumn.php diff --git a/Grid/Column/BooleanColumn.php b/src/Grid/Column/BooleanColumn.php similarity index 100% rename from Grid/Column/BooleanColumn.php rename to src/Grid/Column/BooleanColumn.php diff --git a/Grid/Column/Column.php b/src/Grid/Column/Column.php similarity index 100% rename from Grid/Column/Column.php rename to src/Grid/Column/Column.php diff --git a/Grid/Column/DateColumn.php b/src/Grid/Column/DateColumn.php similarity index 100% rename from Grid/Column/DateColumn.php rename to src/Grid/Column/DateColumn.php diff --git a/Grid/Column/DateTimeColumn.php b/src/Grid/Column/DateTimeColumn.php similarity index 100% rename from Grid/Column/DateTimeColumn.php rename to src/Grid/Column/DateTimeColumn.php diff --git a/Grid/Column/JoinColumn.php b/src/Grid/Column/JoinColumn.php similarity index 100% rename from Grid/Column/JoinColumn.php rename to src/Grid/Column/JoinColumn.php diff --git a/Grid/Column/MassActionColumn.php b/src/Grid/Column/MassActionColumn.php similarity index 100% rename from Grid/Column/MassActionColumn.php rename to src/Grid/Column/MassActionColumn.php diff --git a/Grid/Column/NumberColumn.php b/src/Grid/Column/NumberColumn.php similarity index 100% rename from Grid/Column/NumberColumn.php rename to src/Grid/Column/NumberColumn.php diff --git a/Grid/Column/RankColumn.php b/src/Grid/Column/RankColumn.php similarity index 100% rename from Grid/Column/RankColumn.php rename to src/Grid/Column/RankColumn.php diff --git a/Grid/Column/SimpleArrayColumn.php b/src/Grid/Column/SimpleArrayColumn.php similarity index 100% rename from Grid/Column/SimpleArrayColumn.php rename to src/Grid/Column/SimpleArrayColumn.php diff --git a/Grid/Column/TextColumn.php b/src/Grid/Column/TextColumn.php similarity index 100% rename from Grid/Column/TextColumn.php rename to src/Grid/Column/TextColumn.php diff --git a/Grid/Column/TimeColumn.php b/src/Grid/Column/TimeColumn.php similarity index 100% rename from Grid/Column/TimeColumn.php rename to src/Grid/Column/TimeColumn.php diff --git a/Grid/Column/UntypedColumn.php b/src/Grid/Column/UntypedColumn.php similarity index 100% rename from Grid/Column/UntypedColumn.php rename to src/Grid/Column/UntypedColumn.php diff --git a/Grid/Columns.php b/src/Grid/Columns.php similarity index 100% rename from Grid/Columns.php rename to src/Grid/Columns.php diff --git a/Grid/Exception/ColumnAlreadyExistsException.php b/src/Grid/Exception/ColumnAlreadyExistsException.php similarity index 100% rename from Grid/Exception/ColumnAlreadyExistsException.php rename to src/Grid/Exception/ColumnAlreadyExistsException.php diff --git a/Grid/Exception/ColumnNotFoundException.php b/src/Grid/Exception/ColumnNotFoundException.php similarity index 100% rename from Grid/Exception/ColumnNotFoundException.php rename to src/Grid/Exception/ColumnNotFoundException.php diff --git a/Grid/Exception/InvalidArgumentException.php b/src/Grid/Exception/InvalidArgumentException.php similarity index 100% rename from Grid/Exception/InvalidArgumentException.php rename to src/Grid/Exception/InvalidArgumentException.php diff --git a/Grid/Exception/PropertyAccessDeniedException.php b/src/Grid/Exception/PropertyAccessDeniedException.php similarity index 100% rename from Grid/Exception/PropertyAccessDeniedException.php rename to src/Grid/Exception/PropertyAccessDeniedException.php diff --git a/Grid/Exception/TypeAlreadyExistsException.php b/src/Grid/Exception/TypeAlreadyExistsException.php similarity index 100% rename from Grid/Exception/TypeAlreadyExistsException.php rename to src/Grid/Exception/TypeAlreadyExistsException.php diff --git a/Grid/Exception/TypeNotFoundException.php b/src/Grid/Exception/TypeNotFoundException.php similarity index 100% rename from Grid/Exception/TypeNotFoundException.php rename to src/Grid/Exception/TypeNotFoundException.php diff --git a/Grid/Exception/UnexpectedTypeException.php b/src/Grid/Exception/UnexpectedTypeException.php similarity index 100% rename from Grid/Exception/UnexpectedTypeException.php rename to src/Grid/Exception/UnexpectedTypeException.php diff --git a/Grid/Export/CSVExport.php b/src/Grid/Export/CSVExport.php similarity index 100% rename from Grid/Export/CSVExport.php rename to src/Grid/Export/CSVExport.php diff --git a/Grid/Export/DSVExport.php b/src/Grid/Export/DSVExport.php similarity index 100% rename from Grid/Export/DSVExport.php rename to src/Grid/Export/DSVExport.php diff --git a/Grid/Export/ExcelExport.php b/src/Grid/Export/ExcelExport.php similarity index 100% rename from Grid/Export/ExcelExport.php rename to src/Grid/Export/ExcelExport.php diff --git a/Grid/Export/Export.php b/src/Grid/Export/Export.php similarity index 100% rename from Grid/Export/Export.php rename to src/Grid/Export/Export.php diff --git a/Grid/Export/ExportInterface.php b/src/Grid/Export/ExportInterface.php similarity index 100% rename from Grid/Export/ExportInterface.php rename to src/Grid/Export/ExportInterface.php diff --git a/Grid/Export/JSONExport.php b/src/Grid/Export/JSONExport.php similarity index 100% rename from Grid/Export/JSONExport.php rename to src/Grid/Export/JSONExport.php diff --git a/Grid/Export/PHPExcel2003Export.php b/src/Grid/Export/PHPExcel2003Export.php similarity index 100% rename from Grid/Export/PHPExcel2003Export.php rename to src/Grid/Export/PHPExcel2003Export.php diff --git a/Grid/Export/PHPExcel2007Export.php b/src/Grid/Export/PHPExcel2007Export.php similarity index 100% rename from Grid/Export/PHPExcel2007Export.php rename to src/Grid/Export/PHPExcel2007Export.php diff --git a/Grid/Export/PHPExcel5Export.php b/src/Grid/Export/PHPExcel5Export.php similarity index 100% rename from Grid/Export/PHPExcel5Export.php rename to src/Grid/Export/PHPExcel5Export.php diff --git a/Grid/Export/PHPExcelHTMLExport.php b/src/Grid/Export/PHPExcelHTMLExport.php similarity index 100% rename from Grid/Export/PHPExcelHTMLExport.php rename to src/Grid/Export/PHPExcelHTMLExport.php diff --git a/Grid/Export/PHPExcelPDFExport.php b/src/Grid/Export/PHPExcelPDFExport.php similarity index 100% rename from Grid/Export/PHPExcelPDFExport.php rename to src/Grid/Export/PHPExcelPDFExport.php diff --git a/Grid/Export/SCSVExport.php b/src/Grid/Export/SCSVExport.php similarity index 100% rename from Grid/Export/SCSVExport.php rename to src/Grid/Export/SCSVExport.php diff --git a/Grid/Export/TSVExport.php b/src/Grid/Export/TSVExport.php similarity index 100% rename from Grid/Export/TSVExport.php rename to src/Grid/Export/TSVExport.php diff --git a/Grid/Export/XMLExport.php b/src/Grid/Export/XMLExport.php similarity index 100% rename from Grid/Export/XMLExport.php rename to src/Grid/Export/XMLExport.php diff --git a/Grid/Filter.php b/src/Grid/Filter.php similarity index 100% rename from Grid/Filter.php rename to src/Grid/Filter.php diff --git a/Grid/Grid.php b/src/Grid/Grid.php similarity index 99% rename from Grid/Grid.php rename to src/Grid/Grid.php index 6948e448..5804a1ec 100644 --- a/Grid/Grid.php +++ b/src/Grid/Grid.php @@ -1411,6 +1411,11 @@ public function setTemplate($template) } $this->set(self::REQUEST_QUERY_TEMPLATE, $template); + + if ($this->hash === null) { + $this->createHash(); + } + $this->saveSession(); } diff --git a/Grid/GridBuilder.php b/src/Grid/GridBuilder.php similarity index 100% rename from Grid/GridBuilder.php rename to src/Grid/GridBuilder.php diff --git a/Grid/GridBuilderInterface.php b/src/Grid/GridBuilderInterface.php similarity index 100% rename from Grid/GridBuilderInterface.php rename to src/Grid/GridBuilderInterface.php diff --git a/Grid/GridConfigBuilder.php b/src/Grid/GridConfigBuilder.php similarity index 100% rename from Grid/GridConfigBuilder.php rename to src/Grid/GridConfigBuilder.php diff --git a/Grid/GridConfigBuilderInterface.php b/src/Grid/GridConfigBuilderInterface.php similarity index 100% rename from Grid/GridConfigBuilderInterface.php rename to src/Grid/GridConfigBuilderInterface.php diff --git a/Grid/GridConfigInterface.php b/src/Grid/GridConfigInterface.php similarity index 100% rename from Grid/GridConfigInterface.php rename to src/Grid/GridConfigInterface.php diff --git a/Grid/GridFactory.php b/src/Grid/GridFactory.php similarity index 100% rename from Grid/GridFactory.php rename to src/Grid/GridFactory.php diff --git a/Grid/GridFactoryInterface.php b/src/Grid/GridFactoryInterface.php similarity index 100% rename from Grid/GridFactoryInterface.php rename to src/Grid/GridFactoryInterface.php diff --git a/Grid/GridInterface.php b/src/Grid/GridInterface.php similarity index 100% rename from Grid/GridInterface.php rename to src/Grid/GridInterface.php diff --git a/Grid/GridManager.php b/src/Grid/GridManager.php similarity index 100% rename from Grid/GridManager.php rename to src/Grid/GridManager.php diff --git a/Grid/GridRegistry.php b/src/Grid/GridRegistry.php similarity index 100% rename from Grid/GridRegistry.php rename to src/Grid/GridRegistry.php diff --git a/Grid/GridRegistryInterface.php b/src/Grid/GridRegistryInterface.php similarity index 100% rename from Grid/GridRegistryInterface.php rename to src/Grid/GridRegistryInterface.php diff --git a/Grid/GridTypeInterface.php b/src/Grid/GridTypeInterface.php similarity index 100% rename from Grid/GridTypeInterface.php rename to src/Grid/GridTypeInterface.php diff --git a/Grid/Helper/ColumnsIterator.php b/src/Grid/Helper/ColumnsIterator.php similarity index 100% rename from Grid/Helper/ColumnsIterator.php rename to src/Grid/Helper/ColumnsIterator.php diff --git a/Grid/Helper/ORMCountWalker.php b/src/Grid/Helper/ORMCountWalker.php similarity index 100% rename from Grid/Helper/ORMCountWalker.php rename to src/Grid/Helper/ORMCountWalker.php diff --git a/Grid/Mapping/Column.php b/src/Grid/Mapping/Column.php similarity index 100% rename from Grid/Mapping/Column.php rename to src/Grid/Mapping/Column.php diff --git a/Grid/Mapping/Driver/Annotation.php b/src/Grid/Mapping/Driver/Annotation.php similarity index 100% rename from Grid/Mapping/Driver/Annotation.php rename to src/Grid/Mapping/Driver/Annotation.php diff --git a/Grid/Mapping/Driver/DriverInterface.php b/src/Grid/Mapping/Driver/DriverInterface.php similarity index 100% rename from Grid/Mapping/Driver/DriverInterface.php rename to src/Grid/Mapping/Driver/DriverInterface.php diff --git a/Grid/Mapping/Metadata/DriverHeap.php b/src/Grid/Mapping/Metadata/DriverHeap.php similarity index 100% rename from Grid/Mapping/Metadata/DriverHeap.php rename to src/Grid/Mapping/Metadata/DriverHeap.php diff --git a/Grid/Mapping/Metadata/Manager.php b/src/Grid/Mapping/Metadata/Manager.php similarity index 100% rename from Grid/Mapping/Metadata/Manager.php rename to src/Grid/Mapping/Metadata/Manager.php diff --git a/Grid/Mapping/Metadata/Metadata.php b/src/Grid/Mapping/Metadata/Metadata.php similarity index 100% rename from Grid/Mapping/Metadata/Metadata.php rename to src/Grid/Mapping/Metadata/Metadata.php diff --git a/Grid/Mapping/Source.php b/src/Grid/Mapping/Source.php similarity index 100% rename from Grid/Mapping/Source.php rename to src/Grid/Mapping/Source.php diff --git a/Grid/Row.php b/src/Grid/Row.php similarity index 100% rename from Grid/Row.php rename to src/Grid/Row.php diff --git a/Grid/Rows.php b/src/Grid/Rows.php similarity index 100% rename from Grid/Rows.php rename to src/Grid/Rows.php diff --git a/Grid/Source/Document.php b/src/Grid/Source/Document.php similarity index 100% rename from Grid/Source/Document.php rename to src/Grid/Source/Document.php diff --git a/Grid/Source/Entity.php b/src/Grid/Source/Entity.php similarity index 100% rename from Grid/Source/Entity.php rename to src/Grid/Source/Entity.php diff --git a/Grid/Source/Source.php b/src/Grid/Source/Source.php similarity index 100% rename from Grid/Source/Source.php rename to src/Grid/Source/Source.php diff --git a/Grid/Source/Vector.php b/src/Grid/Source/Vector.php similarity index 100% rename from Grid/Source/Vector.php rename to src/Grid/Source/Vector.php diff --git a/Grid/Type/GridType.php b/src/Grid/Type/GridType.php similarity index 100% rename from Grid/Type/GridType.php rename to src/Grid/Type/GridType.php diff --git a/Resources/config/columns.xml b/src/Resources/config/columns.xml similarity index 100% rename from Resources/config/columns.xml rename to src/Resources/config/columns.xml diff --git a/Resources/config/grid.yml b/src/Resources/config/grid.yml similarity index 100% rename from Resources/config/grid.yml rename to src/Resources/config/grid.yml diff --git a/Resources/config/services.xml b/src/Resources/config/services.xml similarity index 100% rename from Resources/config/services.xml rename to src/Resources/config/services.xml diff --git a/Resources/doc/columns_configuration/annotations/association_mapping.md b/src/Resources/doc/columns_configuration/annotations/association_mapping.md similarity index 100% rename from Resources/doc/columns_configuration/annotations/association_mapping.md rename to src/Resources/doc/columns_configuration/annotations/association_mapping.md diff --git a/Resources/doc/columns_configuration/annotations/column_annotation_class.md b/src/Resources/doc/columns_configuration/annotations/column_annotation_class.md similarity index 100% rename from Resources/doc/columns_configuration/annotations/column_annotation_class.md rename to src/Resources/doc/columns_configuration/annotations/column_annotation_class.md diff --git a/Resources/doc/columns_configuration/annotations/column_annotation_property.md b/src/Resources/doc/columns_configuration/annotations/column_annotation_property.md similarity index 100% rename from Resources/doc/columns_configuration/annotations/column_annotation_property.md rename to src/Resources/doc/columns_configuration/annotations/column_annotation_property.md diff --git a/Resources/doc/columns_configuration/annotations/dql_function.md b/src/Resources/doc/columns_configuration/annotations/dql_function.md similarity index 100% rename from Resources/doc/columns_configuration/annotations/dql_function.md rename to src/Resources/doc/columns_configuration/annotations/dql_function.md diff --git a/Resources/doc/columns_configuration/annotations/source_annotation.md b/src/Resources/doc/columns_configuration/annotations/source_annotation.md similarity index 100% rename from Resources/doc/columns_configuration/annotations/source_annotation.md rename to src/Resources/doc/columns_configuration/annotations/source_annotation.md diff --git a/Resources/doc/columns_configuration/filters/create_filter.md b/src/Resources/doc/columns_configuration/filters/create_filter.md similarity index 100% rename from Resources/doc/columns_configuration/filters/create_filter.md rename to src/Resources/doc/columns_configuration/filters/create_filter.md diff --git a/Resources/doc/columns_configuration/filters/input_filter.md b/src/Resources/doc/columns_configuration/filters/input_filter.md similarity index 100% rename from Resources/doc/columns_configuration/filters/input_filter.md rename to src/Resources/doc/columns_configuration/filters/input_filter.md diff --git a/Resources/doc/columns_configuration/filters/select_filter.md b/src/Resources/doc/columns_configuration/filters/select_filter.md similarity index 100% rename from Resources/doc/columns_configuration/filters/select_filter.md rename to src/Resources/doc/columns_configuration/filters/select_filter.md diff --git a/Resources/doc/columns_configuration/index.md b/src/Resources/doc/columns_configuration/index.md similarity index 100% rename from Resources/doc/columns_configuration/index.md rename to src/Resources/doc/columns_configuration/index.md diff --git a/Resources/doc/columns_configuration/types/array_column.md b/src/Resources/doc/columns_configuration/types/array_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/array_column.md rename to src/Resources/doc/columns_configuration/types/array_column.md diff --git a/Resources/doc/columns_configuration/types/blank_column.md b/src/Resources/doc/columns_configuration/types/blank_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/blank_column.md rename to src/Resources/doc/columns_configuration/types/blank_column.md diff --git a/Resources/doc/columns_configuration/types/boolean_column.md b/src/Resources/doc/columns_configuration/types/boolean_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/boolean_column.md rename to src/Resources/doc/columns_configuration/types/boolean_column.md diff --git a/Resources/doc/columns_configuration/types/create_column.md b/src/Resources/doc/columns_configuration/types/create_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/create_column.md rename to src/Resources/doc/columns_configuration/types/create_column.md diff --git a/Resources/doc/columns_configuration/types/date_column.md b/src/Resources/doc/columns_configuration/types/date_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/date_column.md rename to src/Resources/doc/columns_configuration/types/date_column.md diff --git a/Resources/doc/columns_configuration/types/datetime_column.md b/src/Resources/doc/columns_configuration/types/datetime_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/datetime_column.md rename to src/Resources/doc/columns_configuration/types/datetime_column.md diff --git a/Resources/doc/columns_configuration/types/join_column.md b/src/Resources/doc/columns_configuration/types/join_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/join_column.md rename to src/Resources/doc/columns_configuration/types/join_column.md diff --git a/Resources/doc/columns_configuration/types/number_column.md b/src/Resources/doc/columns_configuration/types/number_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/number_column.md rename to src/Resources/doc/columns_configuration/types/number_column.md diff --git a/Resources/doc/columns_configuration/types/rank_column.md b/src/Resources/doc/columns_configuration/types/rank_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/rank_column.md rename to src/Resources/doc/columns_configuration/types/rank_column.md diff --git a/Resources/doc/columns_configuration/types/text_column.md b/src/Resources/doc/columns_configuration/types/text_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/text_column.md rename to src/Resources/doc/columns_configuration/types/text_column.md diff --git a/Resources/doc/columns_configuration/types/time_column.md b/src/Resources/doc/columns_configuration/types/time_column.md similarity index 100% rename from Resources/doc/columns_configuration/types/time_column.md rename to src/Resources/doc/columns_configuration/types/time_column.md diff --git a/Resources/doc/configuration.md b/src/Resources/doc/configuration.md similarity index 100% rename from Resources/doc/configuration.md rename to src/Resources/doc/configuration.md diff --git a/Resources/doc/export/create_export.md b/src/Resources/doc/export/create_export.md similarity index 100% rename from Resources/doc/export/create_export.md rename to src/Resources/doc/export/create_export.md diff --git a/Resources/doc/export/index.md b/src/Resources/doc/export/index.md similarity index 100% rename from Resources/doc/export/index.md rename to src/Resources/doc/export/index.md diff --git a/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_HTML_export.md b/src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_HTML_export.md similarity index 100% rename from Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_HTML_export.md rename to src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_HTML_export.md diff --git a/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_PDF_export.md b/src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_PDF_export.md similarity index 100% rename from Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_PDF_export.md rename to src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_PDF_export.md diff --git a/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2003_export.md b/src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2003_export.md similarity index 100% rename from Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2003_export.md rename to src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2003_export.md diff --git a/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2007_export.md b/src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2007_export.md similarity index 100% rename from Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2007_export.md rename to src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel2007_export.md diff --git a/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel5_export.md b/src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel5_export.md similarity index 100% rename from Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel5_export.md rename to src/Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_excel5_export.md diff --git a/Resources/doc/export/native_exports/CSV_export.md b/src/Resources/doc/export/native_exports/CSV_export.md similarity index 100% rename from Resources/doc/export/native_exports/CSV_export.md rename to src/Resources/doc/export/native_exports/CSV_export.md diff --git a/Resources/doc/export/native_exports/DSV_export.md b/src/Resources/doc/export/native_exports/DSV_export.md similarity index 100% rename from Resources/doc/export/native_exports/DSV_export.md rename to src/Resources/doc/export/native_exports/DSV_export.md diff --git a/Resources/doc/export/native_exports/Excel_export.md b/src/Resources/doc/export/native_exports/Excel_export.md similarity index 100% rename from Resources/doc/export/native_exports/Excel_export.md rename to src/Resources/doc/export/native_exports/Excel_export.md diff --git a/Resources/doc/export/native_exports/JSON_export.md b/src/Resources/doc/export/native_exports/JSON_export.md similarity index 100% rename from Resources/doc/export/native_exports/JSON_export.md rename to src/Resources/doc/export/native_exports/JSON_export.md diff --git a/Resources/doc/export/native_exports/SCSV_export.md b/src/Resources/doc/export/native_exports/SCSV_export.md similarity index 100% rename from Resources/doc/export/native_exports/SCSV_export.md rename to src/Resources/doc/export/native_exports/SCSV_export.md diff --git a/Resources/doc/export/native_exports/TSV_export.md b/src/Resources/doc/export/native_exports/TSV_export.md similarity index 100% rename from Resources/doc/export/native_exports/TSV_export.md rename to src/Resources/doc/export/native_exports/TSV_export.md diff --git a/Resources/doc/export/native_exports/XML_export.md b/src/Resources/doc/export/native_exports/XML_export.md similarity index 100% rename from Resources/doc/export/native_exports/XML_export.md rename to src/Resources/doc/export/native_exports/XML_export.md diff --git a/Resources/doc/features.md b/src/Resources/doc/features.md similarity index 100% rename from Resources/doc/features.md rename to src/Resources/doc/features.md diff --git a/Resources/doc/getting_started.md b/src/Resources/doc/getting_started.md similarity index 100% rename from Resources/doc/getting_started.md rename to src/Resources/doc/getting_started.md diff --git a/Resources/doc/grid.md b/src/Resources/doc/grid.md similarity index 100% rename from Resources/doc/grid.md rename to src/Resources/doc/grid.md diff --git a/Resources/doc/grid_configuration/add_actions_column.md b/src/Resources/doc/grid_configuration/add_actions_column.md similarity index 100% rename from Resources/doc/grid_configuration/add_actions_column.md rename to src/Resources/doc/grid_configuration/add_actions_column.md diff --git a/Resources/doc/grid_configuration/add_column.md b/src/Resources/doc/grid_configuration/add_column.md similarity index 100% rename from Resources/doc/grid_configuration/add_column.md rename to src/Resources/doc/grid_configuration/add_column.md diff --git a/Resources/doc/grid_configuration/add_delete_mass_action.md b/src/Resources/doc/grid_configuration/add_delete_mass_action.md similarity index 100% rename from Resources/doc/grid_configuration/add_delete_mass_action.md rename to src/Resources/doc/grid_configuration/add_delete_mass_action.md diff --git a/Resources/doc/grid_configuration/add_export.md b/src/Resources/doc/grid_configuration/add_export.md similarity index 100% rename from Resources/doc/grid_configuration/add_export.md rename to src/Resources/doc/grid_configuration/add_export.md diff --git a/Resources/doc/grid_configuration/add_mass_action.md b/src/Resources/doc/grid_configuration/add_mass_action.md similarity index 100% rename from Resources/doc/grid_configuration/add_mass_action.md rename to src/Resources/doc/grid_configuration/add_mass_action.md diff --git a/Resources/doc/grid_configuration/add_row_action.md b/src/Resources/doc/grid_configuration/add_row_action.md similarity index 100% rename from Resources/doc/grid_configuration/add_row_action.md rename to src/Resources/doc/grid_configuration/add_row_action.md diff --git a/Resources/doc/grid_configuration/always_show_grid.md b/src/Resources/doc/grid_configuration/always_show_grid.md similarity index 100% rename from Resources/doc/grid_configuration/always_show_grid.md rename to src/Resources/doc/grid_configuration/always_show_grid.md diff --git a/Resources/doc/grid_configuration/grid_response.md b/src/Resources/doc/grid_configuration/grid_response.md similarity index 100% rename from Resources/doc/grid_configuration/grid_response.md rename to src/Resources/doc/grid_configuration/grid_response.md diff --git a/Resources/doc/grid_configuration/hide_show_columns.md b/src/Resources/doc/grid_configuration/hide_show_columns.md similarity index 100% rename from Resources/doc/grid_configuration/hide_show_columns.md rename to src/Resources/doc/grid_configuration/hide_show_columns.md diff --git a/Resources/doc/grid_configuration/index.md b/src/Resources/doc/grid_configuration/index.md similarity index 100% rename from Resources/doc/grid_configuration/index.md rename to src/Resources/doc/grid_configuration/index.md diff --git a/Resources/doc/grid_configuration/manipulate_column.md b/src/Resources/doc/grid_configuration/manipulate_column.md similarity index 100% rename from Resources/doc/grid_configuration/manipulate_column.md rename to src/Resources/doc/grid_configuration/manipulate_column.md diff --git a/Resources/doc/grid_configuration/manipulate_column_render_cell.md b/src/Resources/doc/grid_configuration/manipulate_column_render_cell.md similarity index 100% rename from Resources/doc/grid_configuration/manipulate_column_render_cell.md rename to src/Resources/doc/grid_configuration/manipulate_column_render_cell.md diff --git a/Resources/doc/grid_configuration/manipulate_count_query.md b/src/Resources/doc/grid_configuration/manipulate_count_query.md similarity index 100% rename from Resources/doc/grid_configuration/manipulate_count_query.md rename to src/Resources/doc/grid_configuration/manipulate_count_query.md diff --git a/Resources/doc/grid_configuration/manipulate_query.md b/src/Resources/doc/grid_configuration/manipulate_query.md similarity index 100% rename from Resources/doc/grid_configuration/manipulate_query.md rename to src/Resources/doc/grid_configuration/manipulate_query.md diff --git a/Resources/doc/grid_configuration/manipulate_row_action_rendering.md b/src/Resources/doc/grid_configuration/manipulate_row_action_rendering.md similarity index 100% rename from Resources/doc/grid_configuration/manipulate_row_action_rendering.md rename to src/Resources/doc/grid_configuration/manipulate_row_action_rendering.md diff --git a/Resources/doc/grid_configuration/manipulate_rows_data.md b/src/Resources/doc/grid_configuration/manipulate_rows_data.md similarity index 100% rename from Resources/doc/grid_configuration/manipulate_rows_data.md rename to src/Resources/doc/grid_configuration/manipulate_rows_data.md diff --git a/Resources/doc/grid_configuration/multi_grid_manager.md b/src/Resources/doc/grid_configuration/multi_grid_manager.md similarity index 100% rename from Resources/doc/grid_configuration/multi_grid_manager.md rename to src/Resources/doc/grid_configuration/multi_grid_manager.md diff --git a/Resources/doc/grid_configuration/set_columns_order.md b/src/Resources/doc/grid_configuration/set_columns_order.md similarity index 100% rename from Resources/doc/grid_configuration/set_columns_order.md rename to src/Resources/doc/grid_configuration/set_columns_order.md diff --git a/Resources/doc/grid_configuration/set_data.md b/src/Resources/doc/grid_configuration/set_data.md similarity index 100% rename from Resources/doc/grid_configuration/set_data.md rename to src/Resources/doc/grid_configuration/set_data.md diff --git a/Resources/doc/grid_configuration/set_default_filters.md b/src/Resources/doc/grid_configuration/set_default_filters.md similarity index 100% rename from Resources/doc/grid_configuration/set_default_filters.md rename to src/Resources/doc/grid_configuration/set_default_filters.md diff --git a/Resources/doc/grid_configuration/set_default_limit.md b/src/Resources/doc/grid_configuration/set_default_limit.md similarity index 100% rename from Resources/doc/grid_configuration/set_default_limit.md rename to src/Resources/doc/grid_configuration/set_default_limit.md diff --git a/Resources/doc/grid_configuration/set_default_order.md b/src/Resources/doc/grid_configuration/set_default_order.md similarity index 100% rename from Resources/doc/grid_configuration/set_default_order.md rename to src/Resources/doc/grid_configuration/set_default_order.md diff --git a/Resources/doc/grid_configuration/set_default_page.md b/src/Resources/doc/grid_configuration/set_default_page.md similarity index 100% rename from Resources/doc/grid_configuration/set_default_page.md rename to src/Resources/doc/grid_configuration/set_default_page.md diff --git a/Resources/doc/grid_configuration/set_grid_identifier.md b/src/Resources/doc/grid_configuration/set_grid_identifier.md similarity index 100% rename from Resources/doc/grid_configuration/set_grid_identifier.md rename to src/Resources/doc/grid_configuration/set_grid_identifier.md diff --git a/Resources/doc/grid_configuration/set_grid_persistence.md b/src/Resources/doc/grid_configuration/set_grid_persistence.md similarity index 100% rename from Resources/doc/grid_configuration/set_grid_persistence.md rename to src/Resources/doc/grid_configuration/set_grid_persistence.md diff --git a/Resources/doc/grid_configuration/set_grid_route.md b/src/Resources/doc/grid_configuration/set_grid_route.md similarity index 100% rename from Resources/doc/grid_configuration/set_grid_route.md rename to src/Resources/doc/grid_configuration/set_grid_route.md diff --git a/Resources/doc/grid_configuration/set_limits.md b/src/Resources/doc/grid_configuration/set_limits.md similarity index 100% rename from Resources/doc/grid_configuration/set_limits.md rename to src/Resources/doc/grid_configuration/set_limits.md diff --git a/Resources/doc/grid_configuration/set_max_results.md b/src/Resources/doc/grid_configuration/set_max_results.md similarity index 100% rename from Resources/doc/grid_configuration/set_max_results.md rename to src/Resources/doc/grid_configuration/set_max_results.md diff --git a/Resources/doc/grid_configuration/set_no_data_message.md b/src/Resources/doc/grid_configuration/set_no_data_message.md similarity index 100% rename from Resources/doc/grid_configuration/set_no_data_message.md rename to src/Resources/doc/grid_configuration/set_no_data_message.md diff --git a/Resources/doc/grid_configuration/set_no_result_message.md b/src/Resources/doc/grid_configuration/set_no_result_message.md similarity index 100% rename from Resources/doc/grid_configuration/set_no_result_message.md rename to src/Resources/doc/grid_configuration/set_no_result_message.md diff --git a/Resources/doc/grid_configuration/set_permanent_filters.md b/src/Resources/doc/grid_configuration/set_permanent_filters.md similarity index 100% rename from Resources/doc/grid_configuration/set_permanent_filters.md rename to src/Resources/doc/grid_configuration/set_permanent_filters.md diff --git a/Resources/doc/grid_configuration/set_prefix_titles.md b/src/Resources/doc/grid_configuration/set_prefix_titles.md similarity index 100% rename from Resources/doc/grid_configuration/set_prefix_titles.md rename to src/Resources/doc/grid_configuration/set_prefix_titles.md diff --git a/Resources/doc/grid_configuration/set_size_actions_column.md b/src/Resources/doc/grid_configuration/set_size_actions_column.md similarity index 100% rename from Resources/doc/grid_configuration/set_size_actions_column.md rename to src/Resources/doc/grid_configuration/set_size_actions_column.md diff --git a/Resources/doc/grid_configuration/set_title_actions_column.md b/src/Resources/doc/grid_configuration/set_title_actions_column.md similarity index 100% rename from Resources/doc/grid_configuration/set_title_actions_column.md rename to src/Resources/doc/grid_configuration/set_title_actions_column.md diff --git a/Resources/doc/grid_configuration/working_example.css b/src/Resources/doc/grid_configuration/working_example.css similarity index 100% rename from Resources/doc/grid_configuration/working_example.css rename to src/Resources/doc/grid_configuration/working_example.css diff --git a/Resources/doc/grid_configuration/working_example.md b/src/Resources/doc/grid_configuration/working_example.md similarity index 100% rename from Resources/doc/grid_configuration/working_example.md rename to src/Resources/doc/grid_configuration/working_example.md diff --git a/Resources/doc/images/false.png b/src/Resources/doc/images/false.png similarity index 100% rename from Resources/doc/images/false.png rename to src/Resources/doc/images/false.png diff --git a/Resources/doc/images/pagerfanta.png b/src/Resources/doc/images/pagerfanta.png similarity index 100% rename from Resources/doc/images/pagerfanta.png rename to src/Resources/doc/images/pagerfanta.png diff --git a/Resources/doc/images/screenshot_database.png b/src/Resources/doc/images/screenshot_database.png similarity index 100% rename from Resources/doc/images/screenshot_database.png rename to src/Resources/doc/images/screenshot_database.png diff --git a/Resources/doc/images/screenshot_en.png b/src/Resources/doc/images/screenshot_en.png similarity index 100% rename from Resources/doc/images/screenshot_en.png rename to src/Resources/doc/images/screenshot_en.png diff --git a/Resources/doc/images/screenshot_fr.png b/src/Resources/doc/images/screenshot_fr.png similarity index 100% rename from Resources/doc/images/screenshot_fr.png rename to src/Resources/doc/images/screenshot_fr.png diff --git a/Resources/doc/images/screenshot_full.png b/src/Resources/doc/images/screenshot_full.png similarity index 100% rename from Resources/doc/images/screenshot_full.png rename to src/Resources/doc/images/screenshot_full.png diff --git a/Resources/doc/images/sort_down.gif b/src/Resources/doc/images/sort_down.gif similarity index 100% rename from Resources/doc/images/sort_down.gif rename to src/Resources/doc/images/sort_down.gif diff --git a/Resources/doc/images/sort_up.gif b/src/Resources/doc/images/sort_up.gif similarity index 100% rename from Resources/doc/images/sort_up.gif rename to src/Resources/doc/images/sort_up.gif diff --git a/Resources/doc/images/true.png b/src/Resources/doc/images/true.png similarity index 100% rename from Resources/doc/images/true.png rename to src/Resources/doc/images/true.png diff --git a/Resources/doc/index.md b/src/Resources/doc/index.md similarity index 100% rename from Resources/doc/index.md rename to src/Resources/doc/index.md diff --git a/Resources/doc/source/document_source.md b/src/Resources/doc/source/document_source.md similarity index 100% rename from Resources/doc/source/document_source.md rename to src/Resources/doc/source/document_source.md diff --git a/Resources/doc/source/entity_source.md b/src/Resources/doc/source/entity_source.md similarity index 100% rename from Resources/doc/source/entity_source.md rename to src/Resources/doc/source/entity_source.md diff --git a/Resources/doc/source/index.md b/src/Resources/doc/source/index.md similarity index 100% rename from Resources/doc/source/index.md rename to src/Resources/doc/source/index.md diff --git a/Resources/doc/source/vector_source.md b/src/Resources/doc/source/vector_source.md similarity index 100% rename from Resources/doc/source/vector_source.md rename to src/Resources/doc/source/vector_source.md diff --git a/Resources/doc/summary.md b/src/Resources/doc/summary.md similarity index 100% rename from Resources/doc/summary.md rename to src/Resources/doc/summary.md diff --git a/Resources/doc/template/cell_rendering.md b/src/Resources/doc/template/cell_rendering.md similarity index 100% rename from Resources/doc/template/cell_rendering.md rename to src/Resources/doc/template/cell_rendering.md diff --git a/Resources/doc/template/filter_rendering.md b/src/Resources/doc/template/filter_rendering.md similarity index 100% rename from Resources/doc/template/filter_rendering.md rename to src/Resources/doc/template/filter_rendering.md diff --git a/Resources/doc/template/index.md b/src/Resources/doc/template/index.md similarity index 100% rename from Resources/doc/template/index.md rename to src/Resources/doc/template/index.md diff --git a/Resources/doc/template/overriding_internal_blocks.md b/src/Resources/doc/template/overriding_internal_blocks.md similarity index 100% rename from Resources/doc/template/overriding_internal_blocks.md rename to src/Resources/doc/template/overriding_internal_blocks.md diff --git a/Resources/doc/template/pagerfanta_example.css b/src/Resources/doc/template/pagerfanta_example.css similarity index 100% rename from Resources/doc/template/pagerfanta_example.css rename to src/Resources/doc/template/pagerfanta_example.css diff --git a/Resources/doc/template/render_an_ajax_grid.md b/src/Resources/doc/template/render_an_ajax_grid.md similarity index 100% rename from Resources/doc/template/render_an_ajax_grid.md rename to src/Resources/doc/template/render_an_ajax_grid.md diff --git a/Resources/doc/template/render_external_filters.md b/src/Resources/doc/template/render_external_filters.md similarity index 100% rename from Resources/doc/template/render_external_filters.md rename to src/Resources/doc/template/render_external_filters.md diff --git a/Resources/doc/template/render_pagerfanta_pager.md b/src/Resources/doc/template/render_pagerfanta_pager.md similarity index 100% rename from Resources/doc/template/render_pagerfanta_pager.md rename to src/Resources/doc/template/render_pagerfanta_pager.md diff --git a/Resources/translations/messages.cs.xliff b/src/Resources/translations/messages.cs.xliff similarity index 100% rename from Resources/translations/messages.cs.xliff rename to src/Resources/translations/messages.cs.xliff diff --git a/Resources/translations/messages.de.xliff b/src/Resources/translations/messages.de.xliff similarity index 100% rename from Resources/translations/messages.de.xliff rename to src/Resources/translations/messages.de.xliff diff --git a/Resources/translations/messages.en.xliff b/src/Resources/translations/messages.en.xliff similarity index 100% rename from Resources/translations/messages.en.xliff rename to src/Resources/translations/messages.en.xliff diff --git a/Resources/translations/messages.es.xliff b/src/Resources/translations/messages.es.xliff similarity index 100% rename from Resources/translations/messages.es.xliff rename to src/Resources/translations/messages.es.xliff diff --git a/Resources/translations/messages.fr.xliff b/src/Resources/translations/messages.fr.xliff similarity index 100% rename from Resources/translations/messages.fr.xliff rename to src/Resources/translations/messages.fr.xliff diff --git a/Resources/translations/messages.it.xliff b/src/Resources/translations/messages.it.xliff similarity index 100% rename from Resources/translations/messages.it.xliff rename to src/Resources/translations/messages.it.xliff diff --git a/Resources/translations/messages.ja.xliff b/src/Resources/translations/messages.ja.xliff similarity index 100% rename from Resources/translations/messages.ja.xliff rename to src/Resources/translations/messages.ja.xliff diff --git a/Resources/translations/messages.nl.xliff b/src/Resources/translations/messages.nl.xliff similarity index 100% rename from Resources/translations/messages.nl.xliff rename to src/Resources/translations/messages.nl.xliff diff --git a/Resources/translations/messages.pl.xliff b/src/Resources/translations/messages.pl.xliff similarity index 100% rename from Resources/translations/messages.pl.xliff rename to src/Resources/translations/messages.pl.xliff diff --git a/Resources/translations/messages.pt_BR.xliff b/src/Resources/translations/messages.pt_BR.xliff similarity index 100% rename from Resources/translations/messages.pt_BR.xliff rename to src/Resources/translations/messages.pt_BR.xliff diff --git a/Resources/translations/messages.ru.xliff b/src/Resources/translations/messages.ru.xliff similarity index 100% rename from Resources/translations/messages.ru.xliff rename to src/Resources/translations/messages.ru.xliff diff --git a/Resources/translations/messages.sk.xliff b/src/Resources/translations/messages.sk.xliff similarity index 100% rename from Resources/translations/messages.sk.xliff rename to src/Resources/translations/messages.sk.xliff diff --git a/Resources/translations/messages.tr.xliff b/src/Resources/translations/messages.tr.xliff similarity index 100% rename from Resources/translations/messages.tr.xliff rename to src/Resources/translations/messages.tr.xliff diff --git a/Resources/views/blocks.html.twig b/src/Resources/views/blocks.html.twig similarity index 100% rename from Resources/views/blocks.html.twig rename to src/Resources/views/blocks.html.twig diff --git a/Resources/views/blocks_js.jquery.html.twig b/src/Resources/views/blocks_js.jquery.html.twig similarity index 100% rename from Resources/views/blocks_js.jquery.html.twig rename to src/Resources/views/blocks_js.jquery.html.twig diff --git a/Translation/ColumnTitleAnnotationTranslationExtractor.php b/src/Translation/ColumnTitleAnnotationTranslationExtractor.php similarity index 100% rename from Translation/ColumnTitleAnnotationTranslationExtractor.php rename to src/Translation/ColumnTitleAnnotationTranslationExtractor.php diff --git a/Twig/DataGridExtension.php b/src/Twig/DataGridExtension.php similarity index 100% rename from Twig/DataGridExtension.php rename to src/Twig/DataGridExtension.php From 925e9af5b018965c31bf6c1a30ba34f014246aeb Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Tue, 18 Jan 2022 15:14:37 -0500 Subject: [PATCH 15/41] Add hook to allow mocking final classes --- composer.json | 1 + phpunit.xml.dist | 4 ++++ tests/Hook/BypassFinalHook.php | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 tests/Hook/BypassFinalHook.php diff --git a/composer.json b/composer.json index 4f340485..bd490faa 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "require-dev": { "ext-intl": "*", "ext-mongodb": "*", + "dg/bypass-finals": "^1.2", "symfony/framework-bundle": "^4.4|^5.2", "symfony/expression-language": "^4.4|^5.2", "symfony/phpunit-bridge": "^4.4|^5.2", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f8b9a6ab..acb7032d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,6 +19,10 @@ + + + + diff --git a/tests/Hook/BypassFinalHook.php b/tests/Hook/BypassFinalHook.php new file mode 100644 index 00000000..4de2e535 --- /dev/null +++ b/tests/Hook/BypassFinalHook.php @@ -0,0 +1,14 @@ + Date: Tue, 18 Jan 2022 16:42:09 -0500 Subject: [PATCH 16/41] Resolve some deprecations --- src/Grid/Column/Column.php | 7 +- src/Grid/Column/SimpleArrayColumn.php | 14 +- tests/Grid/Column/DateTimeColumnTest.php | 153 +++++--------- tests/Grid/Column/JoinColumnTest.php | 45 ++--- tests/Grid/Column/MassActionColumnTest.php | 25 ++- tests/Grid/Column/NumberColumnTest.php | 208 ++++++++------------ tests/Grid/Column/RankColumnTest.php | 50 ++--- tests/Grid/Column/SimpleArrayColumnTest.php | 61 +++--- tests/Grid/Column/TextColumnTest.php | 33 +++- tests/Grid/Column/UntypedColumnTest.php | 10 - tests/Grid/Source/VectorTest.php | 16 +- 11 files changed, 269 insertions(+), 353 deletions(-) diff --git a/src/Grid/Column/Column.php b/src/Grid/Column/Column.php index 157e41fe..2d384b71 100644 --- a/src/Grid/Column/Column.php +++ b/src/Grid/Column/Column.php @@ -193,6 +193,11 @@ public function __initialize(array $params) $this->setTranslationDomain($this->getParam('translation_domain')); } + public function getParams() + { + return $this->params; + } + public function getParam($id, $default = null) { return isset($this->params[$id]) ? $this->params[$id] : $default; @@ -201,7 +206,7 @@ public function getParam($id, $default = null) /** * Draw cell. * - * @param string $value + * @param mixed $value * @param Row $row * @param $router * diff --git a/src/Grid/Column/SimpleArrayColumn.php b/src/Grid/Column/SimpleArrayColumn.php index 762a3930..2e4f00c8 100644 --- a/src/Grid/Column/SimpleArrayColumn.php +++ b/src/Grid/Column/SimpleArrayColumn.php @@ -65,21 +65,21 @@ public function getFilters($source) return $filters; } - public function renderCell($values, $row, $router) + public function renderCell($value, $row, $router) { if (is_callable($this->callback)) { - return call_user_func($this->callback, $values, $row, $router); + return call_user_func($this->callback, $value, $row, $router); } // @todo: when it has an array as value? $return = []; - if (is_array($values) || $values instanceof \Traversable) { - foreach ($values as $key => $value) { - if (!is_array($value) && isset($this->values[(string) $value])) { - $value = $this->values[$value]; + if (is_array($value) || $value instanceof \Traversable) { + foreach ($value as $key => $itemValue) { + if (!is_array($itemValue) && isset($this->values[(string) $itemValue])) { + $itemValue = $this->values[$itemValue]; } - $return[$key] = $value; + $return[$key] = $itemValue; } } diff --git a/tests/Grid/Column/DateTimeColumnTest.php b/tests/Grid/Column/DateTimeColumnTest.php index b2082f8e..40f13666 100644 --- a/tests/Grid/Column/DateTimeColumnTest.php +++ b/tests/Grid/Column/DateTimeColumnTest.php @@ -7,7 +7,7 @@ use APY\DataGridBundle\Grid\Filter; use APY\DataGridBundle\Grid\Row; use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Routing\Router; +use Symfony\Component\Routing\RouterInterface; class DateTimeColumnTest extends TestCase { @@ -24,16 +24,6 @@ public function testSetFormat() $column = new DateTimeColumn(); $column->setFormat($format); - $this->assertAttributeEquals($format, 'format', $column); - } - - public function testGetFormat() - { - $format = 'Y-m-d'; - - $column = new DateTimeColumn(); - $column->setFormat($format); - $this->assertEquals($format, $column->getFormat()); } @@ -44,16 +34,6 @@ public function testSetInputFormat() $column = new DateTimeColumn(); $column->setInputFormat($inputFormat); - $this->assertAttributeEquals($inputFormat, 'inputFormat', $column); - } - - public function testGetInputFormat() - { - $inputFormat = 'Y-m-d'; - - $column = new DateTimeColumn(); - $column->setInputFormat($inputFormat); - $this->assertEquals($inputFormat, $column->getInputFormat()); } @@ -64,16 +44,6 @@ public function testSetTimezone() $column = new DateTimeColumn(); $column->setTimezone($timezone); - $this->assertAttributeEquals($timezone, 'timezone', $column); - } - - public function testGetTimezone() - { - $timezone = 'UTC'; - - $column = new DateTimeColumn(); - $column->setTimezone($timezone); - $this->assertEquals($timezone, $column->getTimezone()); } @@ -90,7 +60,7 @@ public function testRenderCellWithoutCallback() $column->renderCell( $now, $this->createMock(Row::class), - $this->createMock(Router::class) + $this->createMock(RouterInterface::class) ) ); } @@ -99,9 +69,7 @@ public function testRenderCellWithCallback() { $column = new DateTimeColumn(); $column->setFormat('Y-m-d H:i:s'); - $column->manipulateRenderCell(function ($value, $row, $router) { - return '01:00:00'; - }); + $column->manipulateRenderCell(fn($value, $row, $router) => '01:00:00'); $dateTime = '2000-01-01 01:00:00'; $now = new \DateTime($dateTime); @@ -111,7 +79,7 @@ public function testRenderCellWithCallback() $column->renderCell( $now, $this->createMock(Row::class), - $this->createMock(Router::class) + $this->createMock(RouterInterface::class) ) ); } @@ -121,10 +89,13 @@ public function testFilterWithValue() $column = new DateTimeColumn(); $column->setData(['operator' => Column::OPERATOR_BTW, 'from' => '2017-03-22 01:30:00', 'to' => '2017-03-23 19:00:00']); - $this->assertEquals([ - new Filter(Column::OPERATOR_GT, new \DateTime('2017-03-22 01:30:00')), - new Filter(Column::OPERATOR_LT, new \DateTime('2017-03-23 19:00:00')), - ], $column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GT, new \DateTime('2017-03-22 01:30:00')), + new Filter(Column::OPERATOR_LT, new \DateTime('2017-03-23 19:00:00')), + ], + $column->getFilters('asource') + ); } public function testFilterWithFormattedValue() @@ -133,10 +104,13 @@ public function testFilterWithFormattedValue() $column->setInputFormat('m/d/Y H-i-s'); $column->setData(['operator' => Column::OPERATOR_BTW, 'from' => '03/22/2017 01-30-00', 'to' => '03/23/2017 19-00-00']); - $this->assertEquals([ - new Filter(Column::OPERATOR_GT, new \DateTime('2017-03-22 01:30:00')), - new Filter(Column::OPERATOR_LT, new \DateTime('2017-03-23 19:00:00')), - ], $column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GT, new \DateTime('2017-03-22 01:30:00')), + new Filter(Column::OPERATOR_LT, new \DateTime('2017-03-23 19:00:00')), + ], + $column->getFilters('asource') + ); } public function testFilterWithoutValue() @@ -181,22 +155,25 @@ public function testInitializeDefaultParams() { $column = new DateTimeColumn(); - $this->assertAttributeEquals(null, 'format', $column); - $this->assertAttributeEquals('Y-m-d H:i:s', 'inputFormat', $column); - $this->assertAttributeEquals([ - Column::OPERATOR_EQ, - Column::OPERATOR_NEQ, - Column::OPERATOR_LT, - Column::OPERATOR_LTE, - Column::OPERATOR_GT, - Column::OPERATOR_GTE, - Column::OPERATOR_BTW, - Column::OPERATOR_BTWE, - Column::OPERATOR_ISNULL, - Column::OPERATOR_ISNOTNULL, - ], 'operators', $column); - $this->assertAttributeEquals(Column::OPERATOR_EQ, 'defaultOperator', $column); - $this->assertAttributeEquals(date_default_timezone_get(), 'timezone', $column); + $this->assertEquals(null, $column->getFormat()); + $this->assertEquals('Y-m-d H:i:s', $column->getInputFormat()); + $this->assertEquals( + [ + Column::OPERATOR_EQ, + Column::OPERATOR_NEQ, + Column::OPERATOR_LT, + Column::OPERATOR_LTE, + Column::OPERATOR_GT, + Column::OPERATOR_GTE, + Column::OPERATOR_BTW, + Column::OPERATOR_BTWE, + Column::OPERATOR_ISNULL, + Column::OPERATOR_ISNOTNULL, + ], + $column->getOperators() + ); + $this->assertEquals(Column::OPERATOR_EQ, $column->getDefaultOperator()); + $this->assertEquals(date_default_timezone_get(), $column->getTimezone()); } public function testInitialize() @@ -215,25 +192,29 @@ public function testInitialize() $column = new DateTimeColumn($params); - $this->assertAttributeEquals($format, 'format', $column); - $this->assertAttributeEquals($inputFormat, 'inputFormat', $column); - $this->assertAttributeEquals([ - Column::OPERATOR_LT, Column::OPERATOR_LTE, - ], 'operators', $column); - $this->assertAttributeEquals(Column::OPERATOR_LT, 'defaultOperator', $column); - $this->assertAttributeEquals($timezone, 'timezone', $column); + $this->assertEquals($format, $column->getFormat()); + $this->assertEquals($inputFormat, $column->getInputFormat()); + $this->assertEquals( + [ + Column::OPERATOR_LT, + Column::OPERATOR_LTE, + ], + $column->getOperators() + ); + $this->assertEquals(Column::OPERATOR_LT, $column->getDefaultOperator()); + $this->assertEquals($timezone, $column->getTimezone()); } /** * @dataProvider provideDisplayInput */ - public function testCorrectDisplayOut($value, $expectedOutput, $timeZone = null) + public function testCorrectDisplayOut($value, $expectedOutput, $timezone = null) { $column = new DateTimeColumn(); $column->setFormat('Y-m-d H:i:s'); - if ($timeZone !== null) { - $column->setTimezone($timeZone); + if ($timezone !== null) { + $column->setTimezone($timezone); } $this->assertEquals($expectedOutput, $column->getDisplayedValue($value)); @@ -241,10 +222,6 @@ public function testCorrectDisplayOut($value, $expectedOutput, $timeZone = null) public function testDisplayValueForDateTimeImmutable() { - if (PHP_VERSION_ID < 50500) { - $this->markTestSkipped('\\DateTimeImmutable was introduced in PHP 5.5'); - } - $now = new \DateTimeImmutable(); $column = new DateTimeColumn(); @@ -263,34 +240,6 @@ public function testDateTimeZoneForDisplayValueIsTheSameAsTheColumn() $this->assertEquals('2000-01-01 00:00:00', $column->getDisplayedValue($now)); } -// public function testDisplayValueWithDefaultFormats() -// { -// $column = new DateTimeColumn(); -// $now = new \DateTime('2017-03-22 22:52:00'); -// -// $this->assertEquals('Mar 22, 2017, 10:52:00 PM', $column->getDisplayedValue($now)); -// } -// -// public function testDisplayValueWithoutFormatButTimeZone() -// { -// $column = new DateTimeColumn(); -// $column->setTimezone('UTC'); -// -// $now = new \DateTime('2017-03-22 22:52:00', new \DateTimeZone('Europe/Amsterdam')); -// -// $this->assertEquals('Mar 22, 2017, 9:52:00 PM', $column->getDisplayedValue($now)); -// } -// -// public function testDisplayValueWithFallbackFormat() -// { -// $column = new DateTimeColumn(); -// $column->setTimezone(\IntlDateFormatter::NONE); -// -// $now = new \DateTime('2017/03/22 22:52:00'); -// -// $this->assertEquals('2017-03-22 20:52:00', $column->getDisplayedValue($now)); -// } - public function provideDisplayInput() { $now = new \DateTime(); diff --git a/tests/Grid/Column/JoinColumnTest.php b/tests/Grid/Column/JoinColumnTest.php index a465fe22..4c09eac6 100644 --- a/tests/Grid/Column/JoinColumnTest.php +++ b/tests/Grid/Column/JoinColumnTest.php @@ -9,7 +9,9 @@ class JoinColumnTest extends TestCase { - /** @var JoinColumn */ + /** + * @var JoinColumn + */ private $column; public function setUp(): void @@ -27,11 +29,11 @@ public function testInitializeDefaultParams() $params = []; $column = new JoinColumn($params); - $this->assertAttributeEquals([], 'params', $column); - $this->assertAttributeEquals([], 'joinColumns', $column); - $this->assertAttributeEquals(' ', 'separator', $column); - $this->assertAttributeEquals(true, 'visibleForSource', $column); - $this->assertAttributeEquals(true, 'isManualField', $column); + $this->assertEquals([], $column->getParams()); + $this->assertEquals([], $column->getJoinColumns()); + $this->assertEquals(' ', $column->getSeparator()); + $this->assertTrue($column->isVisibleForSource()); + $this->assertTrue($column->getIsManualField()); } public function testInitialize() @@ -46,9 +48,9 @@ public function testInitialize() ]; $column = new JoinColumn($params); - $this->assertAttributeEquals($params, 'params', $column); - $this->assertAttributeEquals([$col1, $col2], 'joinColumns', $column); - $this->assertAttributeEquals($separator, 'separator', $column); + $this->assertEquals($params, $column->getParams()); + $this->assertEquals([$col1, $col2], $column->getJoinColumns()); + $this->assertEquals($separator, $column->getSeparator()); } public function testSetJoinColumns() @@ -58,16 +60,6 @@ public function testSetJoinColumns() $this->column->setJoinColumns([$col1, $col2]); - $this->assertAttributeEquals([$col1, $col2], 'joinColumns', $this->column); - } - - public function testGetjoinColumns() - { - $col1 = 'col1'; - $col2 = 'col2'; - - $this->column->setJoinColumns([$col1, $col2]); - $this->assertEquals([$col1, $col2], $this->column->getJoinColumns()); } @@ -85,11 +77,14 @@ public function testSetColumnNameOnFilters() $column = new JoinColumn($params); $column->setData(['operator' => Column::OPERATOR_ISNOTNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNOTNULL, null, $col1), - new Filter(Column::OPERATOR_NEQ, null, $col1), - new Filter(Column::OPERATOR_ISNOTNULL, null, $col2), - new Filter(Column::OPERATOR_NEQ, null, $col2), - ], $column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNOTNULL, null, $col1), + new Filter(Column::OPERATOR_NEQ, null, $col1), + new Filter(Column::OPERATOR_ISNOTNULL, null, $col2), + new Filter(Column::OPERATOR_NEQ, null, $col2), + ], + $column->getFilters('asource') + ); } } diff --git a/tests/Grid/Column/MassActionColumnTest.php b/tests/Grid/Column/MassActionColumnTest.php index 2891e55c..51241f06 100644 --- a/tests/Grid/Column/MassActionColumnTest.php +++ b/tests/Grid/Column/MassActionColumnTest.php @@ -8,7 +8,9 @@ class MassActionColumnTest extends TestCase { - /** @var MassActionColumn */ + /** + * @var MassActionColumn + */ private $column; public function setUp(): void @@ -34,14 +36,17 @@ public function testIsVisible() public function testInitialize() { - $this->assertAttributeEquals([ - 'id' => MassActionColumn::ID, - 'title' => '', - 'size' => 15, - 'filterable' => true, - 'sortable' => false, - 'source' => false, - 'align' => Column::ALIGN_CENTER, - ], 'params', $this->column); + $this->assertEquals( + [ + 'id' => MassActionColumn::ID, + 'title' => '', + 'size' => 15, + 'filterable' => true, + 'sortable' => false, + 'source' => false, + 'align' => Column::ALIGN_CENTER, + ], + $this->column->getParams() + ); } } diff --git a/tests/Grid/Column/NumberColumnTest.php b/tests/Grid/Column/NumberColumnTest.php index 8816f706..a162d969 100644 --- a/tests/Grid/Column/NumberColumnTest.php +++ b/tests/Grid/Column/NumberColumnTest.php @@ -7,7 +7,7 @@ use APY\DataGridBundle\Grid\Filter; use APY\DataGridBundle\Grid\Row; use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Routing\Router; +use Symfony\Component\Routing\RouterInterface; class NumberColumnTest extends TestCase { @@ -28,109 +28,112 @@ public function testGetType() public function testInitializeDefaultParams() { - $this->assertAttributeEquals(Column::ALIGN_RIGHT, 'align', $this->column); - $this->assertAttributeEquals(\NumberFormatter::DECIMAL, 'style', $this->column); - $this->assertAttributeEquals(\Locale::getDefault(), 'locale', $this->column); - $this->assertAttributeEquals(null, 'precision', $this->column); - $this->assertAttributeEquals(false, 'grouping', $this->column); - $this->assertAttributeEquals(\NumberFormatter::ROUND_HALFUP, 'roundingMode', $this->column); - $this->assertAttributeEquals(null, 'ruleSet', $this->column); - $this->assertAttributeEquals(null, 'currencyCode', $this->column); - $this->assertAttributeEquals(false, 'fractional', $this->column); - $this->assertAttributeEquals(null, 'maxFractionDigits', $this->column); - $this->assertAttributeEquals([ - Column::OPERATOR_EQ, - Column::OPERATOR_NEQ, - Column::OPERATOR_LT, - Column::OPERATOR_LTE, - Column::OPERATOR_GT, - Column::OPERATOR_GTE, - Column::OPERATOR_BTW, - Column::OPERATOR_BTWE, - Column::OPERATOR_ISNULL, - Column::OPERATOR_ISNOTNULL, - ], 'operators', $this->column); - $this->assertAttributeEquals(Column::OPERATOR_EQ, 'defaultOperator', $this->column); + $this->assertEquals(Column::ALIGN_RIGHT, $this->column->getAlign()); + $this->assertEquals(\NumberFormatter::DECIMAL, $this->column->getStyle()); + $this->assertEquals(\Locale::getDefault(), $this->column->getLocale()); + $this->assertEquals(null, $this->column->getPrecision()); + $this->assertEquals(false, $this->column->getGrouping()); + $this->assertEquals(\NumberFormatter::ROUND_HALFUP, $this->column->getRoundingMode()); + $this->assertEquals(null, $this->column->getRuleSet()); + $this->assertEquals(null, $this->column->getCurrencyCode()); + $this->assertEquals(false, $this->column->getFractional()); + $this->assertEquals(null, $this->column->getMaxFractionDigits()); + $this->assertEquals( + [ + Column::OPERATOR_EQ, + Column::OPERATOR_NEQ, + Column::OPERATOR_LT, + Column::OPERATOR_LTE, + Column::OPERATOR_GT, + Column::OPERATOR_GTE, + Column::OPERATOR_BTW, + Column::OPERATOR_BTWE, + Column::OPERATOR_ISNULL, + Column::OPERATOR_ISNOTNULL, + ], + $this->column->getOperators() + ); + $this->assertEquals(Column::OPERATOR_EQ, $this->column->getDefaultOperator()); + } + + public function testInitializeStyleWithInvalidValue() + { + $this->expectException(\InvalidArgumentException::class); + $column = new NumberColumn(['style' => 'foostyle']); } - public function testInitializeStyle() + public function testGetStyle() { $column = new NumberColumn(['style' => 'decimal']); - $this->assertAttributeEquals(\NumberFormatter::DECIMAL, 'style', $column); + $this->assertEquals(\NumberFormatter::DECIMAL, $column->getStyle()); $column = new NumberColumn(['style' => 'percent']); - $this->assertAttributeEquals(\NumberFormatter::PERCENT, 'style', $column); + $this->assertEquals(\NumberFormatter::PERCENT, $column->getStyle()); $column = new NumberColumn(['style' => 'money']); - $this->assertAttributeEquals(\NumberFormatter::CURRENCY, 'style', $column); + $this->assertEquals(\NumberFormatter::CURRENCY, $column->getStyle()); $column = new NumberColumn(['style' => 'currency']); - $this->assertAttributeEquals(\NumberFormatter::CURRENCY, 'style', $column); + $this->assertEquals(\NumberFormatter::CURRENCY, $column->getStyle()); $column = new NumberColumn(['style' => 'duration']); - $this->assertAttributeEquals(\NumberFormatter::DURATION, 'style', $column); - $this->assertAttributeEquals('en', 'locale', $column); - $this->assertAttributeEquals('%in-numerals', 'ruleSet', $column); + $this->assertEquals(\NumberFormatter::DURATION, $column->getStyle()); + $this->assertEquals('en', $column->getLocale()); + $this->assertEquals('%in-numerals', $column->getRuleSet()); $column = new NumberColumn(['style' => 'scientific']); - $this->assertAttributeEquals(\NumberFormatter::SCIENTIFIC, 'style', $column); + $this->assertEquals(\NumberFormatter::SCIENTIFIC, $column->getStyle()); $column = new NumberColumn(['style' => 'spellout']); - $this->assertAttributeEquals(\NumberFormatter::SPELLOUT, 'style', $column); + $this->assertEquals(\NumberFormatter::SPELLOUT, $column->getStyle()); } - public function testInitializeStyleWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - $column = new NumberColumn(['style' => 'foostyle']); - } - - public function testInitializeLocale() + public function testGetLocale() { $column = new NumberColumn(['locale' => 'it']); - $this->assertAttributeEquals('it', 'locale', $column); + $this->assertEquals('it', $column->getLocale()); } - public function testInitializePrecision() + public function testGetPrecision() { $column = new NumberColumn(['precision' => 2]); - $this->assertAttributeEquals(2, 'precision', $column); + $this->assertEquals(2, $column->getPrecision()); } - public function testInitializeGrouping() + public function testGetGrouping() { $column = new NumberColumn(['grouping' => 3]); - $this->assertAttributeEquals(3, 'grouping', $column); + $this->assertEquals(3, $column->getGrouping()); } - public function testInitializeRoundingMode() + public function testGetRoundingMode() { $column = new NumberColumn(['roundingMode' => \NumberFormatter::ROUND_HALFDOWN]); - $this->assertAttributeEquals(\NumberFormatter::ROUND_HALFDOWN, 'roundingMode', $column); + $this->assertEquals(\NumberFormatter::ROUND_HALFDOWN, $column->getRoundingMode()); } - public function testInitializeRuleSet() + public function testGetRuleSet() { $column = new NumberColumn(['ruleSet' => \NumberFormatter::PUBLIC_RULESETS]); - $this->assertAttributeEquals(\NumberFormatter::PUBLIC_RULESETS, 'ruleSet', $column); + $this->assertEquals(\NumberFormatter::PUBLIC_RULESETS, $column->getRuleSet()); } - public function testInitializeCurrencyCode() + public function testGetCurrencyCode() { $column = new NumberColumn(['currencyCode' => 'EUR']); - $this->assertAttributeEquals('EUR', 'currencyCode', $column); + $this->assertEquals('EUR', $column->getCurrencyCode()); } - public function testInizializeFractional() + public function testGetFractional() { $column = new NumberColumn(['fractional' => true]); - $this->assertAttributeEquals(true, 'fractional', $column); + $this->assertEquals(true, $column->getFractional()); } - public function testInizializeMaxFractionalDigits() + public function testGetMaxFractionDigits() { $column = new NumberColumn(['maxFractionDigits' => 2]); - $this->assertAttributeEquals(2, 'maxFractionDigits', $column); + $this->assertEquals(2, $column->getMaxFractionDigits()); } public function testIsQueryValid() @@ -147,17 +150,15 @@ public function testIsQueryValid() public function testRenderCellWithCallback() { $value = 1.0; - $this->column->manipulateRenderCell(function ($value, $row, $router) { - return (int) $value; - }); + $this->column->manipulateRenderCell(fn($value, $row, $router) => (int)$value); $result = $this->column->renderCell( $value, $this->createMock(Row::class), - $this->createMock(Router::class) + $this->createMock(RouterInterface::class) ); - $this->assertEquals($result, $value); + $this->assertEquals($value, $result); } public function testDisplayedValueWithEmptyValue() @@ -241,74 +242,29 @@ public function testDisplayedValueFromArrayValues() public function testGetFilters() { $this->column->setData(['operator' => Column::OPERATOR_BTW, 'from' => '10', 'to' => '20']); - $this->assertEquals([ - new Filter(Column::OPERATOR_GT, 10), - new Filter(Column::OPERATOR_LT, 20), - ], $this->column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GT, 10), + new Filter(Column::OPERATOR_LT, 20), + ], + $this->column->getFilters('asource') + ); $this->column->setData(['operator' => Column::OPERATOR_BTW, 'from' => 10, 'to' => 20]); - $this->assertEquals([ - new Filter(Column::OPERATOR_GT, 10), - new Filter(Column::OPERATOR_LT, 20), - ], $this->column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GT, 10), + new Filter(Column::OPERATOR_LT, 20), + ], + $this->column->getFilters('asource') + ); $this->column->setData(['operator' => Column::OPERATOR_ISNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNULL), - ], $this->column->getFilters('asource')); - } - - public function getStyle() - { - $column = new NumberColumn(['style' => 'decimal']); - $this->assertEquals(\NumberFormatter::DECIMAL, $column->getStyle()); - } - - public function getLocale() - { - $column = new NumberColumn(['locale' => 'it_IT']); - $this->assertEquals('it_IT', $column->getLocale()); - } - - public function getPrecision() - { - $column = new NumberColumn(['precision' => 2]); - $this->assertEquals(2, $column->getPrecision()); - } - - public function getGrouping() - { - $column = new NumberColumn(['grouping' => 3]); - $this->assertEquals(3, $column->getGrouping()); - } - - public function getRoundingMode() - { - $column = new NumberColumn(['roundingMode' => \NumberFormatter::ROUND_HALFDOWN]); - $this->assertEquals(\NumberFormatter::ROUND_HALFDOWN, $column->getRoundingMode()); - } - - public function getRuleSet() - { - $column = new NumberColumn(['ruleSet' => \NumberFormatter::PUBLIC_RULESETS]); - $this->assertEquals(\NumberFormatter::PUBLIC_RULESETS, $column->getRuleSet()); - } - - public function getCurrencyCode() - { - $column = new NumberColumn(['currencyCode' => 'USD']); - $this->assertEquals('USD', $column->getCurrencyCode()); - } - - public function getFractional() - { - $column = new NumberColumn(['fractional' => true]); - $this->assertTrue($column->getFractional()); - } - - public function getMaxFractionDigits() - { - $column = new NumberColumn(['maxFractionDigits' => 3]); - $this->assertEquals(3, $column->getMaxFractionDigits()); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNULL), + ], + $this->column->getFilters('asource') + ); } } diff --git a/tests/Grid/Column/RankColumnTest.php b/tests/Grid/Column/RankColumnTest.php index c4b2e71a..dca35d01 100644 --- a/tests/Grid/Column/RankColumnTest.php +++ b/tests/Grid/Column/RankColumnTest.php @@ -6,11 +6,13 @@ use APY\DataGridBundle\Grid\Column\RankColumn; use APY\DataGridBundle\Grid\Row; use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Routing\Router; +use Symfony\Component\Routing\RouterInterface; class RankColumnTest extends TestCase { - /** @var RankColumn */ + /** + * @var RankColumn + */ private $column; public function setUp(): void @@ -35,54 +37,56 @@ public function testInitialize() $column = new RankColumn($params); - $this->assertAttributeEquals([ - 'foo' => 'foo', - 'bar' => 'bar', - 'title' => 'title', - 'filterable' => false, - 'sortable' => false, - 'source' => false, - ], 'params', $column); + $this->assertEquals( + [ + 'foo' => 'foo', + 'bar' => 'bar', + 'title' => 'title', + 'filterable' => false, + 'sortable' => false, + 'source' => false, + ], + $column->getParams() + ); } public function testSetId() { - $this->assertAttributeEquals('rank', 'id', $this->column); + $this->assertEquals('rank', $this->column->getId()); $column = new RankColumn(['id' => 'foo']); - $this->assertAttributeEquals('foo', 'id', $column); + $this->assertEquals('foo', $column->getId()); } public function testSetTitle() { - $this->assertAttributeEquals('rank', 'title', $this->column); + $this->assertEquals('rank', $this->column->getTitle()); $column = new RankColumn(['title' => 'foo']); - $this->assertAttributeEquals('foo', 'title', $column); + $this->assertEquals('foo', $column->getTitle()); } public function testSetSize() { - $this->assertAttributeEquals('30', 'size', $this->column); + $this->assertEquals('30', $this->column->getSize()); $column = new RankColumn(['size' => '20']); - $this->assertAttributeEquals('20', 'size', $column); + $this->assertEquals('20', $column->getSize()); } public function testSetAlign() { - $this->assertAttributeEquals(Column::ALIGN_CENTER, 'align', $this->column); + $this->assertEquals(Column::ALIGN_CENTER, $this->column->getAlign()); $column = new RankColumn(['align' => Column::ALIGN_RIGHT]); - $this->assertAttributeEquals(Column::ALIGN_RIGHT, 'align', $column); + $this->assertEquals(Column::ALIGN_RIGHT, $column->getAlign()); } public function testRenderCell() { - $this->assertEquals(1, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(Router::class))); - $this->assertAttributeEquals(2, 'rank', $this->column); - - $this->assertEquals(2, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(Router::class))); - $this->assertAttributeEquals(3, 'rank', $this->column); + $this->assertEquals(1, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(RouterInterface::class))); + $this->assertEquals(2, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(RouterInterface::class))); + $this->assertEquals(3, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(RouterInterface::class))); + $this->assertEquals(4, $this->column->renderCell(true, $this->createMock(Row::class), $this->createMock(RouterInterface::class))); } } diff --git a/tests/Grid/Column/SimpleArrayColumnTest.php b/tests/Grid/Column/SimpleArrayColumnTest.php index 69303625..1ef2ab7a 100644 --- a/tests/Grid/Column/SimpleArrayColumnTest.php +++ b/tests/Grid/Column/SimpleArrayColumnTest.php @@ -11,7 +11,9 @@ class SimpleArrayColumnTest extends TestCase { - /** @var SimpleArrayColumn */ + /** + * @var SimpleArrayColumn + */ private $column; public function setUp(): void @@ -26,16 +28,19 @@ public function testGetType() public function testInitializeDefaultParams() { - $this->assertAttributeEquals([ - Column::OPERATOR_LIKE, - Column::OPERATOR_NLIKE, - Column::OPERATOR_EQ, - Column::OPERATOR_NEQ, - Column::OPERATOR_ISNULL, - Column::OPERATOR_ISNOTNULL, - ], 'operators', $this->column); - - $this->assertAttributeEquals(Column::OPERATOR_LIKE, 'defaultOperator', $this->column); + $this->assertEquals( + [ + Column::OPERATOR_LIKE, + Column::OPERATOR_NLIKE, + Column::OPERATOR_EQ, + Column::OPERATOR_NEQ, + Column::OPERATOR_ISNULL, + Column::OPERATOR_ISNOTNULL, + ], + $this->column->getOperators() + ); + + $this->assertEquals(Column::OPERATOR_LIKE, $this->column->getDefaultOperator()); } public function testEqualFilter() @@ -78,21 +83,28 @@ public function testIsNullFilter() { $this->column->setData(['operator' => Column::OPERATOR_ISNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNULL), - new Filter(Column::OPERATOR_EQ, ''), - ], $this->column->getFilters('asource')); - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $this->column); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNULL), + new Filter(Column::OPERATOR_EQ, ''), + ], + $this->column->getFilters('asource') + ); + + $this->assertEquals(Column::DATA_DISJUNCTION, $this->column->getDataJunction()); } public function testIsNotNullFilter() { $this->column->setData(['operator' => Column::OPERATOR_ISNOTNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNOTNULL), - new Filter(Column::OPERATOR_NEQ, ''), - ], $this->column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNOTNULL), + new Filter(Column::OPERATOR_NEQ, ''), + ], + $this->column->getFilters('asource') + ); } public function testRenderCellWithoutCallback() @@ -105,15 +117,14 @@ public function testRenderCellWithoutCallback() $this->createMock(Router::class) ); - $this->assertEquals($result, $values); + $this->assertEquals($values, $result); } public function testRenderCellWithCallback() { $values = ['foo, bar']; - $this->column->manipulateRenderCell(function ($value, $row, $router) { - return ['foobar']; - }); + + $this->column->manipulateRenderCell(fn ($value, $row, $router) => ['foobar']); $result = $this->column->renderCell( $values, @@ -121,6 +132,6 @@ public function testRenderCellWithCallback() $this->createMock(Router::class) ); - $this->assertEquals($result, ['foobar']); + $this->assertEquals(['foobar'], $result); } } diff --git a/tests/Grid/Column/TextColumnTest.php b/tests/Grid/Column/TextColumnTest.php index defcec23..3cc8647a 100644 --- a/tests/Grid/Column/TextColumnTest.php +++ b/tests/Grid/Column/TextColumnTest.php @@ -9,7 +9,9 @@ class TextColumnTest extends WebTestCase { - /** @var TextColumn */ + /** + * @var TextColumn + */ private $column; public function setUp(): void @@ -32,30 +34,41 @@ public function testIsQueryValid() public function testNullOperatorFilters() { $this->column->setData(['operator' => Column::OPERATOR_ISNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNULL), - new Filter(Column::OPERATOR_EQ, ''), - ], $this->column->getFilters('asource')); - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $this->column); + + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNULL), + new Filter(Column::OPERATOR_EQ, ''), + ], + $this->column->getFilters('asource') + ); + + $this->assertEquals(Column::DATA_DISJUNCTION, $this->column->getDataJunction()); } public function testNotNullOperatorFilters() { $this->column->setData(['operator' => Column::OPERATOR_ISNOTNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNOTNULL), - new Filter(Column::OPERATOR_NEQ, ''), - ], $this->column->getFilters('asource')); + + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNOTNULL), + new Filter(Column::OPERATOR_NEQ, ''), + ], + $this->column->getFilters('asource') + ); } public function testOtherOperatorFilters() { $operators = array_flip(Column::getAvailableOperators()); + unset($operators[Column::OPERATOR_ISNOTNULL]); unset($operators[Column::OPERATOR_ISNULL]); foreach (array_keys($operators) as $operator) { $this->column->setData(['operator' => $operator]); + $this->assertEmpty($this->column->getFilters('asource')); } } diff --git a/tests/Grid/Column/UntypedColumnTest.php b/tests/Grid/Column/UntypedColumnTest.php index 92140c20..e53560c8 100644 --- a/tests/Grid/Column/UntypedColumnTest.php +++ b/tests/Grid/Column/UntypedColumnTest.php @@ -15,16 +15,6 @@ public function testGetParams() $this->assertEquals($params, $column->getParams()); } - public function testSetType() - { - $type = 'text'; - - $column = new UntypedColumn(); - $column->setType($type); - - $this->assertAttributeEquals($type, 'type', $column); - } - public function getType() { $type = 'text'; diff --git a/tests/Grid/Source/VectorTest.php b/tests/Grid/Source/VectorTest.php index 1f0f03cc..fac66997 100644 --- a/tests/Grid/Source/VectorTest.php +++ b/tests/Grid/Source/VectorTest.php @@ -24,7 +24,7 @@ public function setUp(): void public function testCreateVectorWithEmptyData() { - $this->assertAttributeEmpty('data', $this->vector); + $this->assertEmpty($this->vector->getData()); } public function testRaiseExceptionDuringVectorCreationWhenDataIsNotAVector() @@ -195,15 +195,7 @@ public function testGetHash() $this->assertEquals('APY\DataGridBundle\Grid\Source\Vector' . md5($idCol1.$idCol2), $vector->getHash()); } - public function testSetId() - { - $id = 'id'; - $this->vector->setId($id); - - $this->assertAttributeEquals($id, 'id', $this->vector); - } - - public function testGetId() + public function testId() { $id = 'id'; $this->vector->setId($id); @@ -249,7 +241,3 @@ public function guessedColumnProvider() ]; } } - -class VectorObj -{ -} From c63f8a98730b5335dc4f3ff2579c32cb7fe4019a Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Mon, 30 Jan 2023 11:31:56 -0500 Subject: [PATCH 17/41] Remove MongoDB support --- composer.json | 3 - src/Grid/Column/DateTimeColumn.php | 10 - src/Grid/Source/Document.php | 552 ---------- src/Grid/Source/Source.php | 10 - tests/Grid/Source/DocumentTest.php | 1532 ---------------------------- 5 files changed, 2107 deletions(-) delete mode 100644 src/Grid/Source/Document.php delete mode 100644 tests/Grid/Source/DocumentTest.php diff --git a/composer.json b/composer.json index bd490faa..145983d1 100644 --- a/composer.json +++ b/composer.json @@ -19,21 +19,18 @@ }, "require-dev": { "ext-intl": "*", - "ext-mongodb": "*", "dg/bypass-finals": "^1.2", "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", "doctrine/orm": "~2.4,>=2.4.5", - "doctrine/mongodb-odm": "^2.3" }, "suggest": { "ext-intl": "Translate the grid", "ext-mbstring": "Convert your data with the right charset", "PHPExcel": "Export the grid (Excel, HTML or PDF)", "doctrine/orm": "If you want to use Entity as source, please require doctrine/orm", - "doctrine/mongodb-odm": "If you want to use Document as source, please require doctrine/mongodb-odm" }, "autoload": { "psr-4": { diff --git a/src/Grid/Column/DateTimeColumn.php b/src/Grid/Column/DateTimeColumn.php index b4291bee..68df14fb 100644 --- a/src/Grid/Column/DateTimeColumn.php +++ b/src/Grid/Column/DateTimeColumn.php @@ -136,16 +136,6 @@ protected function getDatetime($data, \DateTimeZone $timezone) $data = strtotime($data); } - // MongoDB Date and Timestamp - if ($data instanceof \MongoDate || $data instanceof \MongoTimestamp) { - $data = $data->sec; - } - - // Mongodb bug ? timestamp value is on the key 'i' instead of the key 't' - if (is_array($data) && array_keys($data) == ['t', 'i']) { - $data = $data['i']; - } - $date = new \DateTime(); $date->setTimestamp($data); $date->setTimezone($timezone); diff --git a/src/Grid/Source/Document.php b/src/Grid/Source/Document.php deleted file mode 100644 index d72efa9a..00000000 --- a/src/Grid/Source/Document.php +++ /dev/null @@ -1,552 +0,0 @@ - - * (c) Stanislav Turza - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * - */ - -namespace APY\DataGridBundle\Grid\Source; - -use APY\DataGridBundle\Grid\Column\Column; -use APY\DataGridBundle\Grid\Helper\ColumnsIterator; -use APY\DataGridBundle\Grid\Row; -use APY\DataGridBundle\Grid\Rows; -use Doctrine\ODM\MongoDB\Query\Builder as QueryBuilder; -use MongoDB\BSON\Regex; - -class Document extends Source -{ - /** - * @var \Doctrine\ODM\MongoDB\Query\Builder; - */ - protected $query; - - /** - * @var \Doctrine\ODM\MongoDB\DocumentManager - */ - protected $manager; - - /** - * e.g. Base\Cms\Document\Page. - */ - protected $class; - - /** - * @var \Doctrine\ODM\MongoDB\Mapping\ClassMetadata - */ - protected $odmMetadata; - - /** - * e.g. Cms:Page. - */ - protected $documentName; - - /** - * @var \APY\DataGridBundle\Grid\Mapping\Metadata\Metadata - */ - protected $metadata; - - /** - * @var int Items count - */ - protected $count; - - /** - * @var string - */ - protected $group; - - /** - * @var array - */ - protected $referencedColumns = []; - - /** - * @var array - */ - protected $referencedMappings = []; - - /** - * @param string $documentName e.g. "Cms:Page" - */ - public function __construct($documentName, $group = 'default') - { - $this->documentName = $documentName; - $this->group = $group; - } - - public function initialise($container) - { - $this->manager = $container->get('doctrine.odm.mongodb.document_manager'); - $this->odmMetadata = $this->manager->getClassMetadata($this->documentName); - $this->class = $this->odmMetadata->getReflectionClass()->getName(); - - $mapping = $container->get('grid.mapping.manager'); - $mapping->addDriver($this, -1); - $this->metadata = $mapping->getMetadata($this->class, $this->group); - } - - /** - * @param \APY\DataGridBundle\Grid\Columns $columns - */ - public function getColumns($columns) - { - foreach ($this->metadata->getColumnsFromMapping($columns) as $column) { - $columns->addColumn($column); - } - } - - protected function normalizeOperator($operator) - { - switch ($operator) { - // For case insensitive - case Column::OPERATOR_EQ: - case Column::OPERATOR_LIKE: - case Column::OPERATOR_NLIKE: - case Column::OPERATOR_RLIKE: - case Column::OPERATOR_LLIKE: - case Column::OPERATOR_SLIKE: - case Column::OPERATOR_NSLIKE: - case Column::OPERATOR_RSLIKE: - case Column::OPERATOR_LSLIKE: - case Column::OPERATOR_NEQ: - return 'equals'; - case Column::OPERATOR_ISNULL: - case Column::OPERATOR_ISNOTNULL: - return 'exists'; - default: - return $operator; - } - } - - protected function normalizeValue($operator, $value) - { - switch ($operator) { - case Column::OPERATOR_NEQ: - return new Regex('^(?!' . $value . '$).*$', 'i'); - case Column::OPERATOR_LIKE: - return new Regex($value, 'i'); - case Column::OPERATOR_NLIKE: - return new Regex('^((?!' . $value . ').)*$', 'i'); - case Column::OPERATOR_RLIKE: - return new Regex('^' . $value, 'i'); - case Column::OPERATOR_LLIKE: - return new Regex($value . '$', 'i'); - case Column::OPERATOR_SLIKE: - return new Regex($value, ''); - case Column::OPERATOR_RSLIKE: - return new Regex('^' . $value, ''); - case Column::OPERATOR_LSLIKE: - return new Regex($value . '$', ''); - case Column::OPERATOR_ISNULL: - return false; - case Column::OPERATOR_ISNOTNULL: - return true; - default: - return $value; - } - } - - /** - * Sets the initial QueryBuilder for this DataGrid. - * - * @param QueryBuilder $queryBuilder - */ - public function initQueryBuilder(QueryBuilder $queryBuilder) - { - $this->query = clone $queryBuilder; - } - - /** - * @return QueryBuilder - */ - protected function getQueryBuilder() - { - //If a custom QB has been provided, use that - //Otherwise create our own basic one - if ($this->query instanceof QueryBuilder) { - $qb = $this->query; - } else { - $qb = $this->query = $this->manager->createQueryBuilder($this->documentName); - } - - return $qb; - } - - /** - * @param ColumnsIterator $columns - * @param int $page Page Number - * @param int $limit Rows Per Page - * @param int $gridDataJunction Grid data junction - * - * @return \APY\DataGridBundle\Grid\Rows - */ - public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gridDataJunction = Column::DATA_CONJUNCTION) - { - $this->query = $this->getQueryBuilder(); - - $validColumns = []; - foreach ($columns as $column) { - - //checks if exists '.' notation on referenced columns and build query if it's filtered - $subColumn = explode('.', $column->getId()); - if (count($subColumn) > 1 && isset($this->referencedMappings[$subColumn[0]])) { - $this->addReferencedColumnn($subColumn, $column); - - continue; - } - - $this->query->select($column->getField()); - - if ($column->isSorted()) { - $this->query->sort($column->getField(), $column->getOrder()); - } - - if ($column->isPrimary()) { - $column->setFilterable(false); - } elseif ($column->isFiltered()) { - // Some attributes of the column can be changed in this function - $filters = $column->getFilters('document'); - - foreach ($filters as $filter) { - //normalize values - $operator = $this->normalizeOperator($filter->getOperator()); - $value = $this->normalizeValue($filter->getOperator(), $filter->getValue()); - - if ($column->getDataJunction() === Column::DATA_DISJUNCTION) { - $this->query->addOr($this->query->expr()->field($column->getField())->$operator($value)); - } else { - $this->query->field($column->getField())->$operator($value); - } - } - } - - $validColumns[] = $column; - } - - if ($page > 0) { - $this->query->skip($page * $limit); - } - - if ($limit > 0) { - if ($maxResults !== null && ($maxResults - $page * $limit < $limit)) { - $limit = $maxResults - $page * $limit; - } - - $this->query->limit($limit); - } elseif ($maxResults !== null) { - $this->query->limit($maxResults); - } - - //call overridden prepareQuery or associated closure - $this->prepareQuery($this->query); - - //execute and get results - $result = new Rows(); - - // I really don't know if Cursor is the right type returned (I mean, every single type). - // As I didn't find out this information, I'm gonna test it with Cursor returned only. - $cursor = $this->query->getQuery()->execute(); - - $this->count = $cursor->count(); - - foreach ($cursor as $resource) { - $row = new Row(); - $properties = $this->getClassProperties($resource); - - foreach ($validColumns as $column) { - if (isset($properties[strtolower($column->getId())])) { - $row->setField($column->getId(), $properties[strtolower($column->getId())]); - } - } - - $this->addReferencedFields($row, $resource); - - //call overridden prepareRow or associated closure - if (($modifiedRow = $this->prepareRow($row)) !== null) { - $result->addRow($modifiedRow); - } - } - - return $result; - } - - /** - * @param array $subColumn - * @param Column \APY\DataGridBundle\Grid\Column\Column - */ - protected function addReferencedColumnn(array $subColumn, Column $column) - { - $this->referencedColumns[$subColumn[0]][] = $subColumn[1]; - - if ($column->isFiltered()) { - $helperQuery = $this->manager->createQueryBuilder($this->referencedMappings[$subColumn[0]]); - $filters = $column->getFilters('document'); - foreach ($filters as $filter) { - $operator = $this->normalizeOperator($filter->getOperator()); - $value = $this->normalizeValue($filter->getOperator(), $filter->getValue()); - - $helperQuery->field($subColumn[1])->$operator($value); - $this->prepareQuery($this->query); - - $cursor = $helperQuery->getQuery()->execute(); - - foreach ($cursor as $resource) { - // Is this case possible? I don't think so - if ($cursor->count() > 0) { - $this->query->select($subColumn[0]); - } - - if ($cursor->count() == 1) { - $this->query->field($subColumn[0])->references($resource); - } else { - $this->query->addOr($this->query->expr()->field($subColumn[0])->references($resource)); - } - } - } - } - } - - /** - * @param \APY\DataGridBundle\Grid\Row $row - * @param Document $resource - * - * @throws \Exception if getter for field does not exists - * - * @return \APY\DataGridBundle\Grid\Row $row with referenced fields - */ - protected function addReferencedFields(Row $row, $resource) - { - foreach ($this->referencedColumns as $parent => $subColumns) { - $node = $this->getClassProperties($resource); - if (isset($node[strtolower($parent)])) { - $node = $node[strtolower($parent)]; - - foreach ($subColumns as $field) { - $getter = 'get' . ucfirst($field); - if (method_exists($node, $getter)) { - $row->setField($parent . '.' . $field, $node->$getter()); - } else { - throw new \Exception(sprintf('Method %s for Document %s not exists', $getter, $this->referencedMappings[$parent])); - } - } - } - } - - return $row; - } - - public function getTotalCount($maxResults = null) - { - if ($maxResults !== null) { - return min([$maxResults, $this->count]); - } - - return $this->count; - } - - protected function getClassProperties($obj) - { - $reflect = new \ReflectionClass($obj); - $props = $reflect->getProperties(); - $result = []; - - foreach ($props as $property) { - $property->setAccessible(true); - $result[strtolower($property->getName())] = $property->getValue($obj); - } - - return $result; - } - - /** - * @param string $class - * @param string $group - * - * @return array - */ - public function getFieldsMetadata($class, $group = 'default') - { - $result = []; - foreach ($this->odmMetadata->getReflectionProperties() as $property) { - $name = $property->getName(); - $mapping = $this->odmMetadata->getFieldMapping($name); - $values = ['title' => $name, 'source' => true]; - - if (isset($mapping['fieldName'])) { - $values['field'] = $mapping['fieldName']; - $values['id'] = $mapping['fieldName']; - } - - if (isset($mapping['id']) && $mapping['id'] == 'id') { - $values['primary'] = true; - } - - switch ($mapping['type']) { - case 'id': - case 'string': - case 'bin_custom': - case 'bin_func': - case 'bin_md5': - case 'bin': - case 'bin_uuid': - case 'file': - case 'key': - case 'increment': - $values['type'] = 'text'; - break; - case 'int': - case 'float': - $values['type'] = 'number'; - break; - /*case 'hash': - $values['type'] = 'array';*/ - case 'boolean': - $values['type'] = 'boolean'; - break; - case 'date': - case 'timestamp': - $values['type'] = 'date'; - break; - case 'collection': - $values['type'] = 'array'; - break; - case 'one': - $values['type'] = 'array'; - if (isset($mapping['reference']) && $mapping['reference'] === true) { - $this->referencedMappings[$name] = $mapping['targetDocument']; - } - break; - case 'many': - $values['type'] = 'array'; - break; - default: - $values['type'] = 'text'; - } - - $result[$name] = $values; - } - - return $result; - } - - public function populateSelectFilters($columns, $loop = false) - { - $queryFromSource = $this->getQueryBuilder(); - $queryFromQuery = clone $this->query; - - // Clean the select fields from the query - foreach ($columns as $column) { - $queryFromQuery->exclude($column->getField()); - } - - /* @var $column Column */ - foreach ($columns as $column) { - $selectFrom = $column->getSelectFrom(); - - if ($column->getFilterType() === 'select' && ($selectFrom === 'source' || $selectFrom === 'query')) { - - // For negative operators, show all values - if ($selectFrom === 'query') { - foreach ($column->getFilters('document') as $filter) { - if (in_array($filter->getOperator(), [Column::OPERATOR_NEQ, Column::OPERATOR_NLIKE, Column::OPERATOR_NSLIKE])) { - $selectFrom = 'source'; - break; - } - } - } - - // Dynamic from query or not ? - $query = ($selectFrom === 'source') ? clone $queryFromSource : clone $queryFromQuery; - - $result = $query->select($column->getField()) - ->distinct($column->getField()) - ->sort($column->getField(), 'asc') - ->skip(null) - ->limit(null) - ->getQuery() - ->execute(); - - $values = []; - foreach ($result as $value) { - switch ($column->getType()) { - case 'number': - $values[$value] = $column->getDisplayedValue($value); - break; - case 'datetime': - case 'date': - case 'time': - if ($value instanceof \MongoDate || $value instanceof \MongoTimestamp) { - $value = $value->sec; - } - - // Mongodb bug ? timestamp value is on the key 'i' instead of the key 't' - if (is_array($value) && array_keys($value) == ['t', 'i']) { - $value = $value['i']; - } - - $displayedValue = $column->getDisplayedValue($value); - $values[$displayedValue] = $displayedValue; - break; - default: - $values[$value] = $value; - } - } - - // It avoids to have no result when the other columns are filtered - if ($selectFrom === 'query' && empty($values) && $loop === false) { - $column->setSelectFrom('source'); - $this->populateSelectFilters($columns, true); - } else { - $values = $this->prepareColumnValues($column, $values); - $column->setValues($values); - } - } - } - } - - /** - * @param array $ids - * - * @throws \Exception - */ - public function delete(array $ids) - { - $repository = $this->getRepository(); - - foreach ($ids as $id) { - $object = $repository->find($id); - - if (!$object) { - throw new \Exception(sprintf('No %s found for id %s', $this->documentName, $id)); - } - - $this->manager->remove($object); - } - - $this->manager->flush(); - } - - /** - * @return \Doctrine\ODM\MongoDB\DocumentRepository - */ - public function getRepository() - { - return $this->manager->getRepository($this->documentName); - } - - /** - * @return string - */ - public function getHash() - { - return $this->documentName; - } -} diff --git a/src/Grid/Source/Source.php b/src/Grid/Source/Source.php index f2605216..248df9b1 100644 --- a/src/Grid/Source/Source.php +++ b/src/Grid/Source/Source.php @@ -501,16 +501,6 @@ public function populateSelectFiltersFromData($columns, $loop = false) case 'datetime': case 'date': case 'time': - // For document - if ($value instanceof \MongoDate || $value instanceof \MongoTimestamp) { - $value = $value->sec; - } - - // Mongodb bug ? timestamp value is on the key 'i' instead of the key 't' - if (is_array($value) && array_keys($value) == ['t', 'i']) { - $value = $value['i']; - } - $displayedValue = $column->getDisplayedValue($value); $values[$displayedValue] = $displayedValue; break; diff --git a/tests/Grid/Source/DocumentTest.php b/tests/Grid/Source/DocumentTest.php deleted file mode 100644 index 31bb6fc0..00000000 --- a/tests/Grid/Source/DocumentTest.php +++ /dev/null @@ -1,1532 +0,0 @@ -document = new Document($name); - - $reflectionClassName = 'aName'; - $reflectionClass = $this->createMock(\ReflectionClass::class); - $reflectionClass - ->method('getName') - ->willReturn($reflectionClassName); - - $odmMetadata = $this->createMock(ClassMetadata::class); - $odmMetadata - ->method('getReflectionClass') - ->willReturn($reflectionClass); - - $this->odmMetadata = $odmMetadata; - - $documentManager = $this->createMock(DocumentManager::class); - $documentManager - ->method('getClassMetadata') - ->with($name) - ->willReturn($odmMetadata); - - $this->manager = $documentManager; - - $metadata = $this->createMock(Metadata::class); - $this->metadata = $metadata; - - $mapping = $this->createMock(Manager::class); - $mapping - ->method('getMetadata') - ->with($reflectionClassName, 'default') - ->willReturn($metadata); - - $containerGetMap = [ - ['doctrine.odm.mongodb.document_manager', Container::EXCEPTION_ON_INVALID_REFERENCE, $documentManager], - ['grid.mapping.manager', Container::EXCEPTION_ON_INVALID_REFERENCE, $mapping] - ]; - - $container = $this->createMock(Container::class); - $container - ->method('get') - ->will($this->returnValueMap($containerGetMap)); - - $mapping - ->expects($this->once()) - ->method('addDriver') - ->with($this->document, -1); - - $this->document->initialise($container); - } - - public function testConstructedWithDefaultGroup() - { - $name = 'name'; - $document = new Document($name); - - $this->assertAttributeEquals($name, 'documentName', $document); - $this->assertAttributeEquals('default', 'group', $document); - } - - public function testConstructedWithAGroup() - { - $name = 'name'; - $group = 'aGroup'; - $document = new Document($name, $group); - - $this->assertAttributeEquals($name, 'documentName', $document); - $this->assertAttributeEquals($group, 'group', $document); - } - - public function testInitQueryBuilder() - { - $qb = $this->createMock(Builder::class); - - $this->document->initQueryBuilder($qb); - - $this->assertAttributeEquals($qb, 'query', $this->document); - $this->assertAttributeNotSame($qb, 'query', $this->document); - } - - /** - * @dataProvider fieldsMetadataProvider - */ - public function testGetFieldsMetadataProv($name, array $fieldMapping, array $metadata, array $referenceMappings = []) - { - $property = $this->createMock(\ReflectionProperty::class); - $property - ->method('getName') - ->willReturn($name); - - $this - ->odmMetadata - ->method('getReflectionProperties') - ->willReturn([$property]); - $this - ->odmMetadata - ->method('getFieldMapping') - ->with($name) - ->willReturn($fieldMapping); - - $this->assertEquals($metadata, $this->document->getFieldsMetadata('name', 'default')); - - $this->assertAttributeEquals($referenceMappings, 'referencedMappings', $this->document); - } - - public function testGetFieldsMetadata() - { - $name1 = 'propName1'; - - $property1 = $this->createMock(\ReflectionProperty::class); - $property1 - ->method('getName') - ->willReturn($name1); - - $name2 = 'propName2'; - - $property2 = $this->createMock(\ReflectionProperty::class); - $property2 - ->method('getName') - ->willReturn($name2); - - $getFieldMappingMap = [ - [$name1, ['type' => 'text']], - [$name2, ['type' => 'text']] - ]; - - $this - ->odmMetadata - ->method('getReflectionProperties') - ->willReturn([$property1, $property2]); - $this - ->odmMetadata - ->method('getFieldMapping') - ->will($this->returnValueMap($getFieldMappingMap)); - - $this->assertEquals( - [$name1 => [ - 'title' => $name1, - 'type' => 'text', - 'source' => true, - ], - $name2 => [ - 'title' => $name2, - 'type' => 'text', - 'source' => true, - ]], - $this->document->getFieldsMetadata('name', 'default') - ); - } - - public function testGetRepository() - { - $repo = $this->createMock(DocumentRepository::class); - - $this - ->manager - ->method('getRepository') - ->with('name') - ->willReturn($repo); - - $this->assertEquals($repo, $this->document->getRepository()); - } - - public function testRaiseExceptionIfDeleteNonExistentObjectFromId() - { - $this->assertEquals('name', $this->document->getHash()); - } - - public function testDeleteRaiseExceptionIfIdNotMatchAnyObject() - { - $this->expectException(\Exception::class); - - $repo = $this->createMock(DocumentRepository::class); - - $this - ->manager - ->method('getRepository') - ->willReturn($repo); - - $this->document->delete(['id']); - } - - public function testDelete() - { - $id1 = 'id1'; - $id2 = 'id2'; - $ids = [$id1, $id2]; - - $doc1 = $this->createMock(DocumentEntity::class); - $doc2 = $this->createMock(DocumentEntity::class); - - $repo = $this->createMock(DocumentRepository::class); - $repo - ->method('find') - ->withConsecutive([$id1], [$id2]) - ->willReturnOnConsecutiveCalls($doc1, $doc2); - - $this - ->manager - ->method('getRepository') - ->willReturn($repo); - - $this - ->manager - ->expects($this->exactly(2)) - ->method('remove') - ->withConsecutive([$doc1], [$doc2]); - $this - ->manager - ->expects($this->atLeastOnce()) - ->method('flush'); - - $this->document->delete($ids); - } - - public function testExceuteWithExistentNewQueryBuilder() - { - $builder = $this->stubBuilder(); - - $this->document->initQueryBuilder($builder); - - $columnsIterator = $this->createMock(ColumnsIterator::class); - $this->assertEquals(new Rows(), $this->document->execute($columnsIterator)); - } - - public function testExecuteWithPageAndLimit() - { - $page = 2; - $limit = 3; - $total = 6; - - $builder = $this->stubBuilder(); - - $builder - ->expects($this->once()) - ->method('skip') - ->with($total); - - $columnsIterator = $this->createMock(ColumnsIterator::class); - $this->assertEquals(new Rows(), $this->document->execute($columnsIterator, $page, $limit)); - } - - public function testExecuteWithLimit() - { - $limit = 3; - - $builder = $this->stubBuilder(); - - $builder - ->expects($this->once()) - ->method('limit') - ->with($limit); - - $columnsIterator = $this->createMock(ColumnsIterator::class); - $this->assertEquals(new Rows(), $this->document->execute($columnsIterator, 0, $limit)); - } - - public function testExecuteWithLimitPageAndMaxResultDecreasingLimit() - { - $page = 1; - $limit = 3; - $maxResult = 5; - $newLimit = $maxResult - $page * $limit; - - $builder = $this->stubBuilder(); - - $builder - ->expects($this->once()) - ->method('limit') - ->with($newLimit); - - $columnsIterator = $this->createMock(ColumnsIterator::class); - $this->assertEquals(new Rows(), $this->document->execute($columnsIterator, $page, $limit, $maxResult)); - } - - public function testExecuteWithLimitPageAndMaxResultNotDecreasingLimit() - { - $page = 2; - $limit = 7; - $maxResult = 50; - - $builder = $this->stubBuilder(); - - $builder - ->expects($this->once()) - ->method('limit') - ->with($limit); - - $columnsIterator = $this->createMock(ColumnsIterator::class); - $this->assertEquals(new Rows(), $this->document->execute($columnsIterator, $page, $limit, $maxResult)); - } - - public function testExecuteWithMaxResult() - { - $maxResult = 50; - - $builder = $this->stubBuilder(); - - $builder - ->expects($this->once()) - ->method('limit') - ->with($maxResult); - - $columnsIterator = $this->createMock(ColumnsIterator::class); - $this->assertEquals(new Rows(), $this->document->execute($columnsIterator, 0, 0, $maxResult)); - } - - public function testExecuteWithNoFilteredSubColumns() - { - $document = new DocumentEntity(); - $this->stubBuilder([$document]); - - $id = 'colId'; - $subCol = 'subCol'; - $colId = $id . '.' .$subCol; - - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - - $this->arrangeGetFieldsMetadata($id, ['type' => 'one', 'reference' => true, 'targetDocument' => 'foo']); - - $this->document->getFieldsMetadata('name', 'default'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $result = $this->document->execute($columnsIterator); - $iterator = $result->getIterator(); - - $this->assertEquals(1, $result->count()); - foreach ($iterator as $row) { - $this->assertAttributeEquals([$colId => 'subColValue'], 'fields', $row); - } - } - - /** - * @dataProvider filterProvider - */ - public function testExecuteWithFiltersOnSubColumns($operator, $method, $filterValue, $params) - { - $document = new DocumentEntity(); - - $cursor = $this->mockCursor([$document]); - - $query = $this->createMock(Query::class); - $query - ->method('execute') - ->willReturn($cursor); - - $builder = $this->createMock(Builder::class); - $builder - ->method('getQuery') - ->willReturn($query); - - $filter = $this->stubFilter($operator, $filterValue); - - $id = 'colId'; - $subCol = 'subCol'; - $colId = $id . '.' .$subCol; - - $column = $this->stubColumnWithFilters($colId, [$filter]); - - $helperCursor = $this->mockCursor([]); - - $helperQuery = $this->createMock(Query::class); - $helperQuery - ->method('execute') - ->willReturn($helperCursor); - - $helperBuilder = $this->stubBuilderWithField($subCol, $helperQuery); - - $createQbMap = [ - ['name', $builder], - ['foo', $helperBuilder] - ]; - - $this - ->manager - ->method('createQueryBuilder') - ->will($this->returnValueMap($createQbMap)); - - $this->arrangeGetFieldsMetadata($id, ['type' => 'one', 'reference' => true, 'targetDocument' => 'foo']); - - $this->document->getFieldsMetadata('name', 'default'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $helperBuilder - ->expects($this->once()) - ->method($method) - ->with($params); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithFiltersOnSubColumnsAndEmptyCursorResult() - { - $document = new DocumentEntity(); - $cursor = $this->mockCursor([$document]); - - $subDoc = new DocumentEntity(); - $helperCursor = $this->mockHelperCursor([$subDoc]); - - $filter = $this->stubFilter(Column::OPERATOR_EQ, 'aValue'); - - $id = 'colId'; - $subCol = 'subCol'; - $colId = $id . '.' .$subCol; - $column = $this->stubColumnWithFilters($colId, [$filter]); - - $query = $this->createMock(Query::class); - $query - ->method('execute') - ->willReturn($cursor); - - $builder = $this->createMock(Builder::class); - $builder - ->method('expr') - ->willReturn($builder); - $builder - ->method('field') - ->with($id) - ->willReturn($builder); - $builder - ->method('references') - ->with($subDoc) - ->willReturn($builder); - $builder - ->method('getQuery') - ->willReturn($query); - - $helperQuery = $this->createMock(Query::class); - $helperQuery - ->method('execute') - ->willReturn($helperCursor); - - $helperBuilder = $this->stubBuilderWithField($subCol, $helperQuery); - - $createQbMap = [ - ['name', $builder], - ['foo', $helperBuilder] - ]; - - $this - ->manager - ->method('createQueryBuilder') - ->will($this->returnValueMap($createQbMap)); - - $this->arrangeGetFieldsMetadata($id, ['type' => 'one', 'reference' => true, 'targetDocument' => 'foo']); - - $this->document->getFieldsMetadata('name', 'default'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->once()) - ->method('addOr') - ->with($builder); - $builder - ->expects($this->never()) - ->method('select'); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithFiltersOnSubColumnsAndCursorWithMoreThanOneResult() - { - $document = new DocumentEntity(); - $cursor = $this->mockCursor([$document]); - - $subDoc1 = new DocumentEntity(); - $subDoc2 = new DocumentEntity(); - $helperCursor = $this->mockHelperCursor([$subDoc1, $subDoc2]); - $helperCursor - ->method('count') - ->willReturn(2); - - $filter = $this->stubFilter(Column::OPERATOR_EQ, 'aValue'); - - $id = 'colId'; - $subCol = 'subCol'; - $colId = $id . '.' .$subCol; - $column = $this->stubColumnWithFilters($colId, [$filter]); - - $query = $this->createMock(Query::class); - $query - ->method('execute') - ->willReturn($cursor); - - $builder = $this->createMock(Builder::class); - $builder - ->method('expr') - ->willReturn($builder); - $builder - ->method('field') - ->with($id) - ->willReturn($builder); - $builder - ->method('references') - ->withConsecutive([$subDoc1], [$subDoc2]) - ->willReturn($builder); - $builder - ->method('getQuery') - ->willReturn($query); - - $helperQuery = $this->createMock(Query::class); - $helperQuery - ->method('execute') - ->willReturn($helperCursor); - - $helperBuilder = $this->stubBuilderWithField($subCol, $helperQuery); - - $createQbMap = [ - ['name', $builder], - ['foo', $helperBuilder] - ]; - - $this - ->manager - ->method('createQueryBuilder') - ->will($this->returnValueMap($createQbMap)); - - $this->arrangeGetFieldsMetadata($id, ['type' => 'one', 'reference' => true, 'targetDocument' => 'foo']); - - $this->document->getFieldsMetadata('name', 'default'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->once()) - ->method('addOr') - ->with($builder); - $builder - ->expects($this->once()) - ->method('select') - ->with($id); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithFiltersOnSubColumnsAndCursorWithOneResult() - { - $document = new DocumentEntity(); - $cursor = $this->mockCursor([$document]); - - $subDoc = new DocumentEntity(); - $helperCursor = $this->mockHelperCursor([$subDoc]); - $helperCursor - ->method('count') - ->willReturn(1); - - $filter = $this->stubFilter(Column::OPERATOR_EQ, 'aValue'); - - $id = 'colId'; - $subCol = 'subCol'; - $colId = $id . '.' .$subCol; - $column = $this->stubColumnWithFilters($colId, [$filter]); - - $query = $this->createMock(Query::class); - $query - ->method('execute') - ->willReturn($cursor); - - $builder = $this->stubBuilderWithField($id, $query); - - $helperQuery = $this->createMock(Query::class); - $helperQuery - ->method('execute') - ->willReturn($helperCursor); - - $helperBuilder = $this->stubBuilderWithField($subCol, $helperQuery); - - $createQbMap = [ - ['name', $builder], - ['foo', $helperBuilder] - ]; - - $this - ->manager - ->method('createQueryBuilder') - ->will($this->returnValueMap($createQbMap)); - - $this->arrangeGetFieldsMetadata($id, ['type' => 'one', 'reference' => true, 'targetDocument' => 'foo']); - - $this->document->getFieldsMetadata('name', 'default'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->once()) - ->method('references') - ->with($subDoc); - $builder - ->expects($this->once()) - ->method('select') - ->with($id); - $builder - ->expects($this->never()) - ->method('addOr') - ->with($builder); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithSubColumnsButNotGetter() - { - $this->expectException(\Exception::class); - - $document = new DocumentEntity(); - $this->stubBuilder([$document]); - - $id = 'colId'; - $subCol = 'subCol1'; - $colId = $id . '.' .$subCol; - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - - $this->arrangeGetFieldsMetadata($id, ['type' => 'one', 'reference' => true, 'targetDocument' => 'foo']); - - $this->document->getFieldsMetadata('name', 'default'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithSortedColumn() - { - $document = new DocumentEntity(); - $builder = $this->stubBuilder([$document]); - - $colId = 'colId'; - $colField = 'colField'; - $colOrder = 'asc'; - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - $column - ->method('isSorted') - ->willReturn(true); - $column - ->method('getField') - ->willReturn($colField); - $column - ->method('getOrder') - ->willReturn($colOrder); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->once()) - ->method('sort') - ->with($colField, $colOrder); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithPrimaryColumnAndDataDisjunction() - { - $document = new DocumentEntity(); - - $expr = $this->createMock(Expr::class); - $expr - ->method('field') - ->willReturn($expr); - - $builder = $this->stubBuilder([$document]); - $builder - ->method('expr') - ->willReturn($expr); - - $this - ->manager - ->method('createQueryBuilder') - ->with('name') - ->willReturn($builder); - - $filter = $this->stubFilter(Column::OPERATOR_EQ, 'aValue'); - - $colId = 'colId'; - - $column = $this->stubColumnWithFilters($colId, [$filter], true); - $column - ->method('getDataJunction') - ->willReturn(Column::DATA_DISJUNCTION); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $column - ->expects($this->once()) - ->method('setFilterable') - ->with(false); - - $builder - ->expects($this->never()) - ->method('addOr'); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithPrimaryColumnAndDataConjunction() - { - $document = new DocumentEntity(); - - $builder = $this->stubBuilder([$document]); - $builder - ->method('field') - ->willReturn($builder); - - $filter = $this->stubFilter(Column::OPERATOR_EQ, 'aValue'); - - $colId = 'colId'; - - $column = $this->stubColumnWithFilters($colId, [$filter], true); - $columnsIterator = $this->mockColumnsIterator([$column]); - - $column - ->expects($this->once()) - ->method('setFilterable') - ->with(false); - - $builder - ->expects($this->never()) - ->method('field'); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithoutPrimaryColumnDataDisjunctionAndNotFiltered() - { - $document = new DocumentEntity(); - $builder = $this->stubBuilder([$document]); - - $filterEqValue = 'filterValue'; - $filterEq = $this->stubFilter(Column::OPERATOR_EQ, $filterEqValue); - - $colId = 'colId'; - - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - $column - ->method('getFilters') - ->with('document') - ->willReturn([$filterEq]); - $column - ->method('getDataJunction') - ->willReturn(Column::DATA_DISJUNCTION); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->never()) - ->method('addOr'); - - $this->document->execute($columnsIterator); - } - - public function testExecuteWithoutPrimaryColumnDataConjunctionAndNotFiltered() - { - $document = new DocumentEntity(); - $builder = $this->stubBuilder([$document]); - - $filter = $this->stubFilter(Column::OPERATOR_EQ, 'aValue'); - - $colId = 'colId'; - - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - $column - ->method('getFilters') - ->with('document') - ->willReturn([$filter]); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->never()) - ->method('field'); - - $this->document->execute($columnsIterator); - } - - /** - * @dataProvider filterProvider - */ - public function testExecuteWithoutPrimaryColumnDataDisjunctionAndFilters($operator, $method, $filterValue, $params) - { - $document = new DocumentEntity(); - - $expr = $this->createMock(Expr::class); - $expr - ->method('field') - ->willReturn($expr); - $expr - ->method('addOr') - ->willReturn($expr); - - $builder = $this->stubBuilder([$document]); - $builder - ->method('expr') - ->willReturn($expr); - - $filter = $this->stubFilter($operator, $filterValue); - - $colId = 'colId'; - - $column = $this->stubColumnWithFilters($colId, [$filter]); - $column - ->method('getDataJunction') - ->willReturn(Column::DATA_DISJUNCTION); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->once()) - ->method('addOr'); - $expr - ->expects($this->once()) - ->method($method) - ->with($params); - - $this->document->execute($columnsIterator); - } - - /** - * @dataProvider filterProvider - */ - public function testExecuteWithoutPrimaryColumnDataConjunctionAndFilters($operator, $method, $filterValue, $params) - { - $document = new DocumentEntity(); - - $builder = $this->stubBuilder([$document]); - $builder - ->method('field') - ->willReturn($builder); - - $filter = $this->stubFilter($operator, $filterValue); - - $colId = 'colId'; - - $column = $this->stubColumnWithFilters($colId, [$filter]); - $column - ->method('getDataJunction') - ->willReturn(Column::DATA_CONJUNCTION); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $builder - ->expects($this->once()) - ->method($method) - ->with($params); - - $this->document->execute($columnsIterator); - } - - public function testExecuteAddingCorrectFieldsToRow() - { - $document = new DocumentEntity(); - $this->stubBuilder([$document]); - - $colId = 'colId'; - - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $result = $this->document->execute($columnsIterator); - - $this->assertEquals(1, $result->count()); - foreach ($columnsIterator as $row) { - $this->assertAttributeEquals([$colId => 'subColValue'], 'fields', $row); - } - } - - public function testGetTotalCountWithoutMaxResults() - { - $document = new DocumentEntity(); - $this->stubBuilder([$document]); - - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn('colId'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $this->document->execute($columnsIterator); - - $this->assertEquals(1, $this->document->getTotalCount()); - } - - public function testGetTotalCountWithMaxResults() - { - $document = new DocumentEntity(); - $document2 = new DocumentEntity(); - $this->stubBuilder([$document, $document2]); - - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn('colId'); - - $columnsIterator = $this->mockColumnsIterator([$column]); - - $this->document->execute($columnsIterator); - - $this->assertEquals(1, $this->document->getTotalCount(1)); - } - - public function testReturnsColumns() - { - $columns = $this->createMock(Columns::class); - - $column = $this->createMock(Column::class); - $column2 = $this->createMock(Column::class); - $cols = [$column, $column2]; - - $splObjStorage = $this->createMock(\SplObjectStorage::class); - - $splObjStorage - ->expects($this->at(0)) - ->method('rewind'); - - $counter = 1; - foreach ($cols as $k => $v) { - $splObjStorage - ->expects($this->at($counter++)) - ->method('valid') - ->willReturn(true); - - $splObjStorage - ->expects($this->at($counter++)) - ->method('current') - ->willReturn($v); - - $splObjStorage - ->expects($this->at($counter++)) - ->method('key') - ->willReturn($k); - - $splObjStorage - ->expects($this->at($counter)) - ->method('next'); - } - - $this - ->metadata - ->method('getColumnsFromMapping') - ->with($columns) - ->willReturn($splObjStorage); - - $columns - ->expects($this->exactly(2)) - ->method('addColumn') - ->withConsecutive([$column], [$column2]); - - $this->document->getColumns($columns); - } - - public function testPopulateSelectFilters() - { - // @todo Don't know how to move on with __clone method on stubs / mocks - } - - private function stubBuilder(array $documents = []) - { - $cursor = $this->mockCursor($documents); - - $query = $this->createMock(Query::class); - $query - ->method('execute') - ->willReturn($cursor); - - $builder = $this->createMock(Builder::class); - $builder - ->method('getQuery') - ->willReturn($query); - - $this - ->manager - ->method('createQueryBuilder') - ->with('name') - ->willReturn($builder); - - return $builder; - } - - private function stubBuilderWithField($col, $query) - { - $builder = $this->createMock(Builder::class); - $builder - ->method('field') - ->with($col) - ->willReturn($builder); - $builder - ->method('getQuery') - ->willReturn($query); - - return $builder; - } - - private function stubColumnWithFilters($colId, $filters, $isPrimary = false) - { - $column = $this->createMock(Column::class); - $column - ->method('getId') - ->willReturn($colId); - $column - ->method('isPrimary') - ->willReturn($isPrimary); - $column - ->method('isFiltered') - ->willReturn(true); - $column - ->method('getFilters') - ->with('document') - ->willReturn($filters); - - return $column; - } - - private function stubFilter($operator, $filterValue) - { - $filter = $this->createMock(Filter::class); - $filter - ->method('getOperator') - ->willReturn($operator); - $filter - ->method('getValue') - ->willReturn($filterValue); - - return $filter; - } - - /** - * @param string $name - * @param array $fieldMapping - */ - private function arrangeGetFieldsMetadata($name, array $fieldMapping) - { - $property = $this->createMock(\ReflectionProperty::class); - $property - ->method('getName') - ->willReturn($name); - - $this - ->odmMetadata - ->method('getReflectionProperties') - ->willReturn([$property]); - $this - ->odmMetadata - ->method('getFieldMapping') - ->with($name) - ->willReturn($fieldMapping); - } - - /** - * @param array $elements - * - * @return \PHPUnit\Framework\MockObject\MockObject - */ - private function mockColumnsIterator(array $elements) - { - $colIter = $this->createMock(ColumnsIterator::class); - - $colIter - ->expects($this->at(0)) - ->method('rewind'); - - $counter = 1; - foreach ($elements as $k => $v) { - $colIter - ->expects($this->at($counter++)) - ->method('valid') - ->willReturn(true); - - $colIter - ->expects($this->at($counter++)) - ->method('current') - ->willReturn($v); - - $colIter - ->expects($this->at($counter++)) - ->method('key') - ->willReturn($k); - - $colIter - ->expects($this->at($counter++)) - ->method('next'); - } - - return $colIter; - } - - /** - * @param array $resources - * - * @return \PHPUnit\Framework\MockObject\MockObject - */ - private function mockCursor(array $resources) - { - $cursor = $this->createMock(Cursor::class); - - if (empty($resources)) { - return $cursor; - } - - $cursor - ->expects($this->at(0)) - ->method('count') - ->willReturn(count($resources)); - - $cursor - ->expects($this->at(1)) - ->method('rewind'); - - $counter = 2; - foreach ($resources as $k => $v) { - $cursor - ->expects($this->at($counter++)) - ->method('valid') - ->willReturn(true); - - $cursor - ->expects($this->at($counter++)) - ->method('current') - ->willReturn($v); - } - - return $cursor; - } - - /** - * @param array $resources - * - * @return \PHPUnit\Framework\MockObject\MockObject - */ - private function mockHelperCursor(array $resources) - { - $cursor = $this->createMock(Cursor::class); - - if (empty($resources)) { - return $cursor; - } - - $cursor - ->expects($this->at(0)) - ->method('count') - ->willReturn(count($resources)); - - $counter = 1; - foreach ($resources as $k => $v) { - $cursor - ->expects($this->at($counter++)) - ->method('valid') - ->willReturn(true); - - $cursor - ->expects($this->at($counter++)) - ->method('current') - ->willReturn($v); - } - - return $cursor; - } - - public function filterProvider() - { - $value = 'filterValue'; - - return [ - 'Filter EQ' => [Column::OPERATOR_EQ, 'equals', $value, $value], - 'Filter LIKE' => [Column::OPERATOR_LIKE, 'equals', $value, new Regex($value, 'i')], - 'Filter NLIKE' => [Column::OPERATOR_NLIKE, 'equals', $value, new Regex('^((?!' . $value . ').)*$', 'i')], - 'Filter RLIKE' => [Column::OPERATOR_RLIKE, 'equals', $value, new Regex('^' . $value, 'i')], - 'Filter LLIKE' => [Column::OPERATOR_LLIKE, 'equals', $value, new Regex($value . '$', 'i')], - 'Filter SLIKE' => [Column::OPERATOR_SLIKE, 'equals', $value, new Regex($value, '')], - 'Filter NSLIKE' => [Column::OPERATOR_NSLIKE, 'equals', $value, $value], - 'Filter RSLIKE' => [Column::OPERATOR_RSLIKE, 'equals', $value, new Regex('^' . $value, '')], - 'Filter LSLIKE' => [Column::OPERATOR_LSLIKE, 'equals', $value, new Regex($value . '$', '')], - 'Filter NEQ' => [Column::OPERATOR_NEQ, 'equals', $value, new Regex('^(?!' . $value . '$).*$', 'i')], - 'Filter ISNULL' => [Column::OPERATOR_ISNULL, 'exists', $value, false], - 'Filter ISNOTNULL' => [Column::OPERATOR_ISNOTNULL, 'exists', $value, true] - ]; - } - - public function fieldsMetadataProvider() - { - $name = 'propName'; - $fieldName = 'fieldName'; - - return [ - 'Title only' => [ - $name, - ['type' => 'text'], - [$name => ['title' => $name, 'source' => true, 'type' => 'text']] - ], - 'Field name' => [ - $name, - ['type' => 'text', 'fieldName' => $fieldName], - [$name => ['title' => $name, 'source' => true, 'type' => 'text', 'field' => $fieldName, 'id' => $fieldName]] - ], - 'Not primary' => [ - $name, - ['type' => 'text', 'id' => 'notId'], - [$name => ['title' => $name, 'source' => true, 'type' => 'text']] - ], - 'Primary' => [ - $name, - ['type' => 'text', 'id' => 'id'], - [$name => ['title' => $name, 'source' => true, 'type' => 'text', 'primary' => true]] - ], - 'Id type' => [ - $name, - ['type' => 'id', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'String type' => [ - $name, - ['type' => 'string', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Bin custom type' => [ - $name, - ['type' => 'bin_custom', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Bin func type' => [ - $name, - ['type' => 'bin_func', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Bin md5 type' => [ - $name, - ['type' => 'bin_md5', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Bin type' => [ - $name, - ['type' => 'bin', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Bin uuid type' => [ - $name, - ['type' => 'bin_uuid', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'File type' => [ - $name, - ['type' => 'file', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Key type' => [ - $name, - ['type' => 'key', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Increment type' => [ - $name, - ['type' => 'increment', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Int type' => [ - $name, - ['type' => 'int', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'number', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Float type' => [ - $name, - ['type' => 'float', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'number', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Boolean type' => [ - $name, - ['type' => 'boolean', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'boolean', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Date type' => [ - $name, - ['type' => 'date', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'date', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Timestamp type' => [ - $name, - ['type' => 'timestamp', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'date', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'Collection type' => [ - $name, - ['type' => 'collection', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'array', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'One type' => [ - $name, - ['type' => 'one', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'array', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true]] - ], - 'One cardinality false ref type' => [ - $name, - ['type' => 'one', 'id' => 'id', 'fieldName' => $fieldName, 'reference' => 'aa'], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'array', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true, - ]] - ], - 'One cardinality with reference type' => [ - $name, - ['type' => 'one', 'id' => 'id', 'fieldName' => $fieldName, 'reference' => true, 'targetDocument' => 'foo'], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'array', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true, - ]], - [$name => 'foo'] - ], - 'Many type' => [ - $name, - ['type' => 'many', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'array', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true, - ]] - ], - 'Many type with non configured types map type' => [ - $name, - ['type' => 'foo', 'id' => 'id', 'fieldName' => $fieldName], - [$name => [ - 'title' => $name, - 'source' => true, - 'type' => 'text', - 'field' => $fieldName, - 'id' => $fieldName, - 'primary' => true, - ]] - ] - ]; - } -} - -class DocumentEntity -{ - private $colId; - - private $subCol; - - public function __construct() - { - $this->colId = $this; - $this->subCol = 'subColValue'; - } - - public function getColId() - { - return $this->colId; - } - - public function getSubCol() - { - return $this->subCol; - } -} From 7de446f3cd97382dab3dea50286686238a9fb472 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 13:33:28 -0500 Subject: [PATCH 18/41] Remove trailing comma --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 145983d1..edf076da 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "symfony/expression-language": "^4.4|^5.2", "symfony/phpunit-bridge": "^4.4|^5.2", "phpunit/phpunit": "^8.5", - "doctrine/orm": "~2.4,>=2.4.5", + "doctrine/orm": "~2.4,>=2.4.5" }, "suggest": { "ext-intl": "Translate the grid", From 49f4a31587f0d10eabe834c665c31c212f72c946 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 13:36:27 -0500 Subject: [PATCH 19/41] Remove trailing comma --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index edf076da..ffbe09ff 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "ext-intl": "Translate the grid", "ext-mbstring": "Convert your data with the right charset", "PHPExcel": "Export the grid (Excel, HTML or PDF)", - "doctrine/orm": "If you want to use Entity as source, please require doctrine/orm", + "doctrine/orm": "If you want to use Entity as source, please require doctrine/orm" }, "autoload": { "psr-4": { From a8601f9f2bd981982dfa69d33092ef248b0e43e2 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 13:40:32 -0500 Subject: [PATCH 20/41] Remove invalid test --- tests/Grid/Column/BooleanColumnTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Grid/Column/BooleanColumnTest.php b/tests/Grid/Column/BooleanColumnTest.php index 83ad730c..52c02801 100644 --- a/tests/Grid/Column/BooleanColumnTest.php +++ b/tests/Grid/Column/BooleanColumnTest.php @@ -86,7 +86,6 @@ public function testIsQueryValid() $this->assertTrue($this->column->isQueryValid(false)); $this->assertTrue($this->column->isQueryValid(1)); $this->assertTrue($this->column->isQueryValid(0)); - $this->assertTrue($this->column->isQueryValid('foo')); // should this be true!? } public function testRenderCell() From 233847defdccfbec55a226ec4eaba2c7cf234ee8 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:12:33 -0500 Subject: [PATCH 21/41] WIP: Address test deprecation warnings --- rector.php | 0 src/Grid/Action/RowAction.php | 4 + src/Grid/Grid.php | 70 ++ src/Grid/GridConfigBuilder.php | 13 +- tests/Grid/Action/DeleteMassActionTest.php | 4 +- tests/Grid/Action/MassActionTest.php | 60 +- tests/Grid/Action/RowActionTest.php | 109 +-- tests/Grid/FilterTest.php | 30 +- tests/Grid/GridConfigBuilderTest.php | 106 +-- tests/Grid/GridManagerTest.php | 53 +- tests/Grid/GridTest.php | 813 ++++++++++----------- 11 files changed, 513 insertions(+), 749 deletions(-) create mode 100644 rector.php diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..e69de29b diff --git a/src/Grid/Action/RowAction.php b/src/Grid/Action/RowAction.php index 34f281b0..cae723e7 100644 --- a/src/Grid/Action/RowAction.php +++ b/src/Grid/Action/RowAction.php @@ -371,6 +371,10 @@ public function addManipulateRender($callback) return $this; } + public function getCallbacks(): array { + return $this->callbacks; + } + /** * Render action for row. * diff --git a/src/Grid/Grid.php b/src/Grid/Grid.php index 93d2fc7e..bce8ec91 100644 --- a/src/Grid/Grid.php +++ b/src/Grid/Grid.php @@ -1217,6 +1217,11 @@ public function getColumns() return $this->columns; } + public function getLazyAddColumn(): array + { + return $this->lazyAddColumn; + } + /** * Returns true if column exists in columns and lazyAddColumn properties. * @@ -1577,6 +1582,16 @@ protected function setFilters(array $filters, $permanent = true) return $this; } + public function getPermanentFilters(): array + { + return $this->permanentFilters; + } + + public function getDefaultFilters(): array + { + return $this->defaultFilters; + } + /** * Set permanent value for filters. * @@ -1616,6 +1631,11 @@ public function setDefaultOrder($columnId, $order) return $this; } + public function getDefaultOrder(): ?string + { + return $this->defaultOrder; + } + /** * Sets unique filter identification. * @@ -1764,6 +1784,11 @@ public function setDefaultTweak($tweakId) return $this; } + public function getDefaultTweak(): ?string + { + return $this->defaultTweak; + } + /** * Sets current Page (internal). * @@ -1850,6 +1875,11 @@ public function setMaxResults($maxResults = null) return $this; } + public function getMaxResults() + { + return $this->maxResults; + } + /** * Return true if the grid is filtered. * @@ -1931,6 +1961,11 @@ public function hideFilters() return $this; } + public function getShowFilters(): bool + { + return $this->showFilters; + } + /** * Hides Titles panel. * @@ -1943,6 +1978,11 @@ public function hideTitles() return $this; } + public function getShowTitles(): bool + { + return $this->showTitles; + } + /** * Adds Column Extension - internal helper. * @@ -2043,6 +2083,11 @@ public function setHiddenColumns($columnIds) return $this; } + public function getHiddenColumns(): array + { + return $this->lazyHiddenColumns; + } + /** * Sets a list of columns to show when the grid is output * It acts as a mask; Other columns will be set as hidden. @@ -2058,6 +2103,11 @@ public function setVisibleColumns($columnIds) return $this; } + public function getVisibleColumns(): array + { + return $this->lazyVisibleColumns; + } + /** * Sets on the visibility of columns. * @@ -2090,6 +2140,11 @@ public function hideColumns($columnIds) return $this; } + public function getLazyHideShowColumns(): array + { + return $this->lazyHideShowColumns; + } + /** * Sets the size of the default action column. * @@ -2104,6 +2159,16 @@ public function setActionsColumnSize($size) return $this; } + public function getActionsColumnSize(): ?int + { + return $this->actionsColumnSize; + } + + public function getNewSession(): bool + { + return $this->newSession; + } + /** * Sets the title of the default action column. * @@ -2118,6 +2183,11 @@ public function setActionsColumnTitle($title) return $this; } + public function getActionsColumnTitle(): ?string + { + return $this->actionsColumnTitle; + } + /** * Sets whether or not mass actions should be opened in a new tab * diff --git a/src/Grid/GridConfigBuilder.php b/src/Grid/GridConfigBuilder.php index e03376ac..d809a829 100644 --- a/src/Grid/GridConfigBuilder.php +++ b/src/Grid/GridConfigBuilder.php @@ -105,7 +105,7 @@ class GridConfigBuilder implements GridConfigBuilderInterface */ public function __construct($name, array $options = []) { - $this->name = $name; + $this->name = $name; $this->options = $options; } @@ -434,7 +434,8 @@ public function setGroupBy($groupBy) * * @return $this */ - public function setMassActionsInNewTab($massActionsInNewTab) { + public function setMassActionsInNewTab($massActionsInNewTab) + { $this->massActionsInNewTab = (bool)$massActionsInNewTab; return $this; @@ -443,7 +444,8 @@ public function setMassActionsInNewTab($massActionsInNewTab) { /** * @return bool */ - public function getMassActionsInNewTab() { + public function getMassActionsInNewTab() + { return (bool)$this->massActionsInNewTab; } @@ -459,6 +461,11 @@ public function addAction(RowActionInterface $action) return $this; } + public function getActions(): array + { + return $this->actions; + } + /** * {@inheritdoc} */ diff --git a/tests/Grid/Action/DeleteMassActionTest.php b/tests/Grid/Action/DeleteMassActionTest.php index 69d1937b..114d8a9c 100644 --- a/tests/Grid/Action/DeleteMassActionTest.php +++ b/tests/Grid/Action/DeleteMassActionTest.php @@ -10,12 +10,12 @@ class DeleteMassActionTest extends TestCase public function testConstructWithConfirmation() { $ma = new DeleteMassAction(true); - $this->assertAttributeEquals(true, 'confirm', $ma); + $this->assertSame(true, $ma->getConfirm()); } public function testConstructWithoutConfirmation() { $ma = new DeleteMassAction(); - $this->assertAttributeEquals(false, 'confirm', $ma); + $this->assertSame(false, $ma->getConfirm()); } } diff --git a/tests/Grid/Action/MassActionTest.php b/tests/Grid/Action/MassActionTest.php index 3ba6551f..18c57651 100644 --- a/tests/Grid/Action/MassActionTest.php +++ b/tests/Grid/Action/MassActionTest.php @@ -32,19 +32,11 @@ public function setUp(): void public function testMassActionConstruct() { - $this->assertAttributeEquals($this->title, 'title', $this->massAction); - $this->assertAttributeEquals($this->callback, 'callback', $this->massAction); - $this->assertAttributeEquals($this->confirm, 'confirm', $this->massAction); - $this->assertAttributeEquals($this->parameters, 'parameters', $this->massAction); - $this->assertAttributeEquals($this->role, 'role', $this->massAction); - } - - public function testSetTile() - { - $title = 'bar'; - $this->massAction->setTitle($title); - - $this->assertAttributeEquals($title, 'title', $this->massAction); + $this->assertSame($this->title, $this->massAction->getTitle()); + $this->assertSame($this->callback, $this->massAction->getCallback()); + $this->assertSame($this->confirm, $this->massAction->getConfirm()); + $this->assertSame($this->parameters, $this->massAction->getParameters()); + $this->assertSame($this->role, $this->massAction->getRole()); } public function testGetTitle() @@ -55,14 +47,6 @@ public function testGetTitle() $this->assertEquals($title, $this->massAction->getTitle()); } - public function testSetCallback() - { - $callback = 'self::fooMassAction'; - $this->massAction->setCallback($callback); - - $this->assertAttributeEquals($callback, 'callback', $this->massAction); - } - public function testGetCallback() { $callback = 'self::barMassAction'; @@ -71,14 +55,6 @@ public function testGetCallback() $this->assertEquals($callback, $this->massAction->getCallback()); } - public function testSetConfirm() - { - $confirm = false; - $this->massAction->setConfirm($confirm); - - $this->assertAttributeEquals($confirm, 'confirm', $this->massAction); - } - public function testGetConfirm() { $confirm = false; @@ -89,15 +65,7 @@ public function testGetConfirm() public function testDefaultConfirmMessage() { - $this->assertInternalType('string', $this->massAction->getConfirmMessage()); - } - - public function testSetConfirmMessage() - { - $message = 'A foo test message'; - $this->massAction->setConfirmMessage($message); - - $this->assertAttributeEquals($message, 'confirmMessage', $this->massAction); + $this->assertIsString($this->massAction->getConfirmMessage()); } public function testGetConfirmMessage() @@ -108,14 +76,6 @@ public function testGetConfirmMessage() $this->assertEquals($message, $this->massAction->getConfirmMessage()); } - public function testSetParameters() - { - $params = [1 => 1, 2 => 2]; - $this->massAction->setParameters($params); - - $this->assertAttributeEquals($params, 'parameters', $this->massAction); - } - public function testGetParameters() { $params = [1, 2, 3]; @@ -124,14 +84,6 @@ public function testGetParameters() $this->assertEquals($params, $this->massAction->getParameters()); } - public function testSetRole() - { - $role = 'ROLE_ADMIN'; - $this->massAction->setRole($role); - - $this->assertAttributeEquals($role, 'role', $this->massAction); - } - public function testGetRole() { $role = 'ROLE_SUPER_ADMIN'; diff --git a/tests/Grid/Action/RowActionTest.php b/tests/Grid/Action/RowActionTest.php index 77961340..2d6cc8eb 100644 --- a/tests/Grid/Action/RowActionTest.php +++ b/tests/Grid/Action/RowActionTest.php @@ -40,15 +40,7 @@ protected function setUp(): void $this->rowAction = new RowAction( $this->title, $this->route, $this->confirm, $this->target, $this->attributes, $this->role ); - $this->row = $this->createMock(Row::class); - } - - public function testSetTitle() - { - $title = 'foo_title'; - $this->rowAction->setTitle($title); - - $this->assertAttributeEquals($title, 'title', $this->rowAction); + $this->row = $this->createMock(Row::class); } public function testGetTitle() @@ -59,14 +51,6 @@ public function testGetTitle() $this->assertEquals($title, $this->rowAction->getTitle()); } - public function testSetRoute() - { - $route = 'another_vendor.another_bundle.controller.route_name'; - $this->rowAction->setRoute($route); - - $this->assertAttributeEquals($route, 'route', $this->rowAction); - } - public function testGetRoute() { $route = 'another_vendor.another_bundle.controller.route_name'; @@ -75,14 +59,6 @@ public function testGetRoute() $this->assertEquals($route, $this->rowAction->getRoute()); } - public function testSetConfirm() - { - $confirm = true; - $this->rowAction->setConfirm($confirm); - - $this->assertAttributeEquals(true, 'confirm', $this->rowAction); - } - public function testGetConfirmation() { $confirm = true; @@ -93,15 +69,7 @@ public function testGetConfirmation() public function testDefaultConfirmMessage() { - $this->assertInternalType('string', $this->rowAction->getConfirmMessage()); - } - - public function testSetConfirmMessage() - { - $message = 'A foo test message'; - $this->rowAction->setConfirmMessage($message); - - $this->assertAttributeEquals($message, 'confirmMessage', $this->rowAction); + $this->assertIsString($this->rowAction->getConfirmMessage()); } public function testGetConfirmMessage() @@ -112,14 +80,6 @@ public function testGetConfirmMessage() $this->assertEquals($message, $this->rowAction->getConfirmMessage()); } - public function testSetTarget() - { - $target = '_self'; - $this->rowAction->setTarget($target); - - $this->assertAttributeEquals($target, 'target', $this->rowAction); - } - public function testGetTarget() { $target = '_blank'; @@ -128,14 +88,6 @@ public function testGetTarget() $this->assertEquals($target, $this->rowAction->getTarget()); } - public function testSetColumn() - { - $col = 'foo'; - $this->rowAction->setColumn($col); - - $this->assertAttributeEquals($col, 'column', $this->rowAction); - } - public function testGetColumn() { $col = 'bar'; @@ -158,10 +110,9 @@ public function testAddRouteParameters() $associativeParam = ['foo' => 'fooParam', 'bar' => 'barParam']; $this->rowAction->addRouteParameters($associativeParam); - $this->assertAttributeEquals( + $this->assertSame( array_merge([0 => $stringParam, 1 => $string2Param, 2 => $intKeyParam[1], 3 => $intKeyParam[2]], $associativeParam), - 'routeParameters', - $this->rowAction + $this->rowAction->getRouteParameters() ); } @@ -170,15 +121,8 @@ public function testSetStringRouteParameters() $param = 'param'; $this->rowAction->setRouteParameters($param); - $this->assertAttributeEquals([0 => $param], 'routeParameters', $this->rowAction); - } - - public function testSetArrayRouteParameters() - { - $params = ['foo' => 'foo_param', 'bar' => 'bar_param']; - $this->rowAction->setRouteParameters($params); - $this->assertAttributeEquals($params, 'routeParameters', $this->rowAction); + $this->assertSame([0 => $param], $this->rowAction->getRouteParameters()); } public function testGetRouteParameters() @@ -189,18 +133,10 @@ public function testGetRouteParameters() $this->assertEquals($params, $this->rowAction->getRouteParameters()); } - public function testSetRouteParametersMapping() - { - $routeParamsMapping = ['foo.bar.city' => 'cityId', 'foo.bar.country' => 'countryId']; - $this->rowAction->setRouteParametersMapping($routeParamsMapping); - - $this->assertAttributeEquals($routeParamsMapping, 'routeParametersMapping', $this->rowAction); - } - public function testGetRouteParametersMapping() { - $routeParamKey = 'foo.bar.city'; - $routeParamValue = 'cityId'; + $routeParamKey = 'foo.bar.city'; + $routeParamValue = 'cityId'; $routeParamsMapping = [$routeParamKey => $routeParamValue]; $this->rowAction->setRouteParametersMapping($routeParamsMapping); @@ -213,19 +149,18 @@ public function testSetAttributes() $attr = ['foo' => 'foo_val', 'bar' => 'bar_val']; $this->rowAction->setAttributes($attr); - $this->assertAttributeEquals($attr, 'attributes', $this->rowAction); + $this->assertSame($attr, $this->rowAction->getAttributes()); } public function testAddAttribute() { $attrName = 'foo1'; - $attrVal = 'foo_val1'; + $attrVal = 'foo_val1'; $this->rowAction->addAttribute($attrName, $attrVal); - $this->assertAttributeEquals( + $this->assertSame( array_merge($this->attributes, [$attrName => $attrVal]), - 'attributes', - $this->rowAction + $this->rowAction->getAttributes() ); } @@ -234,14 +169,6 @@ public function testGetAttributes() $this->assertEquals($this->attributes, $this->rowAction->getAttributes()); } - public function testSetRole() - { - $role = 'ROLE_ADMIN'; - $this->rowAction->setRole($role); - - $this->assertAttributeEquals($role, 'role', $this->rowAction); - } - public function testGetRole() { $role = 'ROLE_SUPER_ADMIN'; @@ -252,19 +179,23 @@ public function testGetRole() public function testManipulateRender() { - $callback1 = function () { return 1; }; - $callback2 = function () { return 2; }; + $callback1 = function () { + return 1; + }; + $callback2 = function () { + return 2; + }; $this->rowAction->manipulateRender($callback1); $this->rowAction->manipulateRender($callback2); - $this->assertAttributeEquals([$callback1, $callback2], 'callbacks', $this->rowAction); + $this->assertSame([$callback1, $callback2], $this->rowAction->getCallbacks()); } public function testAddManipulateRender() { $this->addCalbacks(); - $this->assertAttributeEquals($this->callbacks, 'callbacks', $this->rowAction); + $this->assertSame($this->callbacks, $this->rowAction->getCallbacks()); } private function addCalbacks() @@ -325,7 +256,7 @@ public function testSetEnabled() $enabled = true; $this->rowAction->setEnabled($enabled); - $this->assertAttributeEquals($enabled, 'enabled', $this->rowAction); + $this->assertSame($enabled, $this->rowAction->getEnabled()); } public function testGetEnabled() diff --git a/tests/Grid/FilterTest.php b/tests/Grid/FilterTest.php index d290cbd8..144c5a01 100644 --- a/tests/Grid/FilterTest.php +++ b/tests/Grid/FilterTest.php @@ -11,17 +11,9 @@ public function testCreateFilters() { $filter1 = new Filter('like', 'foo', 'column1'); - $this->assertAttributeEquals('like', 'operator', $filter1); - $this->assertAttributeEquals('foo', 'value', $filter1); - $this->assertAttributeEquals('column1', 'columnName', $filter1); - } - - public function testSetOperator() - { - $filter = new Filter('like'); - $filter->setOperator('nlike'); - - $this->assertAttributeEquals('nlike', 'operator', $filter); + $this->assertSame('like', $filter1->getOperator()); + $this->assertSame('foo', $filter1->getValue()); + $this->assertSame('column1', $filter1->getColumnName()); } public function testGetOperator() @@ -31,14 +23,6 @@ public function testGetOperator() $this->assertEquals('like', $filter->getOperator()); } - public function testSetValue() - { - $filter = new Filter('like'); - $filter->setValue('foo'); - - $this->assertAttributeEquals('foo', 'value', $filter); - } - public function testGetValue() { $filter = new Filter('like', 'foo'); @@ -46,14 +30,6 @@ public function testGetValue() $this->assertEquals('foo', $filter->getValue()); } - public function testSetColumnName() - { - $filter = new Filter('like'); - $filter->setColumnName('col1'); - - $this->assertAttributeEquals('col1', 'columnName', $filter); - } - public function testGetColumnName() { $filter = new Filter('like', null, 'col1'); diff --git a/tests/Grid/GridConfigBuilderTest.php b/tests/Grid/GridConfigBuilderTest.php index 6c5c8bac..6ad42203 100644 --- a/tests/Grid/GridConfigBuilderTest.php +++ b/tests/Grid/GridConfigBuilderTest.php @@ -32,14 +32,6 @@ public function testGetName() $this->assertEquals($this->name, $this->gridConfigBuilder->getName()); } - public function testSetSource() - { - $source = $this->createMock(Source::class); - $this->gridConfigBuilder->setSource($source); - - $this->assertAttributeSame($source, 'source', $this->gridConfigBuilder); - } - public function testGetSource() { $source = $this->createMock(Source::class); @@ -48,14 +40,6 @@ public function testGetSource() $this->assertSame($source, $this->gridConfigBuilder->getSource()); } - public function testSetType() - { - $type = $this->createMock(GridTypeInterface::class); - $this->gridConfigBuilder->setType($type); - - $this->assertAttributeSame($type, 'type', $this->gridConfigBuilder); - } - public function testGetType() { $type = $this->createMock(GridTypeInterface::class); @@ -64,14 +48,6 @@ public function testGetType() $this->assertSame($type, $this->gridConfigBuilder->getType()); } - public function testSetRoute() - { - $route = 'vendor.bundle.foo_route'; - $this->gridConfigBuilder->setRoute($route); - - $this->assertAttributeEquals($route, 'route', $this->gridConfigBuilder); - } - public function testGetRoute() { $route = 'vendor.bundle.foo_route'; @@ -80,14 +56,6 @@ public function testGetRoute() $this->assertEquals($route, $this->gridConfigBuilder->getRoute()); } - public function testSetRouteParameters() - { - $routeParams = ['foo' => 'foo', 'bar' => 'bar']; - $this->gridConfigBuilder->setRouteParameters($routeParams); - - $this->assertAttributeEquals($routeParams, 'routeParameters', $this->gridConfigBuilder); - } - public function testGetRouteParameters() { $routeParams = ['foo' => 'foo', 'bar' => 'bar']; @@ -96,14 +64,6 @@ public function testGetRouteParameters() $this->assertEquals($routeParams, $this->gridConfigBuilder->getRouteParameters()); } - public function testSetPersistence() - { - $persistence = true; - $this->gridConfigBuilder->setPersistence($persistence); - - $this->assertAttributeEquals($persistence, 'persistence', $this->gridConfigBuilder); - } - public function testIsPersited() { $persisted = false; @@ -112,14 +72,6 @@ public function testIsPersited() $this->assertFalse($this->gridConfigBuilder->isPersisted()); } - public function testSetPage() - { - $page = 1; - $this->gridConfigBuilder->setPage($page); - - $this->assertAttributeEquals($page, 'page', $this->gridConfigBuilder); - } - public function testGetPage() { $page = 5; @@ -146,14 +98,6 @@ public function testGetOption() $this->assertNull($this->gridConfigBuilder->getOption('foobar')); } - public function testSetMaxPerPage() - { - $limit = 50; - $this->gridConfigBuilder->setMaxPerPage($limit); - - $this->assertAttributeEquals($limit, 'limit', $this->gridConfigBuilder); - } - public function testGetMaxPerPage() { $limit = 100; @@ -162,14 +106,6 @@ public function testGetMaxPerPage() $this->assertEquals($limit, $this->gridConfigBuilder->getMaxPerPage()); } - public function testSetMaxResults() - { - $maxResults = 50; - $this->gridConfigBuilder->setMaxResults($maxResults); - - $this->assertAttributeEquals($maxResults, 'maxResults', $this->gridConfigBuilder); - } - public function testGetMaxResults() { $maxResults = 100; @@ -178,14 +114,6 @@ public function testGetMaxResults() $this->assertEquals($maxResults, $this->gridConfigBuilder->getMaxResults()); } - public function testSetSortable() - { - $sortable = true; - $this->gridConfigBuilder->setSortable($sortable); - - $this->assertAttributeEquals(true, 'sortable', $this->gridConfigBuilder); - } - public function testIsSortable() { $sortable = false; @@ -194,14 +122,6 @@ public function testIsSortable() $this->assertFalse($this->gridConfigBuilder->isSortable()); } - public function testSetFilterable() - { - $filterable = false; - $this->gridConfigBuilder->setFilterable($filterable); - - $this->assertAttributeEquals($filterable, 'filterable', $this->gridConfigBuilder); - } - public function testIsFilterable() { $filterable = true; @@ -210,14 +130,6 @@ public function testIsFilterable() $this->assertTrue($this->gridConfigBuilder->isFilterable()); } - public function testSetOrder() - { - $order = 'asc'; - $this->gridConfigBuilder->setOrder($order); - - $this->assertAttributeEquals($order, 'order', $this->gridConfigBuilder); - } - public function testGetOrder() { $order = 'desc'; @@ -226,14 +138,6 @@ public function testGetOrder() $this->assertEquals($order, $this->gridConfigBuilder->getOrder()); } - public function testSetSortBy() - { - $sortBy = 'foo'; - $this->gridConfigBuilder->setSortBy($sortBy); - - $this->assertAttributeEquals($sortBy, 'sortBy', $this->gridConfigBuilder); - } - public function testGetSortBy() { $sortBy = 'bar'; @@ -242,14 +146,6 @@ public function testGetSortBy() $this->assertEquals($sortBy, $this->gridConfigBuilder->getSortBy()); } - public function testSetGroupBy() - { - $groupBy = 'foo'; - $this->gridConfigBuilder->setGroupBy($groupBy); - - $this->assertAttributeEquals($groupBy, 'groupBy', $this->gridConfigBuilder); - } - public function testGetGroupBy() { $groupBy = ['foo', 'bar']; @@ -274,7 +170,7 @@ public function testAddAction() ->addAction($action2) ->addAction($action3); - $this->assertAttributeEquals(['foo' => [$action1], 'bar' => [$action2, $action3]], 'actions', $this->gridConfigBuilder); + $this->assertSame(['foo' => [$action1], 'bar' => [$action2, $action3]], $this->gridConfigBuilder->getActions()); } public function testGetGridConfig() diff --git a/tests/Grid/GridManagerTest.php b/tests/Grid/GridManagerTest.php index 47e70fc0..6a759ba6 100644 --- a/tests/Grid/GridManagerTest.php +++ b/tests/Grid/GridManagerTest.php @@ -23,7 +23,7 @@ class GridManagerTest extends TestCase public function setUp(): void { - $this->container = $this->createMock(Container::class); + $this->container = $this->createMock(Container::class); $this->gridManager = new GridManager($this->container); } @@ -50,7 +50,7 @@ public function testCreateGridWithoutId() $this->assertEquals($grid, $this->gridManager->createGrid()); - $this->assertAttributeEquals($grids, 'grids', $this->gridManager); + $this->assertEquals($grids, $this->gridManager->getIterator()); } public function testCreateGridWithId() @@ -73,7 +73,7 @@ public function testCreateGridWithId() $this->assertEquals($grid, $this->gridManager->createGrid($gridId)); - $this->assertAttributeEquals($grids, 'grids', $this->gridManager); + $this->assertEquals($grids, $this->gridManager->getIterator()); } public function testReturnsManagedGridCount() @@ -90,14 +90,6 @@ public function testReturnsManagedGridCount() $this->assertEquals(1, $this->gridManager->count()); } - public function testSetRouteUrl() - { - $routeUrl = 'aRouteUrl'; - $this->gridManager->setRouteUrl($routeUrl); - - $this->assertAttributeEquals($routeUrl, 'routeUrl', $this->gridManager); - } - public function testGetRouteUrl() { $routeUrl = 'aRouteUrl'; @@ -181,21 +173,6 @@ public function testItRewindGridListWhenCheckingTwoTimesIfReadyForRedirect() $this->gridManager->isReadyForRedirect(); } - public function testItTakesFirstGridUrlAsGlobalRouteUrl() - { - $grid1Hash = 'hashValue1'; - $route1Url = 'route1Url'; - - $grid2Hash = 'hashValue2'; - $route2Url = 'route2Url'; - - $this->stubTwoGridsForRedirect($grid1Hash, $route1Url, null, $grid2Hash, $route2Url, null); - - $this->gridManager->isReadyForRedirect(); - - $this->assertAttributeEquals($route1Url, 'routeUrl', $this->gridManager); - } - public function testItIgnoresEveryGridUrlIfRouteUrlAlreadySetted() { $grid1Hash = 'hashValue1'; @@ -211,7 +188,7 @@ public function testItIgnoresEveryGridUrlIfRouteUrlAlreadySetted() $this->gridManager->isReadyForRedirect(); - $this->assertAttributeEquals($settedRouteUrl, 'routeUrl', $this->gridManager); + $this->assertSame($settedRouteUrl, $this->gridManager->getRouteUrl()); } public function testItThrowsExceptionWhenCheckForExportAndGridsNotSetted() @@ -249,11 +226,9 @@ public function testAtLeastOneGridReadyForExport() $grid1Hash = 'hashValue1'; $grid2Hash = 'hashValue2'; - list($grid, $grid2) = $this->stubTwoGridsForExport($grid1Hash, false, $grid2Hash, true); + [$grid, $grid2] = $this->stubTwoGridsForExport($grid1Hash, false, $grid2Hash, true); $this->assertTrue($this->gridManager->isReadyForExport()); - - $this->assertAttributeEquals($grid2, 'exportGrid', $this->gridManager); } public function testItRewindGridListWhenCheckingTwoTimesIfReadyForExport() @@ -306,11 +281,9 @@ public function testAtLeastOneGridHasMassActionRedirect() $grid1Hash = 'hashValue1'; $grid2Hash = 'hashValue2'; - list($grid, $grid2) = $this->stubTwoGridForMassAction($grid1Hash, false, $grid2Hash, true); + [$grid, $grid2] = $this->stubTwoGridForMassAction($grid1Hash, false, $grid2Hash, true); $this->assertTrue($this->gridManager->isMassActionRedirect()); - - $this->assertAttributeEquals($grid2, 'massActionGrid', $this->gridManager); } public function testItRewindGridListWhenCheckingTwoTimesIfHasMassActionRedirect() @@ -366,7 +339,7 @@ public function testGridResponseExport() $grid1Hash = 'hashValue1'; $grid2Hash = 'hashValue2'; - list($grid, $grid2) = $this->stubTwoGridsForExport($grid1Hash, false, $grid2Hash, true); + [$grid, $grid2] = $this->stubTwoGridsForExport($grid1Hash, false, $grid2Hash, true); $response = new Response(); $grid2 @@ -381,7 +354,7 @@ public function testGridResponseMassActionRedirect() $grid1Hash = 'hashValue1'; $grid2Hash = 'hashValue2'; - list($grid, $grid2) = $this->stubTwoGridForMassAction($grid1Hash, false, $grid2Hash, true); + [$grid, $grid2] = $this->stubTwoGridForMassAction($grid1Hash, false, $grid2Hash, true); $response = new Response(); $grid2 @@ -396,7 +369,7 @@ public function testGetGridResponseWithoutParams() $grid1Hash = 'hashValue1'; $grid2Hash = 'hashValue2'; - list($grid, $grid2) = $this->stubTwoGrids($grid1Hash, $grid2Hash); + [$grid, $grid2] = $this->stubTwoGrids($grid1Hash, $grid2Hash); $this->assertEquals(['grid1' => $grid, 'grid2' => $grid2], $this->gridManager->getGridManagerResponse()); } @@ -406,7 +379,7 @@ public function testGetGridResponseWithoutView() $grid1Hash = 'hashValue1'; $grid2Hash = 'hashValue2'; - list($grid, $grid2) = $this->stubTwoGrids($grid1Hash, $grid2Hash); + [$grid, $grid2] = $this->stubTwoGrids($grid1Hash, $grid2Hash); $param1 = 'foo'; $param2 = 'bar'; @@ -490,7 +463,7 @@ private function stubTwoGridsForRedirect( $route2Url, $grid2ReadyForRedirect ) { - list($grid, $grid2) = $this->stubTwoGrids($grid1Hash, $grid2Hash); + [$grid, $grid2] = $this->stubTwoGrids($grid1Hash, $grid2Hash); $grid ->method('isReadyForRedirect') @@ -517,7 +490,7 @@ private function stubTwoGridsForRedirect( */ private function stubTwoGridsForExport($grid1Hash, $grid1ReadyForExport, $grid2Hash, $grid2ReadyForExport) { - list($grid, $grid2) = $this->stubTwoGrids($grid1Hash, $grid2Hash); + [$grid, $grid2] = $this->stubTwoGrids($grid1Hash, $grid2Hash); $grid ->method('isReadyForExport') @@ -540,7 +513,7 @@ private function stubTwoGridsForExport($grid1Hash, $grid1ReadyForExport, $grid2H */ private function stubTwoGridForMassAction($grid1Hash, $grid1IsMassActionRedirect, $grid2Hash, $grid2IsMassActionRedirect) { - list($grid, $grid2) = $this->stubTwoGrids($grid1Hash, $grid2Hash); + [$grid, $grid2] = $this->stubTwoGrids($grid1Hash, $grid2Hash); $grid ->method('isMassActionRedirect') diff --git a/tests/Grid/GridTest.php b/tests/Grid/GridTest.php index 57c02e98..a9ebaf13 100644 --- a/tests/Grid/GridTest.php +++ b/tests/Grid/GridTest.php @@ -99,14 +99,14 @@ public function testInitializeWithoutAnyConfiguration() $this->grid->initialize(); - $this->assertAttributeEquals(false, 'persistence', $this->grid); - $this->assertAttributeEmpty('routeParameters', $this->grid); - $this->assertAttributeEmpty('routeUrl', $this->grid); - $this->assertAttributeEmpty('source', $this->grid); - $this->assertAttributeEmpty('defaultOrder', $this->grid); - $this->assertAttributeEmpty('limits', $this->grid); - $this->assertAttributeEmpty('maxResults', $this->grid); - $this->assertAttributeEmpty('page', $this->grid); + $this->assertFalse($this->grid->getPersistence()); + $this->assertEmpty($this->grid->getRouteParameters()); + $this->assertEmpty($this->grid->getRouteUrl()); + $this->assertEmpty($this->grid->getSource()); + $this->assertEmpty($this->grid->getDefaultOrder()); + $this->assertEmpty($this->grid->getLimits()); + $this->assertEmpty($this->grid->getMaxResults()); + $this->assertEmpty($this->grid->getPage()); $this->router->expects($this->never())->method($this->anything()); $column->expects($this->never())->method($this->anything()); @@ -123,7 +123,7 @@ public function testInitializePersistence() $this->grid->initialize(); - $this->assertAttributeEquals(true, 'persistence', $this->grid); + $this->assertTrue($this->grid->getPersistence()); } public function testInitializeRouteParams() @@ -139,14 +139,14 @@ public function testInitializeRouteParams() $this->grid->initialize(); - $this->assertAttributeEquals($routeParams, 'routeParameters', $this->grid); + $this->assertSame($routeParams, $this->grid->getRouteParameters()); } public function testInitializeRouteUrlWithoutParams() { - $route = 'vendor.bundle.controller.route_name'; + $route = 'vendor.bundle.controller.route_name'; $routeParams = ['foo' => 1, 'bar' => 2]; - $url = 'aRandomUrl'; + $url = 'aRandomUrl'; $gridConfig = $this->createMock(GridConfigInterface::class); $gridConfig @@ -166,13 +166,13 @@ public function testInitializeRouteUrlWithoutParams() $this->grid->initialize(); - $this->assertAttributeEquals($url, 'routeUrl', $this->grid); + $this->assertSame($url, $this->grid->getRouteUrl()); } public function testInitializeRouteUrlWithParams() { $route = 'vendor.bundle.controller.route_name'; - $url = 'aRandomUrl'; + $url = 'aRandomUrl'; $gridConfig = $this->createMock(GridConfigInterface::class); $gridConfig @@ -188,7 +188,7 @@ public function testInitializeRouteUrlWithParams() $this->grid->initialize(); - $this->assertAttributeEquals($url, 'routeUrl', $this->grid); + $this->assertSame($url, $this->grid->getRouteUrl()); } public function testInizializeColumnsNotFilterableAsGridIsNotFilterable() @@ -330,7 +330,7 @@ public function testInitializeEntitySourceWithoutGroupByArrayValues() public function testInizializeDefaultOrder() { - $sortBy = 'SORTBY'; + $sortBy = 'SORTBY'; $orderBy = 'ORDERBY'; $gridConfig = $this->createMock(GridConfigInterface::class); @@ -345,7 +345,7 @@ public function testInizializeDefaultOrder() $this->grid->initialize(); - $this->assertAttributeEquals(sprintf('%s|%s', $sortBy, strtolower($orderBy)), 'defaultOrder', $this->grid); + $this->assertSame(sprintf('%s|%s', $sortBy, strtolower($orderBy)), $this->grid->getDefaultOrder()); } public function testInizializeDefaultOrderWithoutOrder() @@ -362,7 +362,7 @@ public function testInizializeDefaultOrderWithoutOrder() $this->grid->initialize(); // @todo: is this an admitted case? - $this->assertAttributeEquals("$sortBy|", 'defaultOrder', $this->grid); + $this->assertSame("$sortBy|", $this->grid->getDefaultOrder()); } public function testInizializeLimits() @@ -378,7 +378,7 @@ public function testInizializeLimits() $this->grid->initialize(); - $this->assertAttributeEquals([$maxPerPage => (string) $maxPerPage], 'limits', $this->grid); + $this->assertSame([$maxPerPage => (string)$maxPerPage], $this->grid->getLimits()); } public function testInizializeMaxResults() @@ -394,7 +394,7 @@ public function testInizializeMaxResults() $this->grid->initialize(); - $this->assertAttributeEquals($maxResults, 'maxResults', $this->grid); + $this->assertSame($maxResults, $this->grid->getMaxResults()); } public function testInizializePage() @@ -410,7 +410,7 @@ public function testInizializePage() $this->grid->initialize(); - $this->assertAttributeEquals($page, 'page', $this->grid); + $this->assertSame($page, $this->grid->getPage()); } public function testSetSourceOneThanOneTime() @@ -440,7 +440,7 @@ public function testSetSource() $this->grid->setSource($source); - $this->assertAttributeEquals($source, 'source', $this->grid); + $this->assertSame($source, $this->grid->getSource()); } public function testGetSource() @@ -464,8 +464,8 @@ public function testHandleRequestRaiseExceptionIfSourceNotSetted() $this->grid->handleRequest( $this->getMockBuilder(Request::class) - ->disableOriginalConstructor() - ->getMock() + ->disableOriginalConstructor() + ->getMock() ); } @@ -474,7 +474,7 @@ public function testAddColumnToLazyColumnsWithoutPosition() $column = $this->stubColumn(); $this->grid->addColumn($column); - $this->assertAttributeEquals([['column' => $column, 'position' => 0]], 'lazyAddColumn', $this->grid); + $this->assertSame([['column' => $column, 'position' => 0]], $this->grid->getLazyAddColumn()); } public function testAddColumnToLazyColumnsWithPosition() @@ -482,7 +482,7 @@ public function testAddColumnToLazyColumnsWithPosition() $column = $this->stubColumn(); $this->grid->addColumn($column, 1); - $this->assertAttributeEquals([['column' => $column, 'position' => 1]], 'lazyAddColumn', $this->grid); + $this->assertSame([['column' => $column, 'position' => 1]], $this->grid->getLazyAddColumn()); } public function testAddColumnsToLazyColumnsWithSamePosition() @@ -493,18 +493,19 @@ public function testAddColumnsToLazyColumnsWithSamePosition() $this->grid->addColumn($column1, 1); $this->grid->addColumn($column2, 1); - $this->assertAttributeEquals([ - ['column' => $column1, 'position' => 1], - ['column' => $column2, 'position' => 1], ], - 'lazyAddColumn', - $this->grid + $this->assertSame( + [ + ['column' => $column1, 'position' => 1], + ['column' => $column2, 'position' => 1], + ], + $this->grid->getLazyAddColumn() ); } public function testGetColumnFromLazyColumns() { $columnId = 'foo'; - $column = $this->stubColumn($columnId); + $column = $this->stubColumn($columnId); $this->grid->addColumn($column); @@ -514,7 +515,7 @@ public function testGetColumnFromLazyColumns() public function testGetColumnFromColumns() { $columnId = 'foo'; - $column = $this->stubColumn(); + $column = $this->stubColumn(); $columns = $this->createMock(Columns::class); $columns @@ -545,7 +546,7 @@ public function testGetColumns() public function testHasColumnInLazyColumns() { $columnId = 'foo'; - $column = $this->stubColumn($columnId); + $column = $this->stubColumn($columnId); $this->grid->addColumn($column); $this->assertTrue($this->grid->hasColumn($columnId)); @@ -571,7 +572,7 @@ public function testSetColumns() $columns = $this->createMock(Columns::class); $this->grid->setColumns($columns); - $this->assertAttributeEquals($columns, 'columns', $this->grid); + $this->assertSame($columns, $this->grid->getColumns()); } public function testColumnsReorderAndKeepOtherColumns() @@ -609,12 +610,12 @@ public function testAddMassActionWithoutRole() $massAction = $this->stubMassAction(); $this->grid->addMassAction($massAction); - $this->assertAttributeEquals([$massAction], 'massActions', $this->grid); + $this->assertSame([$massAction], $this->grid->getMassActions()); } public function testAddMassActionWithGrantForActionRole() { - $role = 'aRole'; + $role = 'aRole'; $massAction = $this->stubMassAction($role); $this @@ -625,12 +626,12 @@ public function testAddMassActionWithGrantForActionRole() $this->grid->addMassAction($massAction); - $this->assertAttributeEquals([$massAction], 'massActions', $this->grid); + $this->assertSame([$massAction], $this->grid->getMassActions()); } public function testAddMassActionWithoutGrantForActionRole() { - $role = 'aRole'; + $role = 'aRole'; $massAction = $this->stubMassAction($role); $this @@ -641,7 +642,7 @@ public function testAddMassActionWithoutGrantForActionRole() $this->grid->addMassAction($massAction); - $this->assertAttributeEmpty('massActions', $this->grid); + $this->assertEmpty($this->grid->getMassActions()); } public function testGetMassActions() @@ -666,14 +667,14 @@ public function testAddTweakWithId() { $title = 'aTweak'; $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; - $id = 'aValidTweakId'; + $id = 'aValidTweakId'; $group = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $id, $group); $result = [$id => array_merge(['title' => $title, 'id' => $id, 'group' => $group], $tweak)]; - $this->assertAttributeEquals($result, 'tweaks', $this->grid); + $this->assertSame($result, $this->grid->getTweaks()); } public function testAddTweakWithoutId() @@ -686,22 +687,22 @@ public function testAddTweakWithoutId() $result = [0 => array_merge(['title' => $title, 'id' => null, 'group' => $group], $tweak)]; - $this->assertAttributeEquals($result, 'tweaks', $this->grid); + $this->assertSame($result, $this->grid->getTweaks()); } public function testAddRowActionWithoutRole() { - $colId = 'aColId'; + $colId = 'aColId'; $rowAction = $this->stubRowAction(null, $colId); $this->grid->addRowAction($rowAction); - $this->assertAttributeEquals([$colId => [$rowAction]], 'rowActions', $this->grid); + $this->assertSame([$colId => [$rowAction]], $this->grid->getRowActions()); } public function testAddRowActionWithGrantForActionRole() { - $role = 'aRole'; - $colId = 'aColId'; + $role = 'aRole'; + $colId = 'aColId'; $rowAction = $this->stubRowAction($role, $colId); $this @@ -712,12 +713,12 @@ public function testAddRowActionWithGrantForActionRole() $this->grid->addRowAction($rowAction); - $this->assertAttributeEquals([$colId => [$rowAction]], 'rowActions', $this->grid); + $this->assertSame([$colId => [$rowAction]], $this->grid->getRowActions()); } public function testAddRowActionWithoutGrantForActionRole() { - $role = 'aRole'; + $role = 'aRole'; $rowAction = $this->stubRowAction($role); $this @@ -728,12 +729,12 @@ public function testAddRowActionWithoutGrantForActionRole() $this->grid->addRowAction($rowAction); - $this->assertAttributeEmpty('rowActions', $this->grid); + $this->assertEmpty($this->grid->getRowActions()); } public function testGetRowActions() { - $colId = 'aColId'; + $colId = 'aColId'; $rowAction = $this->stubRowAction(null, $colId); $this->grid->addRowAction($rowAction); @@ -841,7 +842,7 @@ public function testAddExportWithoutRole() $this->grid->addExport($export); - $this->assertAttributeEquals([$export], 'exports', $this->grid); + $this->assertSame([$export], $this->grid->getExports()); } public function testAddExportWithGrantForActionRole() @@ -861,7 +862,7 @@ public function testAddExportWithGrantForActionRole() $this->grid->addExport($export); - $this->assertAttributeEquals([$export], 'exports', $this->grid); + $this->assertSame([$export], $this->grid->getExports()); } public function testAddExportWithoutGrantForActionRole() @@ -881,7 +882,7 @@ public function testAddExportWithoutGrantForActionRole() $this->grid->addExport($export); - $this->assertAttributeEmpty('exports', $this->grid); + $this->assertEmpty($this->grid->getExports()); } public function testGetExports() @@ -898,28 +899,27 @@ public function testGetExports() public function testSetRouteParameter() { - $paramName = 'name'; + $paramName = 'name'; $paramValue = 'value'; - $otherParamName = 'name'; + $otherParamName = 'name'; $otherParamValue = 'value'; $this->grid->setRouteParameter($paramName, $paramValue); $this->grid->setRouteParameter($otherParamName, $otherParamValue); - $this->assertAttributeEquals( + $this->assertSame( [$paramName => $paramValue, $otherParamName => $otherParamValue], - 'routeParameters', - $this->grid + $this->grid->getRouteParameters() ); } public function testGetRouteParameters() { - $paramName = 'name'; + $paramName = 'name'; $paramValue = 'value'; - $otherParamName = 'name'; + $otherParamName = 'name'; $otherParamValue = 'value'; $this->grid->setRouteParameter($paramName, $paramValue); @@ -937,7 +937,7 @@ public function testSetRouteUrl() $this->grid->setRouteUrl($url); - $this->assertAttributeEquals($url, 'routeUrl', $this->grid); + $this->assertSame($url, $this->grid->getRouteUrl()); } public function testGetRouteUrl() @@ -968,14 +968,6 @@ public function testGetRouteUrlFromRequest() $this->assertEquals($url, $this->grid->getRouteUrl()); } - public function testSetId() - { - $id = 'id'; - $this->grid->setId($id); - - $this->assertAttributeEquals($id, 'id', $this->grid); - } - public function testGetId() { $id = 'id'; @@ -984,13 +976,6 @@ public function testGetId() $this->assertEquals($id, $this->grid->getId()); } - public function testSetPersistence() - { - $this->grid->setPersistence(true); - - $this->assertAttributeEquals(true, 'persistence', $this->grid); - } - public function testGetPersistence() { $this->grid->setPersistence(true); @@ -998,13 +983,6 @@ public function testGetPersistence() $this->assertTrue($this->grid->getPersistence()); } - public function testSetDataJunction() - { - $this->grid->setDataJunction(Column::DATA_DISJUNCTION); - - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $this->grid); - } - public function testGetDataJunction() { $this->grid->setDataJunction(Column::DATA_DISJUNCTION); @@ -1025,7 +1003,7 @@ public function testSetIntLimit() $limit = 10; $this->grid->setLimits($limit); - $this->assertAttributeEquals([$limit => (string) $limit], 'limits', $this->grid); + $this->assertSame([$limit => (string)$limit], $this->grid->getLimits()); } public function testSetArrayLimits() @@ -1033,7 +1011,7 @@ public function testSetArrayLimits() $limits = [10, 50, 100]; $this->grid->setLimits($limits); - $this->assertAttributeEquals(array_combine($limits, $limits), 'limits', $this->grid); + $this->assertSame(array_combine($limits, $limits), $this->grid->getLimits()); } public function testSetAssociativeArrayLimits() @@ -1041,7 +1019,7 @@ public function testSetAssociativeArrayLimits() $limits = [10 => '10', 50 => '50', 100 => '100']; $this->grid->setLimits($limits); - $this->assertAttributeEquals(array_combine($limits, $limits), 'limits', $this->grid); + $this->assertSame(array_combine($limits, $limits), $this->grid->getLimits()); } public function testGetLimits() @@ -1057,7 +1035,7 @@ public function testSetDefaultPage() $page = 1; $this->grid->setDefaultPage($page); - $this->assertAttributeEquals($page - 1, 'page', $this->grid); + $this->assertSame($page - 1, $this->grid->getPage()); } public function testSetDefaultTweak() @@ -1065,7 +1043,7 @@ public function testSetDefaultTweak() $tweakId = 1; $this->grid->setDefaultTweak($tweakId); - $this->assertAttributeEquals($tweakId, 'defaultTweak', $this->grid); + $this->assertEquals($tweakId, $this->grid->getDefaultTweak()); } public function testSetPageWithInvalidValueRaiseException() @@ -1082,15 +1060,7 @@ public function testSetPageWithZeroValue() $page = 0; $this->grid->setPage($page); - $this->assertAttributeEquals($page, 'page', $this->grid); - } - - public function testSetPage() - { - $page = 10; - $this->grid->setPage($page); - - $this->assertAttributeEquals($page, 'page', $this->grid); + $this->assertSame($page, $this->grid->getPage()); } public function testGetPage() @@ -1104,7 +1074,7 @@ public function testGetPage() public function testSetMaxResultWithNullValue() { $this->grid->setMaxResults(); - $this->assertAttributeEquals(null, 'maxResults', $this->grid); + $this->assertNull($this->grid->getMaxResults()); } public function testSetMaxResultWithInvalidValueRaiseException() @@ -1121,7 +1091,7 @@ public function testSetMaxResultWithStringValue() $maxResult = 'foo'; $this->grid->setMaxResults($maxResult); - $this->assertAttributeEquals($maxResult, 'maxResults', $this->grid); + $this->assertSame($maxResult, $this->grid->getMaxResults()); } public function testSetMaxResult() @@ -1129,7 +1099,7 @@ public function testSetMaxResult() $maxResult = 1; $this->grid->setMaxResults($maxResult); - $this->assertAttributeEquals($maxResult, 'maxResults', $this->grid); + $this->assertSame($maxResult, $this->grid->getMaxResults()); } public function testIsNotFilteredIfNoColumnIsFiltered() @@ -1264,14 +1234,14 @@ public function testHideFilters() { $this->grid->hideFilters(); - $this->assertAttributeEquals(false, 'showFilters', $this->grid); + $this->assertFalse($this->grid->getShowFilters()); } public function testHideTitles() { $this->grid->hideTitles(); - $this->assertAttributeEquals(false, 'showTitles', $this->grid); + $this->assertFalse($this->grid->getShowTitles()); } public function testAddsColumnExtension() @@ -1292,14 +1262,6 @@ public function testAddsColumnExtension() $this->grid->addColumnExtension($extension); } - public function testSetPrefixTitle() - { - $prefixTitle = 'prefixTitle'; - $this->grid->setPrefixTitle($prefixTitle); - - $this->assertAttributeEquals($prefixTitle, 'prefixTitle', $this->grid); - } - public function testGetPrefixTitle() { $prefixTitle = 'prefixTitle'; @@ -1308,14 +1270,6 @@ public function testGetPrefixTitle() $this->assertEquals($prefixTitle, $this->grid->getPrefixTitle()); } - public function testSetNoDataMessage() - { - $message = 'foo'; - $this->grid->setNoDataMessage($message); - - $this->assertAttributeEquals($message, 'noDataMessage', $this->grid); - } - public function testGetNoDataMessage() { $message = 'foo'; @@ -1324,14 +1278,6 @@ public function testGetNoDataMessage() $this->assertEquals($message, $this->grid->getNoDataMessage()); } - public function testSetNoResultMessage() - { - $message = 'foo'; - $this->grid->setNoResultMessage($message); - - $this->assertAttributeEquals($message, 'noResultMessage', $this->grid); - } - public function testGetNoResultMessage() { $message = 'foo'; @@ -1345,7 +1291,7 @@ public function testSetHiddenColumnsWithIntegerId() $id = 1; $this->grid->setHiddenColumns($id); - $this->assertAttributeEquals([$id], 'lazyHiddenColumns', $this->grid); + $this->assertSame([$id], $this->grid->getHiddenColumns()); } public function testSetHiddenColumnWithArrayOfIds() @@ -1353,7 +1299,7 @@ public function testSetHiddenColumnWithArrayOfIds() $ids = [1, 2, 3]; $this->grid->setHiddenColumns($ids); - $this->assertAttributeEquals($ids, 'lazyHiddenColumns', $this->grid); + $this->assertSame($ids, $this->grid->getHiddenColumns()); } public function testSetVisibleColumnsWithIntegerId() @@ -1361,7 +1307,7 @@ public function testSetVisibleColumnsWithIntegerId() $id = 1; $this->grid->setVisibleColumns($id); - $this->assertAttributeEquals([$id], 'lazyVisibleColumns', $this->grid); + $this->assertSame([$id], $this->grid->getVisibleColumns()); } public function testSetVisibleColumnWithArrayOfIds() @@ -1369,7 +1315,7 @@ public function testSetVisibleColumnWithArrayOfIds() $ids = [1, 2, 3]; $this->grid->setVisibleColumns($ids); - $this->assertAttributeEquals($ids, 'lazyVisibleColumns', $this->grid); + $this->assertSame($ids, $this->grid->getVisibleColumns()); } public function testShowColumnsWithIntegerId() @@ -1377,7 +1323,7 @@ public function testShowColumnsWithIntegerId() $id = 1; $this->grid->showColumns($id); - $this->assertAttributeEquals([$id => true], 'lazyHideShowColumns', $this->grid); + $this->assertSame([$id => true], $this->grid->getLazyHideShowColumns()); } public function testShowColumnsArrayOfIds() @@ -1385,7 +1331,7 @@ public function testShowColumnsArrayOfIds() $ids = [1, 2, 3]; $this->grid->showColumns($ids); - $this->assertAttributeEquals([1 => true, 2 => true, 3 => true], 'lazyHideShowColumns', $this->grid); + $this->assertSame([1 => true, 2 => true, 3 => true], $this->grid->getLazyHideShowColumns()); } public function testHideColumnsWithIntegerId() @@ -1393,7 +1339,7 @@ public function testHideColumnsWithIntegerId() $id = 1; $this->grid->hideColumns($id); - $this->assertAttributeEquals([$id => false], 'lazyHideShowColumns', $this->grid); + $this->assertSame([$id => false], $this->grid->getLazyHideShowColumns()); } public function testHideColumnsArrayOfIds() @@ -1401,7 +1347,7 @@ public function testHideColumnsArrayOfIds() $ids = [1, 2, 3]; $this->grid->hideColumns($ids); - $this->assertAttributeEquals([1 => false, 2 => false, 3 => false], 'lazyHideShowColumns', $this->grid); + $this->assertSame([1 => false, 2 => false, 3 => false], $this->grid->getLazyHideShowColumns()); } public function testSetActionsColumnSize() @@ -1409,7 +1355,7 @@ public function testSetActionsColumnSize() $size = 2; $this->grid->setActionsColumnSize($size); - $this->assertAttributeEquals($size, 'actionsColumnSize', $this->grid); + $this->assertSame($size, $this->grid->getActionsColumnSize()); } public function testSetActionsColumnTitle() @@ -1417,7 +1363,7 @@ public function testSetActionsColumnTitle() $title = 'aTitle'; $this->grid->setActionsColumnTitle($title); - $this->assertAttributeEquals($title, 'actionsColumnTitle', $this->grid); + $this->assertSame($title, $this->grid->getActionsColumnTitle()); } public function testClone() @@ -1483,7 +1429,7 @@ public function testCreateHashWithMd5DuringHandleRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals('grid_' . md5($controller . $columns->getHash() . $sourceHash), 'hash', $this->grid); + $this->assertSame('grid_' . md5($controller . $columns->getHash() . $sourceHash), $this->grid->getHash()); } public function testResetGridSessionWhenChangeGridDuringHandleRequest() @@ -1568,7 +1514,7 @@ public function testStartNewSessionDuringHandleRequestOnFirstGridRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals(true, 'newSession', $this->grid); + $this->assertTrue(true, $this->grid->getNewSession()); } public function testStartKeepSessionDuringHandleRequestNotOnFirstGridRequest() @@ -1584,7 +1530,7 @@ public function testStartKeepSessionDuringHandleRequestNotOnFirstGridRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals(false, 'newSession', $this->grid); + $this->assertFalse($this->grid->getNewSession()); } public function testMassActionRedirect() @@ -1636,7 +1582,7 @@ public function testResetPageAndLimitIfMassActionHandleAllDataDuringHandleReques $this->grid->handleRequest($this->request); - $this->assertAttributeEquals(0, 'limit', $this->grid); + $this->assertEquals(0, $this->grid->getLimit()); } public function testMassActionResponseFromCallbackDuringHandleRequest() @@ -1678,10 +1624,10 @@ public function testProcessExportsDuringHandleRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals(0, 'page', $this->grid); - $this->assertAttributeEquals(0, 'limit', $this->grid); - $this->assertAttributeEquals(true, 'isReadyForExport', $this->grid); - $this->assertAttributeEquals($response, 'exportResponse', $this->grid); + $this->assertEquals(0, $this->grid->getPage()); + $this->assertEquals(0, $this->grid->getLimit()); + $this->assertTrue($this->grid->isReadyForExport()); + $this->assertEquals($response, $this->grid->getExportResponse()); } public function testProcessExportsButNotFiltersPageOrderLimitDuringHandleRequest() @@ -1742,8 +1688,8 @@ public function testProcessPageWithSelectFilterColumnNotSelectMultiDuringHandleR public function testProcessOrderDescDuringHandleRequest() { - $colId = 'colId'; - $order = 'desc'; + $colId = 'colId'; + $order = 'desc'; $queryOrder = "$colId|$order"; $column = $this->mockOrderRequestData($colId, $order); @@ -1764,8 +1710,8 @@ public function testProcessOrderDescDuringHandleRequest() public function testProcessOrderAscDuringHandleRequest() { - $colId = 'colId'; - $order = 'asc'; + $colId = 'colId'; + $order = 'asc'; $queryOrder = "$colId|$order"; $column = $this->mockOrderRequestData($colId, $order); @@ -1812,7 +1758,7 @@ public function testColumnsNotOrderedDuringHandleRequestIfNoOrderRequested() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals(0, 'page', $this->grid); + $this->assertSame(0, $this->grid->getPage()); } public function testProcessConfiguredLimitDuringHandleRequest() @@ -1828,7 +1774,7 @@ public function testProcessNonConfiguredLimitDuringHandleRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEmpty('limit', $this->grid); + $this->assertEmpty($this->grid->getLimit()); } public function testSetDefaultSessionFiltersDuringHandleRequest() @@ -1868,7 +1814,7 @@ public function testSetDefaultOrderRaiseExceptionIfOrderNotAscNeitherDescDuringH $source = $this->createMock(Source::class); $this->grid->setSource($source); - $colId = 'col'; + $colId = 'col'; $column = $this->stubColumn($colId); $this->grid->addColumn($column); @@ -1908,7 +1854,7 @@ public function testSetDefaultOrderDescDuringHandleRequest() $column = $this->arrangeGridPrimaryColumn(); $columnId = 'columnId'; - $order = 'desc'; + $order = 'desc'; $column ->method('getId') ->willReturn($columnId); @@ -1969,8 +1915,8 @@ public function testProcessDefaultTweaksDuringHandleRequest() $this->arrangeGridSourceDataLoadedWithEmptyRows(); $this->arrangeGridPrimaryColumn(); - $title = 'aTweak'; - $tweak = ['reset' => 1]; + $title = 'aTweak'; + $tweak = ['reset' => 1]; $tweakId = 'aValidTweakId'; $this->grid->addTweak($title, $tweak, $tweakId); @@ -1992,29 +1938,29 @@ public function testSetPermanentSessionFiltersDuringHandleRequest() $column = $this->arrangeGridPrimaryColumn(); - $col1Id = 'col1'; + $col1Id = 'col1'; $col1FilterValue = 'val1'; - $column1 = $this->stubColumn($col1Id); + $column1 = $this->stubColumn($col1Id); $this->grid->addColumn($column1); - $col2Id = 'col2'; + $col2Id = 'col2'; $col2FilterValue = ['val2']; - $column2 = $this->stubColumn($col2Id); + $column2 = $this->stubColumn($col2Id); $this->grid->addColumn($column2); - $col3Id = 'col3'; + $col3Id = 'col3'; $col3FilterValue = ['from' => true]; - $column3 = $this->stubColumn($col3Id); + $column3 = $this->stubColumn($col3Id); $this->grid->addColumn($column3); - $col4Id = 'col4'; + $col4Id = 'col4'; $col4FilterValue = ['from' => false]; - $column4 = $this->stubColumn($col4Id); + $column4 = $this->stubColumn($col4Id); $this->grid->addColumn($column4); - $col5Id = 'col5'; + $col5Id = 'col5'; $col5FilterValue = ['from' => 'foo', 'to' => 'bar']; - $column5 = $this + $column5 = $this ->getMockBuilder(Column::class) ->disableOriginalConstructor() ->getMock(); @@ -2028,12 +1974,12 @@ public function testSetPermanentSessionFiltersDuringHandleRequest() $this->grid->addColumn($column5); $this->grid->setPermanentFilters([ - $col1Id => $col1FilterValue, - $col2Id => $col2FilterValue, - $col3Id => $col3FilterValue, - $col4Id => $col4FilterValue, - $col5Id => $col5FilterValue, - ]); + $col1Id => $col1FilterValue, + $col2Id => $col2FilterValue, + $col3Id => $col3FilterValue, + $col4Id => $col4FilterValue, + $col5Id => $col5FilterValue, + ]); $column ->expects($this->never()) @@ -2077,11 +2023,11 @@ public function testSetPermanentSessionFiltersDuringHandleRequest() public function testPrepareRowsFromDataIfDataAlreadyLoadedDuringHandleRequest() { - $source = $this->arrangeGridSourceDataLoadedWithoutRowsReturned(); + $source = $this->arrangeGridSourceDataLoadedWithoutRowsReturned(); $columns = $this->arrangeGridWithColumnsIterator(); $maxResults = 5; - $limit = 10; + $limit = 10; $this->stubRequestWithData([Grid::REQUEST_QUERY_LIMIT => $limit]); $this->grid->setLimits($limit); @@ -2104,11 +2050,11 @@ public function testPrepareRowsFromDataIfDataAlreadyLoadedDuringHandleRequest() public function testPrepareRowsFromExecutionIfDataNotLoadedDuringHandleRequest() { - $source = $this->arrangeGridSourceDataNotLoadedWithoutRowsReturned(); + $source = $this->arrangeGridSourceDataNotLoadedWithoutRowsReturned(); $columns = $this->arrangeGridWithColumnsIterator(); $maxResults = 5; - $limit = 10; + $limit = 10; $this->stubRequestWithData([Grid::REQUEST_QUERY_LIMIT => $limit]); $this->grid->setLimits($limit); @@ -2152,7 +2098,7 @@ public function testRaiseExceptionIfNotRowInstanceReturnedFromSurceIfDataNotLoad public function testSetFirstPageIfNoRowsFromSourceIfDataAlreadyDataAndRequestedPageNotFirst() { - $source = $this->arrangeGridSourceDataLoadedWithoutRowsReturned(); + $source = $this->arrangeGridSourceDataLoadedWithoutRowsReturned(); $columns = $this->arrangeGridWithColumnsIterator(); $page = 2; @@ -2179,7 +2125,7 @@ public function testSetFirstPageIfNoRowsFromSourceIfDataAlreadyDataAndRequestedP public function testSetFirstPageIfNoRowsFromSourceIfDataNotLoadedAndRequestedPageNotFirst() { - $source = $this->arrangeGridSourceDataNotLoadedWithoutRowsReturned(); + $source = $this->arrangeGridSourceDataNotLoadedWithoutRowsReturned(); $columns = $this->arrangeGridWithColumnsIterator(); $page = 2; @@ -2209,7 +2155,7 @@ public function testAddRowActionsToAllColumnsDuringHandleRequest() $this->arrangeGridSourceDataLoadedWithEmptyRows(); $actionsColumnId1 = 'actionsColumnId'; - $actionsColumn1 = $this + $actionsColumn1 = $this ->getMockBuilder(ActionsColumn::class) ->disableOriginalConstructor() ->getMock(); @@ -2228,7 +2174,7 @@ public function testAddRowActionsToAllColumnsDuringHandleRequest() $this->grid->addRowAction($rowAction2); $actionsColumnId2 = 'actionsColumnId2'; - $actionsColumn2 = $this + $actionsColumn2 = $this ->getMockBuilder(ActionsColumn::class) ->disableOriginalConstructor() ->getMock(); @@ -2322,7 +2268,7 @@ public function testAddMassActionColumnsDuringHandleRequest() public function testSetPrimaryFieldOnEachRow() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $row2 = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -2379,7 +2325,7 @@ public function testSetTotalCountFromDataDuringHandleRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals($totalCount, 'totalCount', $this->grid); + $this->assertSame($totalCount, $this->grid->getTotalCount()); } public function testSetTotalCountDuringHandleRequest() @@ -2390,7 +2336,7 @@ public function testSetTotalCountDuringHandleRequest() $this->grid->handleRequest($this->request); - $this->assertAttributeEquals($totalCount, 'totalCount', $this->grid); + $this->assertSame($totalCount, $this->grid->getTotalCount()); } public function testThrowsExceptionIfTotalCountNotIntegerFromDataDuringHandleRequest() @@ -2422,7 +2368,7 @@ public function testRaiseExceptionIfTweakDoesNotExistsDuringHandleRequest() $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage(sprintf(Grid::TWEAK_NOT_DEFINED_EX_MSG, $tweakId)); - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -2536,18 +2482,18 @@ public function testGetTweaksWithUrlWithoutGetParameters() { $routeUrl = 'http://www.foo.com'; - $title = 'aTweak'; - $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; - $id = 'aValidTweakId'; - $group = 'tweakGroup'; + $title = 'aTweak'; + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; + $id = 'aValidTweakId'; + $group = 'tweakGroup'; $tweakUrl = sprintf('%s?[%s]=%s', $routeUrl, Grid::REQUEST_QUERY_TWEAK, $id); $this->grid->addTweak($title, $tweak, $id, $group); - $title2 = 'aTweak'; - $tweak2 = ['filters' => [], 'order' => 'columnId2', 'page' => 2, 'limit' => 100, 'export' => 0, 'massAction' => 0]; - $id2 = 'aValidTweakId2'; - $group2 = 'tweakGroup2'; + $title2 = 'aTweak'; + $tweak2 = ['filters' => [], 'order' => 'columnId2', 'page' => 2, 'limit' => 100, 'export' => 0, 'massAction' => 0]; + $id2 = 'aValidTweakId2'; + $group2 = 'tweakGroup2'; $tweakUrl2 = sprintf('%s?[%s]=%s', $routeUrl, Grid::REQUEST_QUERY_TWEAK, $id2); $this->grid->setRouteUrl($routeUrl); @@ -2566,18 +2512,18 @@ public function testGetTweaksWithUrlWithGetParameters() { $routeUrl = 'http://www.foo.com?foo=foo'; - $title = 'aTweak'; - $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; - $id = 'aValidTweakId'; - $group = 'tweakGroup'; + $title = 'aTweak'; + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; + $id = 'aValidTweakId'; + $group = 'tweakGroup'; $tweakUrl = sprintf('%s&[%s]=%s', $routeUrl, Grid::REQUEST_QUERY_TWEAK, $id); $this->grid->addTweak($title, $tweak, $id, $group); - $title2 = 'aTweak'; - $tweak2 = ['filters' => [], 'order' => 'columnId2', 'page' => 2, 'limit' => 100, 'export' => 0, 'massAction' => 0]; - $id2 = 'aValidTweakId2'; - $group2 = 'tweakGroup2'; + $title2 = 'aTweak'; + $tweak2 = ['filters' => [], 'order' => 'columnId2', 'page' => 2, 'limit' => 100, 'export' => 0, 'massAction' => 0]; + $id2 = 'aValidTweakId2'; + $group2 = 'tweakGroup2'; $tweakUrl2 = sprintf('%s&[%s]=%s', $routeUrl, Grid::REQUEST_QUERY_TWEAK, $id2); $this->grid->setRouteUrl($routeUrl); @@ -2600,7 +2546,7 @@ public function testRaiseExceptionIfGetNonExistentTweak() $this->expectExceptionMessage(sprintf(Grid::NOT_VALID_TWEAK_ID_EX_MSG, $nonExistentTweak)); $tweakId = 'aValidTweakId'; - $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; $routeUrl = 'https://www.foo.com'; $this->grid->setRouteUrl($routeUrl); @@ -2613,13 +2559,13 @@ public function testRaiseExceptionIfGetNonExistentTweak() public function testGetTweak() { $title = 'aTweak'; - $id = 'aValidTweakId'; + $id = 'aValidTweakId'; $group = 'tweakGroup'; $routeUrl = 'http://www.foo.com'; $this->grid->setRouteUrl($routeUrl); - $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; $tweakUrl = $routeUrl . sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); $this->grid->addTweak($title, $tweak, $id, $group); @@ -2632,14 +2578,14 @@ public function testGetTweak() public function testGetTweaksByGroupExcludingThoseWhoDoNotHaveTheGroup() { $title = 'aTweak'; - $id = 'aValidTweakId'; + $id = 'aValidTweakId'; $group = 'tweakGroup'; $routeUrl = 'http://www.foo.com'; $this->grid->setRouteUrl($routeUrl); - $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; - $tweakUrl = $routeUrl . sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); + $tweak = ['filters' => [], 'order' => 'columnId', 'page' => 1, 'limit' => 50, 'export' => 1, 'massAction' => 1]; + $tweakUrl = $routeUrl . sprintf('?[%s]=%s', Grid::REQUEST_QUERY_TWEAK, $id); $tweakResult = [$id => array_merge(['title' => $title, 'id' => $id, 'group' => $group, 'url' => $tweakUrl], $tweak)]; $this->grid->addTweak($title, $tweak, $id, $group); @@ -2653,7 +2599,7 @@ public function testGetTweaksByGroupExcludingThoseWhoDoNotHaveTheGroup() public function testGetActiveTweaks() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -2661,7 +2607,7 @@ public function testGetActiveTweaks() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $colFilter = ['from' => 'foo', 'to' => 'bar']; $column ->method('getId') @@ -2670,9 +2616,9 @@ public function testGetActiveTweaks() ->method('getFilterType') ->willReturn('select'); - $title = 'aTweak'; - $tweak = ['filters' => [$colId => $colFilter]]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['filters' => [$colId => $colFilter]]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -2686,7 +2632,7 @@ public function testGetActiveTweaks() public function testGetActiveTweakGroup() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -2694,7 +2640,7 @@ public function testGetActiveTweakGroup() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $colFilter = ['from' => 'foo', 'to' => 'bar']; $column ->method('getId') @@ -2703,9 +2649,9 @@ public function testGetActiveTweakGroup() ->method('getFilterType') ->willReturn('select'); - $title = 'aTweak'; - $tweak = ['filters' => [$colId => $colFilter]]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['filters' => [$colId => $colFilter]]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -2775,7 +2721,7 @@ public function testSetPermanentFilters() $this->grid->setPermanentFilters($filters); - $this->assertAttributeEquals($filters, 'permanentFilters', $this->grid); + $this->assertSame($filters, $this->grid->getPermanentFilters()); } public function testSetDefaultFilters() @@ -2787,7 +2733,7 @@ public function testSetDefaultFilters() $this->grid->setDefaultFilters($filters); - $this->assertAttributeEquals($filters, 'defaultFilters', $this->grid); + $this->assertSame($filters, $this->grid->getDefaultFilters()); } public function testSetDefaultOrder() @@ -2797,12 +2743,12 @@ public function testSetDefaultOrder() $this->grid->setDefaultOrder($colId, $order); - $this->assertAttributeEquals(sprintf("$colId|%s", strtolower($order)), 'defaultOrder', $this->grid); + $this->assertSame(sprintf("$colId|%s", strtolower($order)), $this->grid->getDefaultOrder()); } public function testGetRows() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -2892,12 +2838,12 @@ public function testGetRawDataWithAllColumnsIfNoColumnsRequested() $this->arrangeGridSourceDataLoadedWithRows($rows); $column1 = $this->arrangeGridPrimaryColumn(); - $col1Id = 'col1Id'; + $col1Id = 'col1Id'; $column1 ->method('getId') ->willReturn($col1Id); - $col2Id = 'col2Id'; + $col2Id = 'col2Id'; $column2 = $this->stubColumn($col2Id); $this->grid->addColumn($column2); @@ -2949,12 +2895,12 @@ public function testGetRawDataWithSubsetOfColumns() $this->arrangeGridSourceDataLoadedWithRows($rows); $column1 = $this->arrangeGridPrimaryColumn(); - $col1Id = 'col1Id'; + $col1Id = 'col1Id'; $column1 ->method('getId') ->willReturn($col1Id); - $col2Id = 'col2Id'; + $col2Id = 'col2Id'; $column2 = $this->stubColumn($col2Id); $this->grid->addColumn($column2); @@ -3006,13 +2952,13 @@ public function testGetRawDataWithoutNamedIndexesResult() $this->arrangeGridSourceDataLoadedWithRows($rows); $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $column ->method('getId') ->willReturn($colId); $rowColField = 'rowColField'; - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $row ->method('getField') ->with($colId) @@ -3021,7 +2967,7 @@ public function testGetRawDataWithoutNamedIndexesResult() $rows->addRow($row); $row2ColField = 'row2ColField'; - $row2 = $this->createMock(Row::class); + $row2 = $this->createMock(Row::class); $row2 ->method('getField') ->with($colId) @@ -3053,39 +2999,39 @@ public function testGetFilters() $this->arrangeGridSourceDataLoadedWithEmptyRows(); $this->arrangeGridPrimaryColumn(); - $col1Id = 'col1Id'; + $col1Id = 'col1Id'; $column1 = $this->stubColumn($col1Id); $this->grid->addColumn($column1); - $col2Id = 'col2Id'; + $col2Id = 'col2Id'; $column2 = $this->stubColumnWithDefaultOperator(Column::OPERATOR_GT, $col2Id); $this->grid->addColumn($column2); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED => true, - Grid::REQUEST_QUERY_MASS_ACTION => true, - Grid::REQUEST_QUERY_EXPORT => false, - Grid::REQUEST_QUERY_PAGE => 1, - Grid::REQUEST_QUERY_LIMIT => 10, - Grid::REQUEST_QUERY_ORDER => null, - Grid::REQUEST_QUERY_TEMPLATE => 'aTemplate', - Grid::REQUEST_QUERY_RESET => false, - MassActionColumn::ID => 'massActionColId', - ]); + Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED => true, + Grid::REQUEST_QUERY_MASS_ACTION => true, + Grid::REQUEST_QUERY_EXPORT => false, + Grid::REQUEST_QUERY_PAGE => 1, + Grid::REQUEST_QUERY_LIMIT => 10, + Grid::REQUEST_QUERY_ORDER => null, + Grid::REQUEST_QUERY_TEMPLATE => 'aTemplate', + Grid::REQUEST_QUERY_RESET => false, + MassActionColumn::ID => 'massActionColId', + ]); $filter1Operator = Column::OPERATOR_BTW; - $filter1From = 'from1'; - $filter1To = 'to1'; - $filter1 = new Filter($filter1Operator, ['from' => $filter1From, 'to' => $filter1To]); + $filter1From = 'from1'; + $filter1To = 'to1'; + $filter1 = new Filter($filter1Operator, ['from' => $filter1From, 'to' => $filter1To]); $filter2Operator = Column::OPERATOR_GT; - $filter2From = 'from2'; - $filter2 = new Filter($filter2Operator, $filter2From); + $filter2From = 'from2'; + $filter2 = new Filter($filter2Operator, $filter2From); $this->grid->setDefaultFilters([ - $col1Id => ['operator' => $filter1Operator, 'from' => $filter1From, 'to' => $filter1To], - $col2Id => ['from' => $filter2From], - ]); + $col1Id => ['operator' => $filter1Operator, 'from' => $filter1From, 'to' => $filter1To], + $col2Id => ['from' => $filter2From], + ]); $this ->session @@ -3093,10 +3039,13 @@ public function testGetFilters() ->method('set') ->withConsecutive( [$this->gridHash, [Grid::REQUEST_QUERY_PAGE => 0]], - [$this->gridHash, [ - Grid::REQUEST_QUERY_PAGE => 0, - $col1Id => ['operator' => $filter1Operator, 'from' => $filter1From, 'to' => $filter1To], - $col2Id => ['from' => $filter2From], ], + [ + $this->gridHash, + [ + Grid::REQUEST_QUERY_PAGE => 0, + $col1Id => ['operator' => $filter1Operator, 'from' => $filter1From, 'to' => $filter1To], + $col2Id => ['from' => $filter2From], + ], ] ); @@ -3131,18 +3080,18 @@ public function testGetFilter() $this->arrangeGridSourceDataLoadedWithEmptyRows(); $this->arrangeGridPrimaryColumn(); - $colId = 'col1Id'; + $colId = 'col1Id'; $column = $this->stubColumn($colId); $this->grid->addColumn($column); $filterOperator = Column::OPERATOR_BTW; - $filterFrom = 'from1'; - $filterTo = 'to1'; - $filter = new Filter($filterOperator, ['from' => $filterFrom, 'to' => $filterTo]); + $filterFrom = 'from1'; + $filterTo = 'to1'; + $filter = new Filter($filterOperator, ['from' => $filterFrom, 'to' => $filterTo]); $this->grid->setDefaultFilters([ - $colId => ['operator' => $filterOperator, 'from' => $filterFrom, 'to' => $filterTo], - ]); + $colId => ['operator' => $filterOperator, 'from' => $filterFrom, 'to' => $filterTo], + ]); $this->grid->handleRequest($this->request); @@ -3172,17 +3121,17 @@ public function testHasFilter() $this->arrangeGridSourceDataLoadedWithEmptyRows(); $this->arrangeGridPrimaryColumn(); - $colId = 'col1Id'; + $colId = 'col1Id'; $column = $this->stubColumn($colId); $this->grid->addColumn($column); $filterOperator = Column::OPERATOR_BTW; - $filterFrom = 'from1'; - $filterTo = 'to1'; + $filterFrom = 'from1'; + $filterTo = 'to1'; $this->grid->setDefaultFilters([ - $colId => ['operator' => $filterOperator, 'from' => $filterFrom, 'to' => $filterTo], - ]); + $colId => ['operator' => $filterOperator, 'from' => $filterFrom, 'to' => $filterTo], + ]); $this->grid->handleRequest($this->request); @@ -3232,7 +3181,7 @@ public function testCreateHashWithMd5DuringRedirect() $this->grid->isReadyForRedirect(); - $this->assertAttributeEquals('grid_' . md5($controller . $columns->getHash() . $sourceHash), 'hash', $this->grid); + $this->assertSame('grid_' . md5($controller . $columns->getHash() . $sourceHash), $this->grid->getHash()); } public function testResetGridSessionWhenResetFiltersIsPressedDuringRedirect() @@ -3296,7 +3245,7 @@ public function testStartNewSessionDuringRedirectOnFirstRequest() $this->grid->isReadyForRedirect(); - $this->assertAttributeEquals(true, 'newSession', $this->grid); + $this->assertTrue($this->grid->getNewSession()); } public function testStartKeepSessionDuringRedirectNotOnFirstRequest() @@ -3312,7 +3261,7 @@ public function testStartKeepSessionDuringRedirectNotOnFirstRequest() $this->grid->isReadyForRedirect(); - $this->assertAttributeEquals(false, 'newSession', $this->grid); + $this->assertFalse($this->grid->getNewSession()); } public function testProcessHiddenColumnsDuringRedirect() @@ -3376,7 +3325,7 @@ public function testResetPageAndLimitIfMassActionHandleAllDataDuringRedirect() $this->assertTrue($this->grid->isReadyForRedirect()); - $this->assertAttributeEquals(0, 'limit', $this->grid); + $this->assertEquals(0, $this->grid->getLimit()); } public function testMassActionResponseFromCallbackDuringRedirect() @@ -3418,10 +3367,10 @@ public function testProcessExportsDuringRedirect() $this->assertTrue($this->grid->isReadyForRedirect()); - $this->assertAttributeEquals(0, 'page', $this->grid); - $this->assertAttributeEquals(0, 'limit', $this->grid); - $this->assertAttributeEquals(true, 'isReadyForExport', $this->grid); - $this->assertAttributeEquals($response, 'exportResponse', $this->grid); + $this->assertSame(0, $this->grid->getPage()); + $this->assertSame(0, $this->grid->getLimit()); + $this->assertTrue($this->grid->isReadyForExport()); + $this->assertSame($response, $this->grid->getExportResponse()); } public function testProcessExportsButNotFiltersPageOrderLimitDuringRedirect() @@ -3438,7 +3387,7 @@ public function testRaiseExceptionIfTweakDoesNotExistsDuringRedirect() $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage(sprintf(Grid::TWEAK_NOT_DEFINED_EX_MSG, $tweakId)); - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -3578,8 +3527,8 @@ public function testProcessPageWithSelectFilterColumnNotSelectMultiDuringRedirec public function testProcessOrderDescDuringRedirect() { - $colId = 'colId'; - $order = 'desc'; + $colId = 'colId'; + $order = 'desc'; $queryOrder = "$colId|$order"; $column = $this->mockOrderRequestData($colId, $order); @@ -3600,8 +3549,8 @@ public function testProcessOrderDescDuringRedirect() public function testProcessOrderAscDuringRedirect() { - $colId = 'colId'; - $order = 'asc'; + $colId = 'colId'; + $order = 'asc'; $queryOrder = "$colId|$order"; $column = $this->mockOrderRequestData($colId, $order); @@ -3648,7 +3597,7 @@ public function testColumnsNotOrderedIfNoOrderRequestedDuringRedirect() $this->assertFalse($this->grid->isReadyForRedirect()); - $this->assertAttributeEquals(0, 'page', $this->grid); + $this->assertSame(0, $this->grid->getPage()); } public function testProcessConfiguredLimitDuringRedirect() @@ -3664,7 +3613,7 @@ public function testProcessNonConfiguredLimitDuringRedirect() $this->assertTrue($this->grid->isReadyForRedirect()); - $this->assertAttributeEmpty('limit', $this->grid); + $this->assertEmpty($this->grid->getLimit()); } public function testSetDefaultSessionFiltersIfNotRequestDataDuringRedirect() @@ -3690,7 +3639,7 @@ public function testSetDefaultSessionFiltersIfSessionDataXmlHttpRequestAndNotExp $col2FilterValue = ['val2']; $col5From = 'foo'; - $col5To = 'bar'; + $col5To = 'bar'; [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, @@ -3745,14 +3694,18 @@ public function testSetDefaultSessionFiltersIfSessionDataXmlHttpRequestAndNotExp ->method('set') ->withConsecutive( [$this->gridHash, [Grid::REQUEST_QUERY_PAGE => $page]], - [$this->gridHash, [ - $col1Id => ['from' => $col1FilterValue], - $col2Id => ['from' => $col2FilterValue], - $col3Id => ['from' => 1], - $col4Id => ['from' => 0], - $col5Id => ['from' => [$col5From], 'to' => [$col5To]], - Grid::REQUEST_QUERY_PAGE => $page, ], - ]); + [ + $this->gridHash, + [ + $col1Id => ['from' => $col1FilterValue], + $col2Id => ['from' => $col2FilterValue], + $col3Id => ['from' => 1], + $col4Id => ['from' => 0], + $col5Id => ['from' => [$col5From], 'to' => [$col5To]], + Grid::REQUEST_QUERY_PAGE => $page, + ], + ] + ); $this->assertFalse($this->grid->isReadyForRedirect()); } @@ -3773,7 +3726,7 @@ public function testNotSetDefaultSessionFiltersIfHasRequestDataNotXmlHttpButExpo $col2FilterValue = ['val2']; $col5From = 'foo'; - $col5To = 'bar'; + $col5To = 'bar'; [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, @@ -3843,7 +3796,7 @@ public function testNotSetDefaultSessionFiltersIfHasRequestDataNotXmlHttpAndNotE $col2FilterValue = ['val2']; $col5From = 'foo'; - $col5To = 'bar'; + $col5To = 'bar'; [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, @@ -3919,7 +3872,7 @@ public function testSetDefaultPageIfNotRequestDataDuringRedirect() public function testSetDefaultPageIfRequestDataXmlHttpRequestAndNotExportDuringRedirect() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -3949,7 +3902,7 @@ public function testSetDefaultPageIfRequestDataXmlHttpRequestAndNotExportDuringR public function testNotSetDefaultPageIfHasRequestDataNotXmlHttpButExportDuringRedirect() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -3975,7 +3928,7 @@ public function testNotSetDefaultPageIfHasRequestDataNotXmlHttpButExportDuringRe public function testNotSetDefaultPageIfHasRequestDataNotXmlHttpAndNotExportDuringRedirect() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -4009,7 +3962,7 @@ public function testSetDefaultOrderRaiseExceptionIfOrderNotAscNeitherDescDuringR $source = $this->createMock(Source::class); $this->grid->setSource($source); - $colId = 'col'; + $colId = 'col'; $column = $this->stubColumn($colId); $this->grid->addColumn($column); @@ -4017,6 +3970,7 @@ public function testSetDefaultOrderRaiseExceptionIfOrderNotAscNeitherDescDuringR $this->grid->isReadyForRedirect(); } + public function testSetDefaultOrderRaiseExceptionIfColumnDoesNotExistsDuringRedirect() { $colId = 'col'; @@ -4055,7 +4009,7 @@ public function testSetDefaultOrderIfRequestDataXmlHttpRequestAndNotExportDuring $column = $this->arrangeGridPrimaryColumn(); $columnId = 'columnId'; - $order = 'desc'; + $order = 'desc'; $column ->method('getId') ->willReturn($columnId); @@ -4096,7 +4050,7 @@ public function testNotSetDefaultOrderIfHasRequestDataNotXmlHttpButExportDuringR $column = $this->arrangeGridPrimaryColumn(); $columnId = 'columnId'; - $order = 'desc'; + $order = 'desc'; $column ->method('getId') ->willReturn($columnId); @@ -4130,7 +4084,7 @@ public function testNotSetDefaultOrderIfHasRequestDataNotXmlHttpAndNotExportDuri $column = $this->arrangeGridPrimaryColumn(); $columnId = 'columnId'; - $order = 'desc'; + $order = 'desc'; $column ->method('getId') ->willReturn($columnId); @@ -4440,13 +4394,13 @@ public function testGetGridWithViewWithViewAndParams() } /** - * @param $gridConfigInterface + * @param $gridConfigInterface * @param string $id * @param \PHPUnit\Framework\MockObject\MockObject $httpKernel */ private function arrange($gridConfigInterface = null, $id = 'id', $httpKernel = null) { - $session = $this + $session = $this ->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); @@ -4463,7 +4417,7 @@ private function arrange($gridConfigInterface = null, $id = 'id', $httpKernel = ->getMockBuilder(HeaderBag::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $request; + $this->request = $request; $request->attributes = new ParameterBag([]); @@ -4478,10 +4432,10 @@ private function arrange($gridConfigInterface = null, $id = 'id', $httpKernel = ->disableOriginalConstructor() ->getMock(); - $authChecker = $this->createMock(AuthorizationCheckerInterface::class); + $authChecker = $this->createMock(AuthorizationCheckerInterface::class); $this->authChecker = $authChecker; - $environment = $this->createMock(Environment::class); + $environment = $this->createMock(Environment::class); $this->environment = $environment; $containerGetMap = [ @@ -4501,7 +4455,7 @@ private function arrange($gridConfigInterface = null, $id = 'id', $httpKernel = ->will($this->returnValueMap($containerGetMap)); $this->container = $container; - $this->gridId = $id; + $this->gridId = $id; $this->gridHash = 'grid_' . $this->gridId; $this->grid = new Grid($container, $this->gridId, $gridConfigInterface); @@ -4536,9 +4490,9 @@ private function mockResetGridSessionWhenResetFilterIsPressed() private function mockNotResetGridSessionWhenSameGridReferer() { - $scheme = 'http'; - $host = 'www.foo.com/'; - $basUrl = 'baseurl'; + $scheme = 'http'; + $host = 'www.foo.com/'; + $basUrl = 'baseurl'; $pathInfo = '/info'; $this->arrangeGridSourceDataLoadedWithEmptyRows(); @@ -4591,7 +4545,7 @@ private function mockHiddenColumns() ->willReturn($column1Id); $column2Id = 'col2Id'; - $column2 = $this->stubColumn($column2Id); + $column2 = $this->stubColumn($column2Id); $this->grid->addColumn($column2); $this->grid->setHiddenColumns([$column1Id, $column2Id]); @@ -4619,11 +4573,11 @@ private function mockVisibleColumns() ->willReturn($column1Id); $column2Id = 'col2Id'; - $column2 = $this->stubColumn($column2Id); + $column2 = $this->stubColumn($column2Id); $this->grid->addColumn($column2); $column3Id = 'col3Id'; - $column3 = $this->stubColumn($column3Id); + $column3 = $this->stubColumn($column3Id); $this->grid->addColumn($column3); $this->grid->setVisibleColumns([$column1Id]); @@ -4651,15 +4605,15 @@ private function mockColumnVisibility() ->willReturn($column1Id); $column2Id = 'col2Id'; - $column2 = $this->stubColumn($column2Id); + $column2 = $this->stubColumn($column2Id); $this->grid->addColumn($column2); $column3Id = 'col3Id'; - $column3 = $this->stubColumn($column3Id); + $column3 = $this->stubColumn($column3Id); $this->grid->addColumn($column3); $column4Id = 'col4Id'; - $column4 = $this->stubColumn($column4Id); + $column4 = $this->stubColumn($column4Id); $this->grid->addColumn($column4); $this->grid->showColumns([$column1Id, $column2Id]); @@ -4692,9 +4646,9 @@ private function mockResetPageAndLimitIfMassActionAndAllKeys() $this->arrangeGridPrimaryColumn(); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_MASS_ACTION => 0, - Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED => true, - ]); + Grid::REQUEST_QUERY_MASS_ACTION => 0, + Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED => true, + ]); $massAction = $this->stubMassActionWithCallback(function () { }); @@ -4768,14 +4722,14 @@ private function mockMassActionControllerResponse() $rows = new Rows(); $rowPrimaryFieldValue = 'pfv1'; - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $row ->method('getPrimaryFieldValue') ->willReturn($rowPrimaryFieldValue); $rows->addRow($row); $rowPrimaryFieldValue2 = 'pfv2'; - $row2 = $this->createMock(Row::class); + $row2 = $this->createMock(Row::class); $row2 ->method('getPrimaryFieldValue') ->willReturn($rowPrimaryFieldValue2); @@ -4785,26 +4739,27 @@ private function mockMassActionControllerResponse() $this->arrangeGridPrimaryColumn(); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_MASS_ACTION => 0, - Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED => true, - ]); + Grid::REQUEST_QUERY_MASS_ACTION => 0, + Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED => true, + ]); $controllerCb = 'VendorBundle:Controller:Action'; - $param1 = 'param1'; - $param1Val = 1; - $param2 = 'param2'; - $param2Val = 2; - $massAction = $this->stubMassActionWithCallback($controllerCb, [$param1 => $param1Val, $param2 => $param2Val]); + $param1 = 'param1'; + $param1Val = 1; + $param2 = 'param2'; + $param2Val = 2; + $massAction = $this->stubMassActionWithCallback($controllerCb, [$param1 => $param1Val, $param2 => $param2Val]); $this ->request ->method('duplicate') ->with([], null, [ - 'primaryKeys' => [$rowPrimaryFieldValue, $rowPrimaryFieldValue2], - 'allPrimaryKeys' => true, - '_controller' => $controllerCb, - $param1 => $param1Val, - $param2 => $param2Val, ] + 'primaryKeys' => [$rowPrimaryFieldValue, $rowPrimaryFieldValue2], + 'allPrimaryKeys' => true, + '_controller' => $controllerCb, + $param1 => $param1Val, + $param2 => $param2Val, + ] ) ->willReturn($subRequest); @@ -4859,7 +4814,7 @@ private function mockExportsButNotFiltersPageOrderLimit() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $colData = 'colData'; $column ->method('getId') @@ -4873,11 +4828,11 @@ private function mockExportsButNotFiltersPageOrderLimit() $limit = 10; $this->stubRequestWithData([ - Grid::REQUEST_QUERY_EXPORT => 0, - Grid::REQUEST_QUERY_ORDER => "$colId|ASC", - Grid::REQUEST_QUERY_LIMIT => $limit, - $colId => $colData, - ]); + Grid::REQUEST_QUERY_EXPORT => 0, + Grid::REQUEST_QUERY_ORDER => "$colId|ASC", + Grid::REQUEST_QUERY_LIMIT => $limit, + $colId => $colData, + ]); $response = $this ->getMockBuilder(Response::class) @@ -4910,15 +4865,15 @@ private function mockExportsButNotFiltersPageOrderLimit() private function mockTweakReset() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); $this->arrangeGridSourceDataLoadedWithRows($rows); $this->arrangeGridPrimaryColumn(); - $title = 'aTweak'; - $tweak = ['reset' => 1]; + $title = 'aTweak'; + $tweak = ['reset' => 1]; $tweakId = 'aValidTweakId'; $this->grid->addTweak($title, $tweak, $tweakId); @@ -4934,7 +4889,7 @@ private function mockTweakReset() private function mockTweakFilters() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -4942,7 +4897,7 @@ private function mockTweakFilters() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $colFilter = ['from' => 'foo', 'to' => 'bar']; $column ->method('getId') @@ -4951,9 +4906,9 @@ private function mockTweakFilters() ->method('getFilterType') ->willReturn('select'); - $title = 'aTweak'; - $tweak = ['filters' => [$colId => $colFilter]]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['filters' => [$colId => $colFilter]]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -4969,7 +4924,7 @@ private function mockTweakFilters() private function mockTweakOrder() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -4986,9 +4941,9 @@ private function mockTweakOrder() ->method('isSortable') ->willReturn(true); - $title = 'aTweak'; - $tweak = ['order' => "$colId|$order"]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['order' => "$colId|$order"]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -5004,16 +4959,16 @@ private function mockTweakOrder() private function mockTweakMassAction() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); $this->arrangeGridSourceDataLoadedWithRows($rows); $this->arrangeGridPrimaryColumn(); - $title = 'aTweak'; - $tweak = ['massAction' => -1]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['massAction' => -1]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -5028,7 +4983,7 @@ private function mockTweakMassAction() private function mockTweakPage() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5039,10 +4994,10 @@ private function mockTweakPage() ->method('isSortable') ->willReturn(true); - $title = 'aTweak'; - $page = 10; - $tweak = ['page' => $page]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $page = 10; + $tweak = ['page' => $page]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -5058,7 +5013,7 @@ private function mockTweakPage() private function mockTweakLimit() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5069,10 +5024,10 @@ private function mockTweakLimit() ->method('isSortable') ->willReturn(true); - $title = 'aTweak'; - $limit = 10; - $tweak = ['limit' => $limit]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $limit = 10; + $tweak = ['limit' => $limit]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -5090,16 +5045,16 @@ private function mockTweakLimit() private function mockTweakExport() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); $this->arrangeGridSourceDataLoadedWithRows($rows); $this->arrangeGridPrimaryColumn(); - $title = 'aTweak'; - $tweak = ['export' => -1]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['export' => -1]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -5114,7 +5069,7 @@ private function mockTweakExport() private function mockTweakExportButNotFiltersPageOrderLimit() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5122,7 +5077,7 @@ private function mockTweakExportButNotFiltersPageOrderLimit() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $colData = 'colData'; $column ->method('getId') @@ -5134,19 +5089,19 @@ private function mockTweakExportButNotFiltersPageOrderLimit() ->method('isSortable') ->willReturn(true); - $title = 'aTweak'; - $tweak = ['export' => -1]; - $tweakId = 'aValidTweakId'; + $title = 'aTweak'; + $tweak = ['export' => -1]; + $tweakId = 'aValidTweakId'; $tweakGroup = 'tweakGroup'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_TWEAK => $tweakId, - Grid::REQUEST_QUERY_ORDER => "$colId|ASC", - Grid::REQUEST_QUERY_LIMIT => 10, - $colId => $colData, - ]); + Grid::REQUEST_QUERY_TWEAK => $tweakId, + Grid::REQUEST_QUERY_ORDER => "$colId|ASC", + Grid::REQUEST_QUERY_LIMIT => 10, + $colId => $colData, + ]); $this ->session @@ -5156,7 +5111,7 @@ private function mockTweakExportButNotFiltersPageOrderLimit() private function mockRemoveActiveTweakGroups() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5164,8 +5119,8 @@ private function mockRemoveActiveTweakGroups() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; - $order = 'ASC'; + $colId = 'colId'; + $order = 'ASC'; $colFilter = ['from' => 'foo', 'to' => 'bar']; $column ->method('getId') @@ -5174,18 +5129,18 @@ private function mockRemoveActiveTweakGroups() ->method('getFilterType') ->willReturn('select'); - $title = 'aTweak'; + $title = 'aTweak'; $tweakGroup = 'tweakGroup'; - $page = 10; - $limit = 15; - $tweak = [ + $page = 10; + $limit = 15; + $tweak = [ 'filters' => [$colId => $colFilter], 'order' => "$colId|$order", 'removeActiveTweaksGroups' => $tweakGroup, 'page' => $page, 'limit' => $limit, ]; - $tweakId = 'aValidTweakId'; + $tweakId = 'aValidTweakId'; $this->grid->addTweak($title, $tweak, $tweakId, $tweakGroup); @@ -5207,7 +5162,7 @@ private function mockRemoveActiveTweakGroups() private function mockRemoveActiveTweak() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5215,8 +5170,8 @@ private function mockRemoveActiveTweak() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; - $order = 'ASC'; + $colId = 'colId'; + $order = 'ASC'; $colFilter = ['from' => 'foo', 'to' => 'bar']; $column ->method('getId') @@ -5225,12 +5180,12 @@ private function mockRemoveActiveTweak() ->method('getFilterType') ->willReturn('select'); - $title = 'aTweak'; + $title = 'aTweak'; $tweakGroup = 'tweakGroup'; - $tweakId = 'aValidTweakId'; - $page = 10; - $limit = 15; - $tweak = [ + $tweakId = 'aValidTweakId'; + $page = 10; + $limit = 15; + $tweak = [ 'filters' => [$colId => $colFilter], 'order' => "$colId|$order", 'removeActiveTweaks' => $tweakId, @@ -5258,7 +5213,7 @@ private function mockRemoveActiveTweak() private function mockAddActiveTweak() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5266,8 +5221,8 @@ private function mockAddActiveTweak() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; - $order = 'ASC'; + $colId = 'colId'; + $order = 'ASC'; $colFilter = ['from' => 'foo', 'to' => 'bar']; $column ->method('getId') @@ -5276,12 +5231,12 @@ private function mockAddActiveTweak() ->method('getFilterType') ->willReturn('select'); - $title = 'aTweak'; + $title = 'aTweak'; $tweakGroup = 'tweakGroup'; - $tweakId = 'aValidTweakId'; - $page = 10; - $limit = 15; - $tweak = [ + $tweakId = 'aValidTweakId'; + $page = 10; + $limit = 15; + $tweak = [ 'filters' => [$colId => $colFilter], 'order' => "$colId|$order", 'addActiveTweaks' => $tweakId, @@ -5309,7 +5264,7 @@ private function mockAddActiveTweak() private function mockPageRequestData() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5340,9 +5295,9 @@ private function mockPageQueryOrderRequestData() $this->grid->setColumns($columns); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_ORDER => 'order|foo', - Grid::REQUEST_QUERY_PAGE => 2, - ]); + Grid::REQUEST_QUERY_ORDER => 'order|foo', + Grid::REQUEST_QUERY_PAGE => 2, + ]); $column ->expects($this->never()) @@ -5361,9 +5316,9 @@ private function mockPageLimitRequestData() $this->arrangeGridPrimaryColumn(); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_LIMIT => 50, - Grid::REQUEST_QUERY_PAGE => 2, - ]); + Grid::REQUEST_QUERY_LIMIT => 50, + Grid::REQUEST_QUERY_PAGE => 2, + ]); $this ->session @@ -5382,9 +5337,9 @@ private function mockPageMassActionRequestData() $this->grid->addMassAction($massAction); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_MASS_ACTION => 0, - Grid::REQUEST_QUERY_PAGE => 2, - ]); + Grid::REQUEST_QUERY_MASS_ACTION => 0, + Grid::REQUEST_QUERY_PAGE => 2, + ]); $this ->session @@ -5395,7 +5350,7 @@ private function mockPageMassActionRequestData() private function mockPageFiltersRequestData() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5403,7 +5358,7 @@ private function mockPageFiltersRequestData() $column = $this->arrangeGridPrimaryColumn(); - $colId = 'colId'; + $colId = 'colId'; $colData = 'colData'; $column ->method('getId') @@ -5413,9 +5368,9 @@ private function mockPageFiltersRequestData() ->willReturn(true); $this->stubRequestWithData([ - Grid::REQUEST_QUERY_PAGE => 2, - $colId => $colData, - ]); + Grid::REQUEST_QUERY_PAGE => 2, + $colId => $colData, + ]); $this ->session @@ -5426,7 +5381,7 @@ private function mockPageFiltersRequestData() private function mockPageNotSelectFilterRequestData() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5457,7 +5412,7 @@ private function mockPageNotSelectFilterRequestData() private function mockPageColumnNotSelectMultiRequestData() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5550,7 +5505,7 @@ private function mockOrderColumnNotSortable() private function mockConfiguredLimitRequestData() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -5599,7 +5554,7 @@ private function mockDefaultSessionFiltersWithoutRequestData() $col2FilterValue = ['val2']; $col5From = 'foo'; - $col5To = 'bar'; + $col5To = 'bar'; [$column1, $column2, $column3, $column4, $column5] = $this->arrangeColumnsFilters( $col1Id, @@ -5682,15 +5637,15 @@ private function arrangeColumnsFilters( $this->grid->addColumn($column2); $col3FilterValue = ['from' => true]; - $column3 = $this->stubColumn($col3Id); + $column3 = $this->stubColumn($col3Id); $this->grid->addColumn($column3); $col4FilterValue = ['from' => false]; - $column4 = $this->stubColumn($col4Id); + $column4 = $this->stubColumn($col4Id); $this->grid->addColumn($column4); $col5FilterValue = ['from' => $col5From, 'to' => $col5To]; - $column5 = $this + $column5 = $this ->getMockBuilder(Column::class) ->disableOriginalConstructor() ->getMock(); @@ -5704,19 +5659,19 @@ private function arrangeColumnsFilters( $this->grid->addColumn($column5); $this->grid->setDefaultFilters([ - $col1Id => $col1FilterValue, - $col2Id => $col2FilterValue, - $col3Id => $col3FilterValue, - $col4Id => $col4FilterValue, - $col5Id => $col5FilterValue, - ]); + $col1Id => $col1FilterValue, + $col2Id => $col2FilterValue, + $col3Id => $col3FilterValue, + $col4Id => $col4FilterValue, + $col5Id => $col5FilterValue, + ]); return [$column1, $column2, $column3, $column4, $column5]; } private function mockDefaultPage() { - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $rows = new Rows(); $rows->addRow($row); @@ -6102,9 +6057,9 @@ private function stubRequestWithData(array $requestData) */ private function arrangeDefaultTweaks($tweakPage) { - $group = 'aGroup'; - $title = 'aTweak'; - $tweak = ['page' => $tweakPage, 'group' => $group]; + $group = 'aGroup'; + $title = 'aTweak'; + $tweak = ['page' => $tweakPage, 'group' => $group]; $tweakId = 'aValidTweakId'; $this->grid->addTweak($title, $tweak, $tweakId); From e2c5ec5fa72f0762f44f5bf3bb57c2ca31e62dc4 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:13:28 -0500 Subject: [PATCH 22/41] Format --- src/Grid/Action/RowAction.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Grid/Action/RowAction.php b/src/Grid/Action/RowAction.php index cae723e7..011d9857 100644 --- a/src/Grid/Action/RowAction.php +++ b/src/Grid/Action/RowAction.php @@ -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. * @@ -99,6 +100,7 @@ public function getTitle() } // @todo: has this setter real sense? we passed this value from constructor + /** * Set action route. * @@ -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)) { @@ -242,7 +244,7 @@ public function addRouteParameters($routeParameters) */ public function setRouteParameters($routeParameters) { - $this->routeParameters = (array) $routeParameters; + $this->routeParameters = (array)$routeParameters; return $this; } @@ -256,6 +258,7 @@ public function getRouteParameters() } // @todo: why is this accepting string? it seems pretty useless, isn't it? + /** * Set route parameters mapping. * @@ -265,7 +268,7 @@ public function getRouteParameters() */ public function setRouteParametersMapping($routeParametersMapping) { - $this->routeParametersMapping = (array) $routeParametersMapping; + $this->routeParametersMapping = (array)$routeParametersMapping; return $this; } @@ -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) { @@ -371,7 +374,8 @@ public function addManipulateRender($callback) return $this; } - public function getCallbacks(): array { + public function getCallbacks(): array + { return $this->callbacks; } @@ -396,6 +400,7 @@ public function render($row) } // @todo: should not this be "isEnabled"? + /** * {@inheritdoc} */ @@ -405,6 +410,7 @@ public function getEnabled() } // @todo: should not this be "enable" as default value is false? + /** * Set the enabled state of this action. * From 74026f39d7cf36c9b8fc842feeabecefd669449c Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:37:06 -0500 Subject: [PATCH 23/41] WIP: Address more deprecation warnings --- src/Grid/Mapping/Metadata/Metadata.php | 4 + src/Grid/Row.php | 9 +- src/Grid/Source/Vector.php | 22 +++- tests/Grid/Column/ActionsColumnTest.php | 52 +++++---- tests/Grid/Column/ArrayColumnTest.php | 33 +++--- tests/Grid/Column/BlankColumnTest.php | 17 +-- tests/Grid/Column/BooleanColumnTest.php | 101 +++++++++++------ tests/Grid/Column/DateColumnTest.php | 24 ++-- tests/Grid/Mapping/ColumnTest.php | 10 +- tests/Grid/Mapping/Metadata/ManagerTest.php | 20 ++-- tests/Grid/Mapping/Metadata/MetadataTest.php | 64 +++-------- tests/Grid/Mapping/SourceTest.php | 66 ++--------- tests/Grid/RowTest.php | 44 ++------ tests/Grid/Source/VectorTest.php | 110 +++++++++---------- 14 files changed, 267 insertions(+), 309 deletions(-) diff --git a/src/Grid/Mapping/Metadata/Metadata.php b/src/Grid/Mapping/Metadata/Metadata.php index aaa34315..84824342 100644 --- a/src/Grid/Mapping/Metadata/Metadata.php +++ b/src/Grid/Mapping/Metadata/Metadata.php @@ -46,6 +46,10 @@ public function getFieldMapping($field) return $this->fieldsMappings[$field]; } + public function getFieldsMappings(): array { + return $this->fieldsMappings; + } + public function getFieldMappingType($field) { return (isset($this->fieldsMappings[$field]['type'])) ? $this->fieldsMappings[$field]['type'] : 'text'; diff --git a/src/Grid/Row.php b/src/Grid/Row.php index f4cc4550..aba6056a 100644 --- a/src/Grid/Row.php +++ b/src/Grid/Row.php @@ -40,7 +40,7 @@ class Row public function __construct() { $this->fields = []; - $this->color = ''; + $this->color = ''; } /** @@ -77,9 +77,9 @@ public function getPrimaryKeyValue() } /** + * @return array|mixed * @throws \InvalidArgumentException * - * @return array|mixed */ public function getPrimaryFieldValue() { @@ -141,6 +141,11 @@ public function getField($columnId) return isset($this->fields[$columnId]) ? $this->fields[$columnId] : ''; } + public function getFields(): array + { + return $this->fields; + } + /** * @param string $class * diff --git a/src/Grid/Source/Vector.php b/src/Grid/Source/Vector.php index 8a06bdd4..a72f322e 100644 --- a/src/Grid/Source/Vector.php +++ b/src/Grid/Source/Vector.php @@ -74,11 +74,11 @@ public function initialise($container) protected function guessColumns() { $guessedColumns = []; - $dataColumnIds = array_keys(reset($this->data)); + $dataColumnIds = array_keys(reset($this->data)); foreach ($dataColumnIds as $id) { if (!$this->hasColumn($id)) { - $params = [ + $params = [ 'id' => $id, 'title' => $id, 'source' => true, @@ -101,7 +101,7 @@ protected function guessColumns() continue; } - $i = 0; + $i = 0; $fieldTypes = []; foreach ($this->data as $row) { @@ -223,7 +223,14 @@ public function getTotalCount($maxResults = null) public function getHash() { - return __CLASS__ . md5(implode('', array_map(function ($c) { return $c->getId(); }, $this->columns))); + return __CLASS__ . md5( + implode( + '', + array_map(function ($c) { + return $c->getId(); + }, $this->columns) + ) + ); } /** @@ -262,7 +269,7 @@ public function setData($data) // This seems to exclude ... if (is_object(reset($this->data))) { foreach ($this->data as $key => $object) { - $this->data[$key] = (array) $object; + $this->data[$key] = (array)$object; } } @@ -292,4 +299,9 @@ protected function hasColumn($id) return false; } + + public function getColumnsArray(): array + { + return $this->columns; + } } diff --git a/tests/Grid/Column/ActionsColumnTest.php b/tests/Grid/Column/ActionsColumnTest.php index 5ec0097a..968bc133 100644 --- a/tests/Grid/Column/ActionsColumnTest.php +++ b/tests/Grid/Column/ActionsColumnTest.php @@ -16,8 +16,8 @@ class ActionsColumnTest extends TestCase public function setUp(): void { - $rowAction1 = $this->createMock(RowAction::class); - $rowAction2 = $this->createMock(RowAction::class); + $rowAction1 = $this->createMock(RowAction::class); + $rowAction2 = $this->createMock(RowAction::class); $this->column = new ActionsColumn('columnId', 'columnTitle', [ $rowAction1, $rowAction2, @@ -26,19 +26,19 @@ public function setUp(): void public function testConstructor() { - $columnId = 'columnId'; + $columnId = 'columnId'; $columnTitle = 'columnTitle'; $rowAction1 = $this->createMock(RowAction::class); $rowAction2 = $this->createMock(RowAction::class); - $column = new ActionsColumn($columnId, $columnTitle, [$rowAction1, $rowAction2]); - - $this->assertAttributeEquals([$rowAction1, $rowAction2], 'rowActions', $column); - $this->assertAttributeEquals($columnId, 'id', $column); - $this->assertAttributeEquals($columnTitle, 'title', $column); - $this->assertAttributeEquals(false, 'sortable', $column); - $this->assertAttributeEquals(false, 'visibleForSource', $column); - $this->assertAttributeEquals(true, 'filterable', $column); + $column = new ActionsColumn($columnId, $columnTitle, [$rowAction1, $rowAction2]); + + $this->assertSame([$rowAction1, $rowAction2], $column->getRowActions()); + $this->assertSame($columnId, $column->getId()); + $this->assertSame($columnTitle, $column->getTitle()); + $this->assertFalse($column->isSortable()); + $this->assertFalse($column->isVisibleForSource()); + $this->assertTrue($column->isFilterable()); } public function testGetType() @@ -72,7 +72,7 @@ public function testGetRowActions() { $rowAction1 = $this->createMock(RowAction::class); $rowAction2 = $this->createMock(RowAction::class); - $column = new ActionsColumn('columnId', 'columnTitle', [ + $column = new ActionsColumn('columnId', 'columnTitle', [ $rowAction1, $rowAction2, ]); @@ -84,10 +84,10 @@ public function testSetRowActions() { $rowAction1 = $this->createMock(RowAction::class); $rowAction2 = $this->createMock(RowAction::class); - $column = new ActionsColumn('columnId', 'columnTitle', []); + $column = new ActionsColumn('columnId', 'columnTitle', []); $column->setRowActions([$rowAction1, $rowAction2]); - $this->assertAttributeEquals([$rowAction1, $rowAction2], 'rowActions', $column); + $this->assertSame([$rowAction1, $rowAction2], $column->getRowActions()); } public function testIsNotVisibleIfExported() @@ -158,17 +158,21 @@ public function testGetRouteParameters() ->willReturnOnConsecutiveCalls(null, 'aName'); $rowAction->method('getRouteParameters')->willReturn([ - 'foo' => 1, - 'foo.bar.foobar' => 2, - 1 => 'foo.bar', - '2' => 'barFoo', - ]); + 'foo' => 1, + 'foo.bar.foobar' => 2, + 1 => 'foo.bar', + '2' => 'barFoo', + ]); $this->assertEquals([ - 'foo' => 1, - 'fooBarFoobar' => 2, - 'fooBar' => 'testValue', - 'aName' => 'aValue', - ], $this->column->getRouteParameters($row, $rowAction)); + 'foo' => 1, + 'fooBarFoobar' => 2, + 'fooBar' => 'testValue', + 'aName' => 'aValue', + ], + $this->column->getRouteParameters( + $row, + $rowAction + )); } } diff --git a/tests/Grid/Column/ArrayColumnTest.php b/tests/Grid/Column/ArrayColumnTest.php index 88b1ae2e..c2519d42 100644 --- a/tests/Grid/Column/ArrayColumnTest.php +++ b/tests/Grid/Column/ArrayColumnTest.php @@ -26,14 +26,17 @@ public function testGetType() public function testInitializeDefaultParams() { - $this->assertAttributeEquals([ - Column::OPERATOR_LIKE, - Column::OPERATOR_NLIKE, - Column::OPERATOR_EQ, - Column::OPERATOR_NEQ, - Column::OPERATOR_ISNULL, - Column::OPERATOR_ISNOTNULL, - ], 'operators', $this->column); + $this->assertSame( + [ + Column::OPERATOR_LIKE, + Column::OPERATOR_NLIKE, + Column::OPERATOR_EQ, + Column::OPERATOR_NEQ, + Column::OPERATOR_ISNULL, + Column::OPERATOR_ISNOTNULL, + ], + $this->column->getOperators() + ); } public function testDocumentFilters() @@ -101,10 +104,10 @@ public function testIsNullFilter() $this->column->setData(['operator' => Column::OPERATOR_ISNULL]); $this->assertEquals([ - new Filter(Column::OPERATOR_ISNULL), - new Filter(Column::OPERATOR_EQ, 'a:0:{}'), - ], $this->column->getFilters('asource')); - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $this->column); + new Filter(Column::OPERATOR_ISNULL), + new Filter(Column::OPERATOR_EQ, 'a:0:{}'), + ], $this->column->getFilters('asource')); + $this->assertSame(Column::DATA_DISJUNCTION, $this->column->getDataJunction()); } public function testIsNotNullFilter() @@ -112,9 +115,9 @@ public function testIsNotNullFilter() $this->column->setData(['operator' => Column::OPERATOR_ISNOTNULL]); $this->assertEquals([ - new Filter(Column::OPERATOR_ISNOTNULL), - new Filter(Column::OPERATOR_NEQ, 'a:0:{}'), - ], $this->column->getFilters('asource')); + new Filter(Column::OPERATOR_ISNOTNULL), + new Filter(Column::OPERATOR_NEQ, 'a:0:{}'), + ], $this->column->getFilters('asource')); } public function testRenderCellWithoutCallback() diff --git a/tests/Grid/Column/BlankColumnTest.php b/tests/Grid/Column/BlankColumnTest.php index 1e809593..24cd45e4 100644 --- a/tests/Grid/Column/BlankColumnTest.php +++ b/tests/Grid/Column/BlankColumnTest.php @@ -25,12 +25,15 @@ public function testInitialize() $column = new BlankColumn($params); - $this->assertAttributeEquals([ - 'filterable' => false, - 'sortable' => false, - 'source' => false, - 'foo' => false, - 'bar' => true, - ], 'params', $column); + $this->assertSame( + [ + 'filterable' => false, + 'sortable' => false, + 'source' => false, + 'foo' => false, + 'bar' => true, + ], + $column->getParams() + ); } } diff --git a/tests/Grid/Column/BooleanColumnTest.php b/tests/Grid/Column/BooleanColumnTest.php index 52c02801..6593ffad 100644 --- a/tests/Grid/Column/BooleanColumnTest.php +++ b/tests/Grid/Column/BooleanColumnTest.php @@ -40,42 +40,45 @@ public function testInitialize() $column = new BooleanColumn($params); - $this->assertAttributeEquals([ - 'filter' => 'select', - 'selectFrom' => 'values', - 'operators' => [Column::OPERATOR_EQ], - 'defaultOperator' => Column::OPERATOR_EQ, - 'operatorsVisible' => false, - 'selectMulti' => false, - 'bar' => 'bar', - 'size' => 52, - ], 'params', $column); + $this->assertSame( + [ + 'filter' => 'select', + 'selectFrom' => 'values', + 'operators' => [Column::OPERATOR_EQ], + 'defaultOperator' => Column::OPERATOR_EQ, + 'operatorsVisible' => false, + 'selectMulti' => false, + 'bar' => 'bar', + 'size' => 52, + ], + $column->getParams() + ); } public function testInitializeAlignment() { - $this->assertAttributeEquals(Column::ALIGN_CENTER, 'align', $this->column); + $this->assertSame(Column::ALIGN_CENTER, $this->column->getAlign()); $column = new BooleanColumn(['align' => Column::ALIGN_LEFT]); - $this->assertAttributeEquals(Column::ALIGN_LEFT, 'align', $column); + $this->assertSame(Column::ALIGN_LEFT, $column->getAlign()); } public function testInitializeSize() { - $this->assertAttributeEquals(30, 'size', $this->column); + $this->assertSame(30, $this->column->getSize()); $column = new BooleanColumn(['size' => 40]); - $this->assertAttributeEquals(40, 'size', $column); + $this->assertSame(40, $column->getSize()); } public function testInitializeValues() { - $this->assertAttributeEquals([1 => 'true', 0 => 'false'], 'values', $this->column); + $this->assertSame([1 => 'true', 0 => 'false'], $this->column->getValues()); $values = [1 => 'foo', 0 => 'bar']; $params = ['values' => $values]; $column = new BooleanColumn($params); - $this->assertAttributeEquals($values, 'values', $column); + $this->assertSame($values, $column->getValues()); } public function testIsQueryValid() @@ -90,17 +93,32 @@ public function testIsQueryValid() public function testRenderCell() { - $this->assertEquals('true', $this->column->renderCell( - true, $this->createMock(Row::class), $this->createMock(Router::class) - )); + $this->assertEquals( + 'true', + $this->column->renderCell( + true, + $this->createMock(Row::class), + $this->createMock(Router::class) + ) + ); - $this->assertEquals('true', $this->column->renderCell( - 1, $this->createMock(Row::class), $this->createMock(Router::class) - )); + $this->assertEquals( + 'true', + $this->column->renderCell( + 1, + $this->createMock(Row::class), + $this->createMock(Router::class) + ) + ); - $this->assertEquals('false', $this->column->renderCell( - 0, $this->createMock(Row::class), $this->createMock(Router::class) - )); + $this->assertEquals( + 'false', + $this->column->renderCell( + 0, + $this->createMock(Row::class), + $this->createMock(Router::class) + ) + ); } public function testRenderCellWithCallback() @@ -110,26 +128,41 @@ function ($value, $row, $router) { return 'true'; } ); - $this->assertEquals('true', $this->column->renderCell( - 0, $this->createMock(Row::class), $this->createMock(Router::class) - )); + $this->assertEquals( + 'true', + $this->column->renderCell( + 0, + $this->createMock(Row::class), + $this->createMock(Router::class) + ) + ); $this->column->manipulateRenderCell( function ($value, $row, $router) { return 'false'; } ); - $this->assertEquals('false', $this->column->renderCell( - 1, $this->createMock(Row::class), $this->createMock(Router::class) - )); + $this->assertEquals( + 'false', + $this->column->renderCell( + 1, + $this->createMock(Row::class), + $this->createMock(Router::class) + ) + ); $this->column->manipulateRenderCell( function ($value, $row, $router) { return; } ); - $this->assertEquals('false', $this->column->renderCell( - 1, $this->createMock(Row::class), $this->createMock(Router::class) - )); + $this->assertEquals( + 'false', + $this->column->renderCell( + 1, + $this->createMock(Row::class), + $this->createMock(Router::class) + ) + ); } } diff --git a/tests/Grid/Column/DateColumnTest.php b/tests/Grid/Column/DateColumnTest.php index fc320f51..c409ae4a 100644 --- a/tests/Grid/Column/DateColumnTest.php +++ b/tests/Grid/Column/DateColumnTest.php @@ -52,28 +52,32 @@ public function testGetFiltersWithIsNullOperator() public function testGetFiltersOperatorEq() { $from = '2017-03-18'; - $to = '2017-03-20'; + $to = '2017-03-20'; $this->column->setData(['operator' => Column::OPERATOR_EQ, 'from' => $from, 'to' => $to]); $this->assertEquals([ - new Filter(Column::OPERATOR_GTE, new \DateTime($from . ' 00:00:00')), - new Filter(Column::OPERATOR_LTE, new \DateTime($from . '23:59:59')), - ], $this->column->getFilters('asource')); + new Filter(Column::OPERATOR_GTE, new \DateTime($from . ' 00:00:00')), + new Filter(Column::OPERATOR_LTE, new \DateTime($from . '23:59:59')), + ], $this->column->getFilters('asource')); } public function testGetFiltersOperatorNeq() { $from = '2017-03-18'; - $to = '2017-03-20'; + $to = '2017-03-20'; $this->column->setData(['operator' => Column::OPERATOR_NEQ, 'from' => $from, 'to' => $to]); - $this->assertEquals([ - new Filter(Column::OPERATOR_LT, new \DateTime($from . ' 00:00:00')), - new Filter(Column::OPERATOR_GT, new \DateTime($from . '23:59:59')), - ], $this->column->getFilters('asource')); - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $this->column); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_LT, new \DateTime($from . ' 00:00:00')), + new Filter(Column::OPERATOR_GT, new \DateTime($from . '23:59:59')), + ], + $this->column->getFilters('asource') + ); + + $this->assertSame(Column::DATA_DISJUNCTION, $this->column->getDataJunction()); } public function testGetFiltersOperatorLt() diff --git a/tests/Grid/Mapping/ColumnTest.php b/tests/Grid/Mapping/ColumnTest.php index a77750ce..c8f70f63 100644 --- a/tests/Grid/Mapping/ColumnTest.php +++ b/tests/Grid/Mapping/ColumnTest.php @@ -10,25 +10,25 @@ class ColumnTest extends TestCase public function setUp(): void { $this->stringMetadata = 'foo'; - $this->arrayMetadata = ['foo' => 'bar', 'groups' => 'baz']; + $this->arrayMetadata = ['foo' => 'bar', 'groups' => 'baz']; } public function testColumnMetadataCanBeEmpty() { $column = new Column([]); - $this->assertAttributeEmpty('metadata', $column); - $this->assertAttributeEquals(['default'], 'groups', $column); + $this->assertEmpty($column->getMetadata()); + $this->assertSame(['default'], $column->getGroups()); } public function testColumnStringMetadataInjectedInConstructor() { $column = new Column($this->stringMetadata); - $this->assertAttributeEquals($this->stringMetadata, 'metadata', $column); + $this->assertSame($this->stringMetadata, $column->getMetadata()); } public function testColumnArrayMetadataInjectedInConstructor() { $column = new Column($this->arrayMetadata); - $this->assertAttributeEquals($this->arrayMetadata, 'metadata', $column); + $this->assertSame($this->arrayMetadata, $column->getMetadata()); } } diff --git a/tests/Grid/Mapping/Metadata/ManagerTest.php b/tests/Grid/Mapping/Metadata/ManagerTest.php index 17121e06..4c462805 100644 --- a/tests/Grid/Mapping/Metadata/ManagerTest.php +++ b/tests/Grid/Mapping/Metadata/ManagerTest.php @@ -18,21 +18,21 @@ public function setUp(): void public function testAddDriver() { $driverInterfaceMock = $this->createMock(DriverInterface::class); - $priority = 1; + $priority = 1; $driverHeap = new DriverHeap(); $driverHeap->insert($driverInterfaceMock, $priority); $this->manager->addDriver($driverInterfaceMock, $priority); - $this->assertAttributeEquals($driverHeap, 'drivers', $this->manager); + $this->assertSame($driverHeap, $this->manager->getDrivers()); } public function testGetDrivers() { $driverInterfaceMock = $this->createMock(DriverInterface::class); - $priority = 1; + $priority = 1; $driverHeap = new DriverHeap(); $driverHeap->insert($driverInterfaceMock, $priority); @@ -44,7 +44,7 @@ public function testGetDrivers() public function testGetDriversReturnDifferentClone() { - $driverFirstTime = $this->manager->getDrivers(); + $driverFirstTime = $this->manager->getDrivers(); $driverSecondTime = $this->manager->getDrivers(); $this->assertNotSame($driverFirstTime, $driverSecondTime); @@ -52,9 +52,9 @@ public function testGetDriversReturnDifferentClone() public function testGetMetadataWithoutDrivers() { - $cols = []; + $cols = []; $mappings = []; - $groupBy = []; + $groupBy = []; $metadataExpected = new Metadata(); $metadataExpected->setFields($cols); @@ -68,7 +68,7 @@ public function testGetMetadataWithoutDrivers() public function testGetMetadata() { - $fields = ['0' => 'bar']; + $fields = ['0' => 'bar']; $groupBy = ['foo' => 'bar']; $mapping = ['bar' => ['foo' => 'foo2']]; @@ -86,8 +86,8 @@ public function testGetMetadata() $metadata = $this->manager->getMetadata('foo'); - $this->assertAttributeEquals($fields, 'fields', $metadata); - $this->assertAttributeEquals($groupBy, 'groupBy', $metadata); - $this->assertAttributeEquals($mapping, 'fieldsMappings', $metadata); + $this->assertSame($fields, $metadata->getFields()); + $this->assertSame($groupBy, $metadata->getGroupBy()); + $this->assertSame($mapping, $metadata->getFieldsMappings()); } } diff --git a/tests/Grid/Mapping/Metadata/MetadataTest.php b/tests/Grid/Mapping/Metadata/MetadataTest.php index 7fd33f84..91d0e382 100644 --- a/tests/Grid/Mapping/Metadata/MetadataTest.php +++ b/tests/Grid/Mapping/Metadata/MetadataTest.php @@ -14,15 +14,6 @@ public function setUp(): void $this->metadata = new Metadata(); } - public function testSetFields() - { - $field = ['foo' => 'bar']; - - $this->metadata->setFields($field); - - $this->assertAttributeEquals($field, 'fields', $this->metadata); - } - public function testGetFields() { $field = ['foo' => 'bar']; @@ -34,8 +25,8 @@ public function testGetFields() public function testHasFieldMappingWithField() { - $field = 'foo'; - $value = 'bar'; + $field = 'foo'; + $value = 'bar'; $fieldMapping = [$field => ['type' => $value]]; $this->metadata->setFieldsMappings($fieldMapping); @@ -46,8 +37,8 @@ public function testHasFieldMappingWithField() public function testGetterFieldMappingReturnDefaultTypeText() { - $field = 'foo'; - $value = 'bar'; + $field = 'foo'; + $value = 'bar'; $fieldMapping = [$field => $value]; $this->metadata->setFieldsMappings($fieldMapping); @@ -55,36 +46,16 @@ public function testGetterFieldMappingReturnDefaultTypeText() $this->assertEquals('text', $this->metadata->getFieldMappingType($field)); } - public function testSetterMappingFieldWithType() - { - $field = 'foo'; - $value = 'bar'; - $fieldMapping = [$field => ['type' => $value]]; - - $this->metadata->setFieldsMappings($fieldMapping); - - $this->assertAttributeEquals($fieldMapping, 'fieldsMappings', $this->metadata); - } - public function testGetterMappingFieldWithType() { - $field = 'foo'; - $value = 'bar'; + $field = 'foo'; + $value = 'bar'; $fieldMapping = [$field => ['type' => $value]]; $this->metadata->setFieldsMappings($fieldMapping); $this->assertEquals($value, $this->metadata->getFieldMappingType($field)); } - public function testSetterGroupBy() - { - $groupBy = 'groupBy'; - - $this->metadata->setGroupBy($groupBy); - - $this->assertAttributeEquals($groupBy, 'groupBy', $this->metadata); - } - public function testGetterGroupBy() { $groupBy = 'groupBy'; @@ -93,15 +64,6 @@ public function testGetterGroupBy() $this->assertEquals($groupBy, $this->metadata->getGroupBy()); } - public function testSetterName() - { - $name = 'name'; - - $this->metadata->setName($name); - - $this->assertAttributeEquals($name, 'name', $this->metadata); - } - public function testGetterName() { $name = 'name'; @@ -115,8 +77,8 @@ public function testGetColumnsFromMappingWithoutTypeReturnException() { $this->expectException(\Exception::class); - $field = 'foo'; - $value = 'bar'; + $field = 'foo'; + $value = 'bar'; $fieldMapping = [$field => ['type' => $value]]; $columnsMock = $this->createMock(Columns::class); @@ -131,12 +93,12 @@ public function testGetColumnsFromMappingWithoutTypeReturnException() public function testGetColumnsFromMapping() { - $field = 'foo'; - $field2 = 'foo2'; - $value = 'bar'; - $value2 = 'bar'; + $field = 'foo'; + $field2 = 'foo2'; + $value = 'bar'; + $value2 = 'bar'; $fieldMapping = [ - $field => [ + $field => [ 'type' => $value, ], $field2 => [ diff --git a/tests/Grid/Mapping/SourceTest.php b/tests/Grid/Mapping/SourceTest.php index 57c608e6..9bc00854 100644 --- a/tests/Grid/Mapping/SourceTest.php +++ b/tests/Grid/Mapping/SourceTest.php @@ -14,44 +14,34 @@ public function setUp(): void public function testColumnsHasDefaultValue() { - $this->assertAttributeEquals([], 'columns', $this->source); + $this->assertSame([], $this->source->getColumns()); } public function testFilterableHasDefaultValue() { - $this->assertAttributeEquals(true, 'filterable', $this->source); + $this->assertTrue($this->source->isFilterable()); } public function testSortableHasDefaultValue() { - $this->assertAttributeEquals(true, 'sortable', $this->source); + $this->assertTrue($this->source->isSortable()); } public function testGroupsHasDefaultValue() { $expectedGroups = ['0' => 'default']; - $this->assertAttributeEquals($expectedGroups, 'groups', $this->source); + $this->assertSame($expectedGroups, $this->source->getGroups()); } public function testGroupByHasDefaultValue() { - $this->assertAttributeEquals([], 'groupBy', $this->source); - } - - public function testSetterColumns() - { - $columns = 'columns'; - $expectedColumns = [$columns]; - - $this->source = new Source(['columns' => $columns]); - - $this->assertAttributeEquals($expectedColumns, 'columns', $this->source); + $this->assertSame([], $this->source->getGroupBy()); } public function testGetterColumns() { - $columns = 'columns'; + $columns = 'columns'; $expectedColumns = [$columns]; $this->source = new Source(['columns' => $columns]); @@ -68,15 +58,6 @@ public function testGetterHasColumns() $this->assertTrue($this->source->hasColumns()); } - public function testSetterFilterable() - { - $filterable = false; - - $this->source = new Source(['filterable' => $filterable]); - - $this->assertAttributeEquals($filterable, 'filterable', $this->source); - } - public function testGetterFilterable() { $filterable = false; @@ -86,37 +67,18 @@ public function testGetterFilterable() $this->assertEquals($filterable, $this->source->isFilterable()); } - public function testSetterSortable() - { - $sortable = false; - - $this->source = new Source(['sortable' => $sortable]); - - $this->assertAttributeEquals($sortable, 'sortable', $this->source); - } - public function testGetterSortable() { $sortable = false; $this->source = new Source(['sortable' => $sortable]); - $this->assertEquals($sortable, $this->source->isSortable()); - } - - public function testSetterGroups() - { - $groups = 'groups'; - $expectedGroups = [$groups]; - - $this->source = new Source(['groups' => $groups]); - - $this->assertAttributeEquals($expectedGroups, 'groups', $this->source); + $this->assertFalse($this->source->isSortable()); } public function testGetterGroups() { - $groups = 'groups'; + $groups = 'groups'; $expectedGroups = [$groups]; $this->source = new Source(['groups' => $groups]); @@ -124,19 +86,9 @@ public function testGetterGroups() $this->assertEquals($expectedGroups, $this->source->getGroups()); } - public function testSetterGroupBy() - { - $groupsBy = 'groupBy'; - $expectedGroupsBy = [$groupsBy]; - - $this->source = new Source(['groupBy' => $groupsBy]); - - $this->assertAttributeEquals($expectedGroupsBy, 'groupBy', $this->source); - } - public function testGetterGroupBy() { - $groupsBy = 'groupBy'; + $groupsBy = 'groupBy'; $expectedGroupsBy = [$groupsBy]; $this->source = new Source(['groupBy' => $groupsBy]); diff --git a/tests/Grid/RowTest.php b/tests/Grid/RowTest.php index 1847a26b..92f635cc 100644 --- a/tests/Grid/RowTest.php +++ b/tests/Grid/RowTest.php @@ -29,7 +29,7 @@ public function testSetPrimaryField() $pf = 'id'; $this->row->setPrimaryField($pf); - $this->assertAttributeEquals($pf, 'primaryField', $this->row); + $this->assertSame($pf, $this->row->getPrimaryField()); } public function testGetPrimaryField() @@ -42,22 +42,22 @@ public function testGetPrimaryField() public function testSetField() { - $field1Id = 'col1'; + $field1Id = 'col1'; $field1Val = 'col1_val'; - $field2Id = 'col2'; + $field2Id = 'col2'; $field2Val = 'col2_val'; $this->row->setField($field1Id, $field1Val); $this->row->setField($field2Id, $field2Val); - $this->assertAttributeEquals([$field1Id => $field1Val, $field2Id => $field2Val], 'fields', $this->row); + $this->assertSame([$field1Id => $field1Val, $field2Id => $field2Val], $this->row->getFields()); } public function testGetField() { $field = 'col1'; - $val = 'col1_val'; + $val = 'col1_val'; $this->row->setField($field, $val); @@ -76,8 +76,8 @@ public function testGetPrimaryFieldValueWithoutAddingItToFields() { $this->expectException(\InvalidArgumentException::class); - $field = 'foo'; - $fieldValue = 1; + $field = 'foo'; + $fieldValue = 1; $primaryField = 'id'; $this->row->setField($field, $fieldValue); @@ -88,8 +88,8 @@ public function testGetPrimaryFieldValueWithoutAddingItToFields() public function testGetSinglePrimaryFieldValue() { - $field = 'id'; - $value = 1; + $field = 'id'; + $value = 1; $primaryField = 'id'; $this->row->setField($field, $value); @@ -149,7 +149,7 @@ public function testGetEntity() $this->row->setPrimaryField($field); $entityDummy = $this->createMock(self::class); - $repo = $this->createMock(EntityRepository::class); + $repo = $this->createMock(EntityRepository::class); $repo ->expects($this->once()) ->method('find') @@ -160,14 +160,6 @@ public function testGetEntity() $this->assertSame($entityDummy, $this->row->getEntity()); } - public function testSetClass() - { - $class = 'Vendor/Bundle/Foo'; - $this->row->setClass($class); - - $this->assertAttributeEquals($class, 'class', $this->row); - } - public function testGetClass() { $class = 'Vendor/Bundle/Foo'; @@ -176,14 +168,6 @@ public function testGetClass() $this->assertEquals($class, $this->row->getClass()); } - public function testSetColor() - { - $color = 'red'; - $this->row->setColor($color); - - $this->assertAttributeEquals($color, 'color', $this->row); - } - public function testGetColor() { $color = 'blue'; @@ -192,14 +176,6 @@ public function testGetColor() $this->assertEquals($color, $this->row->getColor()); } - public function testSetLegend() - { - $legend = 'foo'; - $this->row->setLegend($legend); - - $this->assertAttributeEquals($legend, 'legend', $this->row); - } - public function testGetLegend() { $legend = 'bar'; diff --git a/tests/Grid/Source/VectorTest.php b/tests/Grid/Source/VectorTest.php index fac66997..46538bf6 100644 --- a/tests/Grid/Source/VectorTest.php +++ b/tests/Grid/Source/VectorTest.php @@ -43,32 +43,32 @@ public function testRaiseExceptionDuringVectorCreationWhenEmptyVector() public function testCreateVectorWithColumns() { - $column = $this->createMock(Column::class); + $column = $this->createMock(Column::class); $column2 = $this->createMock(Column::class); $columns = [$column, $column2]; $vector = new Vector([], $columns); - $this->assertAttributeEquals($columns, 'columns', $vector); + $this->assertSame($columns, $vector->getColumnsArray()); } public function testInitialiseWithoutData() { $this->vector->initialise($this->createMock(Container::class)); - $this->assertAttributeEmpty('columns', $this->vector); + $this->assertEmpty($this->vector->getColumnsArray()); } public function testInizialiseWithGuessedColumnsMergedToAlreadySettedColumns() { $columnId = 'cId'; - $column = $this->createMock(Column::class); + $column = $this->createMock(Column::class); $column ->method('getId') ->willReturn($columnId); $column2Id = 'c2Id'; - $column2 = $this->createMock(Column::class); + $column2 = $this->createMock(Column::class); $column2 ->method('getId') ->willReturn($column2Id); @@ -76,42 +76,42 @@ public function testInizialiseWithGuessedColumnsMergedToAlreadySettedColumns() $vector = new Vector([['c3Id' => 'c3', 'c4Id' => 'c4']], [$column, $column2]); $uc1 = new UntypedColumn([ - 'id' => 'c3Id', - 'title' => 'c3Id', - 'source' => true, - 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => 'c3Id', - ]); + 'id' => 'c3Id', + 'title' => 'c3Id', + 'source' => true, + 'filterable' => true, + 'sortable' => true, + 'visible' => true, + 'field' => 'c3Id', + ]); $uc1->setType('text'); $uc2 = new UntypedColumn([ - 'id' => 'c4Id', - 'title' => 'c4Id', - 'source' => true, - 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => 'c4Id', - ]); + 'id' => 'c4Id', + 'title' => 'c4Id', + 'source' => true, + 'filterable' => true, + 'sortable' => true, + 'visible' => true, + 'field' => 'c4Id', + ]); $uc2->setType('text'); $vector->initialise($this->createMock(Container::class)); - $this->assertAttributeEquals([$column, $column2, $uc1, $uc2], 'columns', $vector); + $this->assertSame([$column, $column2, $uc1, $uc2], $vector->getColumnsArray()); } public function testInizialiseWithoutGuessedColumns() { $columnId = 'cId'; - $column = $this->createMock(Column::class); + $column = $this->createMock(Column::class); $column ->method('getId') ->willReturn($columnId); $column2Id = 'c2Id'; - $column2 = $this->createMock(Column::class); + $column2 = $this->createMock(Column::class); $column2 ->method('getId') ->willReturn($column2Id); @@ -120,7 +120,7 @@ public function testInizialiseWithoutGuessedColumns() $vector->initialise($this->createMock(Container::class)); - $this->assertAttributeEquals([$column, $column2], 'columns', $vector); + $this->assertSame([$column, $column2], $vector->getColumnsArray()); } /** @@ -133,12 +133,12 @@ public function testInizializeWithGuessedColumn($vectorValue, UntypedColumn $unt $vector = new Vector($vectorValue); $vector->initialise($this->createMock(Container::class)); - $this->assertAttributeEquals([$untypedColumn], 'columns', $vector); + $this->assertSame([$untypedColumn], $vector->getColumnsArray()); } public function testExecute() { - $rows = [new Row(), new Row()]; + $rows = [new Row(), new Row()]; $columns = $this->createMock(Columns::class); $vector = $this->createPartialMock(Vector::class, ['executeFromData']); @@ -178,13 +178,13 @@ public function testGetTotalCount() public function testGetHash() { - $idCol1 = 'idCol1'; + $idCol1 = 'idCol1'; $column1 = $this->createMock(Column::class); $column1 ->method('getId') ->willReturn($idCol1); - $idCol2 = 'idCol2'; + $idCol2 = 'idCol2'; $column2 = $this->createMock(Column::class); $column2 ->method('getId') @@ -192,7 +192,7 @@ public function testGetHash() $vector = new Vector([], [$column1, $column2]); - $this->assertEquals('APY\DataGridBundle\Grid\Source\Vector' . md5($idCol1.$idCol2), $vector->getHash()); + $this->assertEquals('APY\DataGridBundle\Grid\Source\Vector' . md5($idCol1 . $idCol2), $vector->getHash()); } public function testId() @@ -206,38 +206,38 @@ public function testId() public function guessedColumnProvider() { $uc = new UntypedColumn([ - 'id' => 'c1Id', - 'title' => 'c1Id', - 'source' => true, - 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => 'c1Id', - ]); + 'id' => 'c1Id', + 'title' => 'c1Id', + 'source' => true, + 'filterable' => true, + 'sortable' => true, + 'visible' => true, + 'field' => 'c1Id', + ]); $date = new \DateTime(); $date->setTime(0, 0, 0); return [ - 'Empty' => [[['c1Id' => '']], $uc, 'text'], - 'Null' => [[['c1Id' => null]], $uc, 'text'], - 'Array' => [[['c1Id' => []]], $uc, 'array'], - 'Datetime' => [[['c1Id' => new \DateTime()]], $uc, 'datetime'], - 'Date' => [[['c1Id' => $date]], $uc, 'date'], - 'String but not date' => [[['c1Id' => 'thisIsAString']], $uc, 'text'], - 'Date string' => [[['c1Id' => '2017-07-22']], $uc, 'date'], - 'Datetime string' => [[['c1Id' => '2017-07-22 12:00:00']], $uc, 'datetime'], - 'True value' => [[['c1Id' => true]], $uc, 'boolean'], - 'False value' => [[['c1Id' => true]], $uc, 'boolean'], - 'True int value' => [[['c1Id' => 1]], $uc, 'boolean'], - 'False int value' => [[['c1Id' => 0]], $uc, 'boolean'], - 'True string value' => [[['c1Id' => '1']], $uc, 'boolean'], - 'False string value' => [[['c1Id' => '0']], $uc, 'boolean'], - 'Number' => [[['c1Id' => 12]], $uc, 'number'], + 'Empty' => [[['c1Id' => '']], $uc, 'text'], + 'Null' => [[['c1Id' => null]], $uc, 'text'], + 'Array' => [[['c1Id' => []]], $uc, 'array'], + 'Datetime' => [[['c1Id' => new \DateTime()]], $uc, 'datetime'], + 'Date' => [[['c1Id' => $date]], $uc, 'date'], + 'String but not date' => [[['c1Id' => 'thisIsAString']], $uc, 'text'], + 'Date string' => [[['c1Id' => '2017-07-22']], $uc, 'date'], + 'Datetime string' => [[['c1Id' => '2017-07-22 12:00:00']], $uc, 'datetime'], + 'True value' => [[['c1Id' => true]], $uc, 'boolean'], + 'False value' => [[['c1Id' => true]], $uc, 'boolean'], + 'True int value' => [[['c1Id' => 1]], $uc, 'boolean'], + 'False int value' => [[['c1Id' => 0]], $uc, 'boolean'], + 'True string value' => [[['c1Id' => '1']], $uc, 'boolean'], + 'False string value' => [[['c1Id' => '0']], $uc, 'boolean'], + 'Number' => [[['c1Id' => 12]], $uc, 'number'], 'Boolean and not number' => [[['c1Id' => true], ['c1Id' => '2017-07-22']], $uc, 'text'], - 'Boolean and number' => [[['c1Id' => true], ['c1Id' => 20]], $uc, 'number'], + 'Boolean and number' => [[['c1Id' => true], ['c1Id' => 20]], $uc, 'number'], 'Date and not date time' => [[['c1Id' => '2017-07-22'], ['c1Id' => 20]], $uc, 'text'], - 'Date and time' => [[['c1Id' => '2017-07-22'], ['c1Id' => '2017-07-22 11:00:00']], $uc, 'datetime'] + 'Date and time' => [[['c1Id' => '2017-07-22'], ['c1Id' => '2017-07-22 11:00:00']], $uc, 'datetime'], ]; } } From 198bb86ab2c699bcfd35aba622bedc2c9bb7bb76 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:39:58 -0500 Subject: [PATCH 24/41] WIP: Address more deprecation warnings --- .idea/magento2plugin.xml | 6 ++ .idea/php.xml | 102 ++++++++++++++++++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 179 +++++++++++++++++++++++++++++++ composer.json | 3 +- rector.php | 10 ++ tests/Grid/Source/VectorTest.php | 8 +- 7 files changed, 309 insertions(+), 5 deletions(-) create mode 100644 .idea/magento2plugin.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/magento2plugin.xml b/.idea/magento2plugin.xml new file mode 100644 index 00000000..6485e055 --- /dev/null +++ b/.idea/magento2plugin.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 00000000..c1072809 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..20e7f0ef --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + $PROJECT_DIR$/composer.json + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "true", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "vue.rearranger.settings.migration": "true" + } +} + + + + + 1674852945014 + + + + + + \ No newline at end of file diff --git a/composer.json b/composer.json index ffbe09ff..47118617 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "symfony/expression-language": "^4.4|^5.2", "symfony/phpunit-bridge": "^4.4|^5.2", "phpunit/phpunit": "^8.5", - "doctrine/orm": "~2.4,>=2.4.5" + "doctrine/orm": "~2.4,>=2.4.5", + "rector/rector": "^0.15.10" }, "suggest": { "ext-intl": "Translate the grid", diff --git a/rector.php b/rector.php index e69de29b..563a9c0d 100644 --- a/rector.php +++ b/rector.php @@ -0,0 +1,10 @@ +sets([ + PHPUnitSetList::PHPUNIT_90, + ]); +}; diff --git a/tests/Grid/Source/VectorTest.php b/tests/Grid/Source/VectorTest.php index 46538bf6..705e9b88 100644 --- a/tests/Grid/Source/VectorTest.php +++ b/tests/Grid/Source/VectorTest.php @@ -49,7 +49,7 @@ public function testCreateVectorWithColumns() $vector = new Vector([], $columns); - $this->assertSame($columns, $vector->getColumnsArray()); + $this->assertEquals($columns, $vector->getColumnsArray()); } public function testInitialiseWithoutData() @@ -99,7 +99,7 @@ public function testInizialiseWithGuessedColumnsMergedToAlreadySettedColumns() $vector->initialise($this->createMock(Container::class)); - $this->assertSame([$column, $column2, $uc1, $uc2], $vector->getColumnsArray()); + $this->assertEquals([$column, $column2, $uc1, $uc2], $vector->getColumnsArray()); } public function testInizialiseWithoutGuessedColumns() @@ -120,7 +120,7 @@ public function testInizialiseWithoutGuessedColumns() $vector->initialise($this->createMock(Container::class)); - $this->assertSame([$column, $column2], $vector->getColumnsArray()); + $this->assertEquals([$column, $column2], $vector->getColumnsArray()); } /** @@ -133,7 +133,7 @@ public function testInizializeWithGuessedColumn($vectorValue, UntypedColumn $unt $vector = new Vector($vectorValue); $vector->initialise($this->createMock(Container::class)); - $this->assertSame([$untypedColumn], $vector->getColumnsArray()); + $this->assertEquals([$untypedColumn], $vector->getColumnsArray()); } public function testExecute() From 2a8efc9cfb6319c9b56607e7787226822032449f Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:43:59 -0500 Subject: [PATCH 25/41] Remove rector, remove .idea folder --- .idea/magento2plugin.xml | 6 - .idea/php.xml | 102 -------------- .idea/vcs.xml | 6 - .idea/workspace.xml | 179 ------------------------ composer.json | 3 +- rector.php | 10 -- tests/Grid/Column/BooleanColumnTest.php | 14 +- 7 files changed, 8 insertions(+), 312 deletions(-) delete mode 100644 .idea/magento2plugin.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml delete mode 100644 rector.php diff --git a/.idea/magento2plugin.xml b/.idea/magento2plugin.xml deleted file mode 100644 index 6485e055..00000000 --- a/.idea/magento2plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index c1072809..00000000 --- a/.idea/php.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 20e7f0ef..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - $PROJECT_DIR$/composer.json - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - "keyToString": { - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "WebServerToolWindowFactoryState": "true", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "vue.rearranger.settings.migration": "true" - } -} - - - - - 1674852945014 - - - - - - \ No newline at end of file diff --git a/composer.json b/composer.json index 47118617..ffbe09ff 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,7 @@ "symfony/expression-language": "^4.4|^5.2", "symfony/phpunit-bridge": "^4.4|^5.2", "phpunit/phpunit": "^8.5", - "doctrine/orm": "~2.4,>=2.4.5", - "rector/rector": "^0.15.10" + "doctrine/orm": "~2.4,>=2.4.5" }, "suggest": { "ext-intl": "Translate the grid", diff --git a/rector.php b/rector.php deleted file mode 100644 index 563a9c0d..00000000 --- a/rector.php +++ /dev/null @@ -1,10 +0,0 @@ -sets([ - PHPUnitSetList::PHPUNIT_90, - ]); -}; diff --git a/tests/Grid/Column/BooleanColumnTest.php b/tests/Grid/Column/BooleanColumnTest.php index 6593ffad..882c5cb6 100644 --- a/tests/Grid/Column/BooleanColumnTest.php +++ b/tests/Grid/Column/BooleanColumnTest.php @@ -40,7 +40,7 @@ public function testInitialize() $column = new BooleanColumn($params); - $this->assertSame( + $this->assertEquals( [ 'filter' => 'select', 'selectFrom' => 'values', @@ -57,28 +57,28 @@ public function testInitialize() public function testInitializeAlignment() { - $this->assertSame(Column::ALIGN_CENTER, $this->column->getAlign()); + $this->assertEquals(Column::ALIGN_CENTER, $this->column->getAlign()); $column = new BooleanColumn(['align' => Column::ALIGN_LEFT]); - $this->assertSame(Column::ALIGN_LEFT, $column->getAlign()); + $this->assertEquals(Column::ALIGN_LEFT, $column->getAlign()); } public function testInitializeSize() { - $this->assertSame(30, $this->column->getSize()); + $this->assertEquals(30, $this->column->getSize()); $column = new BooleanColumn(['size' => 40]); - $this->assertSame(40, $column->getSize()); + $this->assertEquals(40, $column->getSize()); } public function testInitializeValues() { - $this->assertSame([1 => 'true', 0 => 'false'], $this->column->getValues()); + $this->assertEquals([1 => 'true', 0 => 'false'], $this->column->getValues()); $values = [1 => 'foo', 0 => 'bar']; $params = ['values' => $values]; $column = new BooleanColumn($params); - $this->assertSame($values, $column->getValues()); + $this->assertEquals($values, $column->getValues()); } public function testIsQueryValid() From 79c5a5e1570819e505c831513f7bd5ff13f56872 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:44:38 -0500 Subject: [PATCH 26/41] gitignore idea folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e01bc6ab..011b104b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor/ +/.idea/ /.phpunit.result.cache /composer.lock /phpunit.xml From 8bc8f1a163c5f945869d56822912794c1246caba Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Wed, 1 Feb 2023 16:46:02 -0500 Subject: [PATCH 27/41] Use assertEquals() instead of assertSame() --- tests/Grid/Column/BlankColumnTest.php | 2 +- tests/Grid/Mapping/Metadata/ManagerTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Grid/Column/BlankColumnTest.php b/tests/Grid/Column/BlankColumnTest.php index 24cd45e4..5269453a 100644 --- a/tests/Grid/Column/BlankColumnTest.php +++ b/tests/Grid/Column/BlankColumnTest.php @@ -25,7 +25,7 @@ public function testInitialize() $column = new BlankColumn($params); - $this->assertSame( + $this->assertEquals( [ 'filterable' => false, 'sortable' => false, diff --git a/tests/Grid/Mapping/Metadata/ManagerTest.php b/tests/Grid/Mapping/Metadata/ManagerTest.php index 4c462805..48445050 100644 --- a/tests/Grid/Mapping/Metadata/ManagerTest.php +++ b/tests/Grid/Mapping/Metadata/ManagerTest.php @@ -25,7 +25,7 @@ public function testAddDriver() $this->manager->addDriver($driverInterfaceMock, $priority); - $this->assertSame($driverHeap, $this->manager->getDrivers()); + $this->assertEquals($driverHeap, $this->manager->getDrivers()); } public function testGetDrivers() @@ -86,8 +86,8 @@ public function testGetMetadata() $metadata = $this->manager->getMetadata('foo'); - $this->assertSame($fields, $metadata->getFields()); - $this->assertSame($groupBy, $metadata->getGroupBy()); - $this->assertSame($mapping, $metadata->getFieldsMappings()); + $this->assertEquals($fields, $metadata->getFields()); + $this->assertEquals($groupBy, $metadata->getGroupBy()); + $this->assertEquals($mapping, $metadata->getFieldsMappings()); } } From e6adf70816485c3bd7271005fefdeae8748d4175 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 14:59:48 -0500 Subject: [PATCH 28/41] Address more deprecations --- src/Grid/Column/Column.php | 12 + tests/Grid/Column/ColumnTest.php | 679 ++++++++++++------------------- 2 files changed, 264 insertions(+), 427 deletions(-) diff --git a/src/Grid/Column/Column.php b/src/Grid/Column/Column.php index 2d384b71..e97a21c8 100644 --- a/src/Grid/Column/Column.php +++ b/src/Grid/Column/Column.php @@ -240,6 +240,10 @@ public function manipulateRenderCell($callback) return $this; } + public function getCallback() { + return $this->callback; + } + /** * Set column identifier. * @@ -563,6 +567,10 @@ 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). * @@ -910,6 +918,10 @@ public function setAuthorizationChecker(AuthorizationCheckerInterface $authoriza return $this; } + public function getAuthorizationChecker(): ?AuthorizationCheckerInterface { + return $this->authorizationChecker; + } + public function getParentType() { return ''; diff --git a/tests/Grid/Column/ColumnTest.php b/tests/Grid/Column/ColumnTest.php index f47172f7..cf3cc342 100644 --- a/tests/Grid/Column/ColumnTest.php +++ b/tests/Grid/Column/ColumnTest.php @@ -20,65 +20,65 @@ public function testInitializeDefaultValues() $mock->__initialize(['field' => $field]); - $this->assertAttributeEquals($field, 'title', $mock); - $this->assertAttributeEquals(true, 'sortable', $mock); - $this->assertAttributeEquals(true, 'visible', $mock); - $this->assertAttributeEquals(-1, 'size', $mock); - $this->assertAttributeEquals(true, 'filterable', $mock); - $this->assertAttributeEquals(false, 'visibleForSource', $mock); - $this->assertAttributeEquals(false, 'primary', $mock); - $this->assertAttributeEquals(Column::ALIGN_LEFT, 'align', $mock); - $this->assertAttributeEquals('text', 'inputType', $mock); - $this->assertAttributeEquals('input', 'filterType', $mock); - $this->assertAttributeEquals('query', 'selectFrom', $mock); - $this->assertAttributeEquals([], 'values', $mock); - $this->assertAttributeEquals(true, 'operatorsVisible', $mock); - $this->assertAttributeEquals(false, 'isManualField', $mock); - $this->assertAttributeEquals(false, 'isAggregate', $mock); - $this->assertAttributeEquals(true, 'usePrefixTitle', $mock); - $this->assertAttributeEquals(Column::getAvailableOperators(), 'operators', $mock); - $this->assertAttributeEquals(Column::OPERATOR_LIKE, 'defaultOperator', $mock); - $this->assertAttributeEquals(false, 'selectMulti', $mock); - $this->assertAttributeEquals(false, 'selectExpanded', $mock); - $this->assertAttributeEquals(false, 'searchOnClick', $mock); - $this->assertAttributeEquals('html', 'safe', $mock); - $this->assertAttributeEquals('
', 'separator', $mock); + $this->assertEquals($field, $mock->getTitle()); + $this->assertTrue($mock->isSortable()); + $this->assertTrue($mock->isVisible()); + $this->assertEquals(-1, $mock->getSize()); + $this->assertTrue($mock->isFilterable()); + $this->assertFalse($mock->isVisibleForSource()); + $this->assertFalse($mock->isPrimary()); + $this->assertEquals(Column::ALIGN_LEFT, $mock->getAlign()); + $this->assertEquals('text', $mock->getInputType()); + $this->assertEquals('input', $mock->getFilterType()); + $this->assertEquals('query', $mock->getSelectFrom()); + $this->assertEquals([], $mock->getValues()); + $this->assertTrue($mock->getOperatorsVisible()); + $this->assertFalse($mock->getIsManualField()); + $this->assertFalse($mock->getIsAggregate()); + $this->assertTrue($mock->getUsePrefixTitle()); + $this->assertEquals(Column::getAvailableOperators(), $mock->getOperators()); + $this->assertEquals(Column::OPERATOR_LIKE, $mock->getDefaultOperator()); + $this->assertFalse($mock->getSelectMulti()); + $this->assertFalse($mock->getSelectExpanded()); + $this->assertFalse($mock->getSearchOnClick()); + $this->assertEquals('html', $mock->getSafe()); + $this->assertEquals('
', $mock->getSeparator()); } public function testInitialize() { $mock = $this->getMockForAbstractClass(Column::class); - $id = 'id'; - $title = 'title'; - $sortable = false; - $visible = false; - $size = 2; - $filterable = false; - $source = true; - $primary = true; - $align = Column::ALIGN_RIGHT; - $inputType = 'number'; - $field = 'field'; - $role = 'role'; - $order = 1; - $joinType = 'left'; - $filter = 'filter'; - $selectFrom = 'source'; - $values = [1, 2, 3]; - $operatorsVisible = false; - $isManualField = true; - $isAggregate = true; - $usePrefixText = false; - $operators = [Column::OPERATOR_ISNULL, Column::OPERATOR_ISNOTNULL]; - $defaultOperator = Column::OPERATOR_ISNOTNULL; - $selectMulti = true; - $selectExpanded = true; - $searchOnClick = true; - $safe = 'safe'; - $separator = '
'; - $export = true; - $class = 'class'; + $id = 'id'; + $title = 'title'; + $sortable = false; + $visible = false; + $size = 2; + $filterable = false; + $source = true; + $primary = true; + $align = Column::ALIGN_RIGHT; + $inputType = 'number'; + $field = 'field'; + $role = 'role'; + $order = 1; + $joinType = 'left'; + $filter = 'filter'; + $selectFrom = 'source'; + $values = [1, 2, 3]; + $operatorsVisible = false; + $isManualField = true; + $isAggregate = true; + $usePrefixText = false; + $operators = [Column::OPERATOR_ISNULL, Column::OPERATOR_ISNOTNULL]; + $defaultOperator = Column::OPERATOR_ISNOTNULL; + $selectMulti = true; + $selectExpanded = true; + $searchOnClick = true; + $safe = 'safe'; + $separator = '
'; + $export = true; + $class = 'class'; $translationDomain = 'en_EN'; $params = [ @@ -117,49 +117,51 @@ public function testInitialize() $mock->__initialize($params); - $this->assertAttributeEquals($params, 'params', $mock); - $this->assertAttributeEquals($id, 'id', $mock); - $this->assertAttributeEquals($title, 'title', $mock); - $this->assertAttributeEquals($sortable, 'sortable', $mock); - $this->assertAttributeEquals($visible, 'visible', $mock); - $this->assertAttributeEquals($size, 'size', $mock); - $this->assertAttributeEquals($filterable, 'filterable', $mock); - $this->assertAttributeEquals($source, 'visibleForSource', $mock); - $this->assertAttributeEquals($primary, 'primary', $mock); - $this->assertAttributeEquals($align, 'align', $mock); - $this->assertAttributeEquals($inputType, 'inputType', $mock); - $this->assertAttributeEquals($field, 'field', $mock); - $this->assertAttributeEquals($role, 'role', $mock); - $this->assertAttributeEquals($order, 'order', $mock); - $this->assertAttributeEquals($joinType, 'joinType', $mock); - $this->assertAttributeEquals($filter, 'filterType', $mock); - $this->assertAttributeEquals($selectFrom, 'selectFrom', $mock); - $this->assertAttributeEquals($values, 'values', $mock); - $this->assertAttributeEquals($operatorsVisible, 'operatorsVisible', $mock); - $this->assertAttributeEquals($isManualField, 'isManualField', $mock); - $this->assertAttributeEquals($isAggregate, 'isAggregate', $mock); - $this->assertAttributeEquals($usePrefixText, 'usePrefixTitle', $mock); - $this->assertAttributeEquals($operators, 'operators', $mock); - $this->assertAttributeEquals($defaultOperator, 'defaultOperator', $mock); - $this->assertAttributeEquals($selectMulti, 'selectMulti', $mock); - $this->assertAttributeEquals($selectExpanded, 'selectExpanded', $mock); - $this->assertAttributeEquals($searchOnClick, 'searchOnClick', $mock); - $this->assertAttributeEquals($safe, 'safe', $mock); - $this->assertAttributeEquals($separator, 'separator', $mock); - $this->assertAttributeEquals($export, 'export', $mock); - $this->assertAttributeEquals($class, 'class', $mock); - $this->assertAttributeEquals($translationDomain, 'translationDomain', $mock); + $this->assertEquals($params, $mock->getParams()); + $this->assertEquals($id, $mock->getId()); + $this->assertEquals($title, $mock->getTitle()); + $this->assertFalse($mock->isSortable()); + $this->assertFalse($mock->isVisible()); + $this->assertEquals($size, $mock->getSize()); + $this->assertFalse($mock->isFilterable()); + $this->assertTrue($mock->isVisibleForSource()); + $this->assertTrue($mock->isPrimary()); + $this->assertEquals($align, $mock->getAlign()); + $this->assertEquals($inputType, $mock->getInputType()); + $this->assertEquals($field, $mock->getField()); + $this->assertEquals($role, $mock->getRole()); + $this->assertEquals($order, $mock->getOrder()); + $this->assertEquals($joinType, $mock->getJoinType()); + $this->assertEquals($filter, $mock->getFilterType()); + $this->assertEquals($selectFrom, $mock->getSelectFrom()); + $this->assertEquals($values, $mock->getValues()); + $this->assertFalse($mock->getOperatorsVisible()); + $this->assertTrue($mock->getIsManualField()); + $this->assertTrue($mock->getIsAggregate()); + $this->assertFalse($mock->getUsePrefixTitle()); + $this->assertEquals($operators, $mock->getOperators()); + $this->assertEquals($defaultOperator, $mock->getDefaultOperator()); + $this->assertTrue($mock->getSelectMulti()); + $this->assertTrue($mock->getSelectExpanded()); + $this->assertTrue($mock->getSearchOnClick()); + $this->assertEquals($safe, $mock->getSafe()); + $this->assertEquals($separator, $mock->getSeparator()); + $this->assertTrue($mock->getExport()); + $this->assertEquals($class, $mock->getClass()); + $this->assertEquals($translationDomain, $mock->getTranslationDomain()); } public function testRenderCellWithCallback() { $mock = $this->getMockForAbstractClass(Column::class); - $value = 0; - $row = $this->createMock(Row::class); + $value = 0; + $row = $this->createMock(Row::class); $router = $this->createMock(Router::class); - $mock->manipulateRenderCell(function ($value, $row, $router) { return 1; }); + $mock->manipulateRenderCell(function ($value, $row, $router) { + return 1; + }); $this->assertEquals(1, $mock->renderCell($value, $row, $router)); } @@ -168,7 +170,7 @@ public function testRenderCellWithBoolValue() { $mock = $this->getMockForAbstractClass(Column::class); - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $router = $this->createMock(Router::class); $mock->setValues([1 => 'foo']); @@ -182,7 +184,7 @@ public function testRenderCell() { $mock = $this->getMockForAbstractClass(Column::class); - $row = $this->createMock(Row::class); + $row = $this->createMock(Row::class); $router = $this->createMock(Router::class); $mock->setValues(['foo' => 'bar']); @@ -193,22 +195,16 @@ public function testManipulateRenderCell() { $mock = $this->getMockForAbstractClass(Column::class); - $value = 0; - $row = $this->createMock(Row::class); + $value = 0; + $row = $this->createMock(Row::class); $router = $this->createMock(Router::class); - $callback = function ($value, $row, $router) { return 1; }; + $callback = function ($value, $row, $router) { + return 1; + }; $mock->manipulateRenderCell($callback); - $this->assertAttributeEquals($callback, 'callback', $mock); - } - - public function testSetId() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setId(1); - - $this->assertAttributeEquals(1, 'id', $mock); + $this->assertEquals($callback, $mock->getCallback()); } public function testGetId() @@ -227,16 +223,6 @@ public function testGetRenderBlockId() $this->assertEquals('foo_bar_foobar', $mock->getRenderBlockId()); } - public function testSetTitle() - { - $mock = $this->getMockForAbstractClass(Column::class); - - $title = 'title'; - $mock->setTitle($title); - - $this->assertAttributeEquals($title, 'title', $mock); - } - public function testGetTitle() { $mock = $this->getMockForAbstractClass(Column::class); @@ -254,7 +240,7 @@ public function testSetVisible() $isVisible = true; $mock->setVisible($isVisible); - $this->assertAttributeEquals($isVisible, 'visible', $mock); + $this->assertTrue($mock->isVisible()); } public function testItIsNotVisibleWhenNotExported() @@ -293,8 +279,8 @@ public function testItIsVisibleIfNotExportedAndRoleNotSetted() public function testItIsVisibleIfNotExportedAndGranted() { - $mock = $this->getMockForAbstractClass(Column::class); - $role = $this->createMock(Role::class); + $mock = $this->getMockForAbstractClass(Column::class); + $role = $this->createMock(Role::class); $authChecker = $this->createMock(AuthorizationCheckerInterface::class); $authChecker->method('isGranted')->with($role)->willReturn(true); @@ -309,8 +295,8 @@ public function testItIsVisibleIfNotExportedAndGranted() public function testItIsNotVisibleIfNotExportedButNotGranted() { - $mock = $this->getMockForAbstractClass(Column::class); - $role = $this->createMock(Role::class); + $mock = $this->getMockForAbstractClass(Column::class); + $role = $this->createMock(Role::class); $authChecker = $this->createMock(AuthorizationCheckerInterface::class); $authChecker->method('isGranted')->with($role)->willReturn(false); @@ -359,8 +345,8 @@ public function testItIsVisibleIfExportedAndRoleNotSetted() public function testItIsVisibleIfExportedAndGranted() { - $mock = $this->getMockForAbstractClass(Column::class); - $role = $this->createMock(Role::class); + $mock = $this->getMockForAbstractClass(Column::class); + $role = $this->createMock(Role::class); $authChecker = $this->createMock(AuthorizationCheckerInterface::class); $authChecker->method('isGranted')->with($role)->willReturn(true); @@ -375,8 +361,8 @@ public function testItIsVisibleIfExportedAndGranted() public function testItIsNotVisibleIfExportedButNotGranted() { - $mock = $this->getMockForAbstractClass(Column::class); - $role = $this->createMock(Role::class); + $mock = $this->getMockForAbstractClass(Column::class); + $role = $this->createMock(Role::class); $authChecker = $this->createMock(AuthorizationCheckerInterface::class); $authChecker->method('isGranted')->with($role)->willReturn(false); @@ -393,7 +379,7 @@ public function testIsNotSortedWhenNotOrdered() { $mock = $this->getMockForAbstractClass(Column::class); - $this->assertAttributeEquals(false, 'isSorted', $mock); + $this->assertFalse($mock->isSorted()); } public function testIsSortedWhenOrdered() @@ -401,7 +387,7 @@ public function testIsSortedWhenOrdered() $mock = $this->getMockForAbstractClass(Column::class); $mock->setOrder(1); - $this->assertAttributeEquals(true, 'isSorted', $mock); + $this->assertTrue($mock->isSorted()); } public function testSetSortable() @@ -409,7 +395,7 @@ public function testSetSortable() $mock = $this->getMockForAbstractClass(Column::class); $mock->setSortable(true); - $this->assertAttributeEquals(true, 'sortable', $mock); + $this->assertTrue($mock->isSortable()); } public function testIsSortable() @@ -483,14 +469,6 @@ public function testIsFilteredIfOperatorIsNotNull() $this->assertTrue($mock->isFiltered()); } - public function testSetFilterable() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setFilterable(true); - - $this->assertAttributeEquals(true, 'filterable', $mock); - } - public function testIsFilterable() { $mock = $this->getMockForAbstractClass(Column::class); @@ -504,8 +482,8 @@ public function testItDoesNotSetOrderIfOrderIsNull() $mock = $this->getMockForAbstractClass(Column::class); $mock->setOrder(null); - $this->assertAttributeEquals(null, 'order', $mock); - $this->assertAttributeEquals(false, 'isSorted', $mock); + $this->assertNull($mock->getOrder()); + $this->assertFalse($mock->isSorted()); } public function testItDoesSetOrderIfZero() @@ -513,8 +491,8 @@ public function testItDoesSetOrderIfZero() $mock = $this->getMockForAbstractClass(Column::class); $mock->setOrder(0); - $this->assertAttributeEquals(0, 'order', $mock); - $this->assertAttributeEquals(true, 'isSorted', $mock); + $this->assertEquals(0, $mock->getOrder()); + $this->assertTrue($mock->isSorted()); } public function testItDoesSetOrder() @@ -522,8 +500,8 @@ public function testItDoesSetOrder() $mock = $this->getMockForAbstractClass(Column::class); $mock->setOrder(1); - $this->assertAttributeEquals(1, 'order', $mock); - $this->assertAttributeEquals(true, 'isSorted', $mock); + $this->assertEquals(1, $mock->getOrder()); + $this->assertTrue($mock->isSorted()); } public function testGetOrder() @@ -548,15 +526,7 @@ public function testAutoResize() $mock = $this->getMockForAbstractClass(Column::class); $mock->setSize(-1); - $this->assertAttributeEquals(-1, 'size', $mock); - } - - public function testSetSize() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSize(2); - - $this->assertAttributeEquals(2, 'size', $mock); + $this->assertEquals(-1, $mock->getSize()); } public function testGetSize() @@ -572,11 +542,14 @@ public function testDataDefaultIfNoDataSetted() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData([]); - $this->assertAttributeEquals([ - 'operator' => Column::OPERATOR_LIKE, - 'from' => Column::DEFAULT_VALUE, - 'to' => Column::DEFAULT_VALUE, - ], 'data', $mock); + $this->assertEquals( + [ + 'operator' => Column::OPERATOR_LIKE, + 'from' => Column::DEFAULT_VALUE, + 'to' => Column::DEFAULT_VALUE, + ], + $mock->getDataAttribute() + ); } public function testSetNullOperatorWithoutFromToValues() @@ -584,11 +557,14 @@ public function testSetNullOperatorWithoutFromToValues() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_ISNULL]); - $this->assertAttributeEquals([ - 'operator' => Column::OPERATOR_ISNULL, - 'from' => Column::DEFAULT_VALUE, - 'to' => Column::DEFAULT_VALUE, - ], 'data', $mock); + $this->assertEquals( + [ + 'operator' => Column::OPERATOR_ISNULL, + 'from' => Column::DEFAULT_VALUE, + 'to' => Column::DEFAULT_VALUE, + ], + $mock->getDataAttribute() + ); } public function testSetNotNullOperatorWithoutFromToValues() @@ -596,11 +572,14 @@ public function testSetNotNullOperatorWithoutFromToValues() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_ISNOTNULL]); - $this->assertAttributeEquals([ - 'operator' => Column::OPERATOR_ISNOTNULL, - 'from' => Column::DEFAULT_VALUE, - 'to' => Column::DEFAULT_VALUE, - ], 'data', $mock); + $this->assertEquals( + [ + 'operator' => Column::OPERATOR_ISNOTNULL, + 'from' => Column::DEFAULT_VALUE, + 'to' => Column::DEFAULT_VALUE, + ], + $mock->getDataAttribute() + ); } public function testDoesNotSetDataIfOperatorNotNotNullOrNullNoFromToValues() @@ -614,11 +593,14 @@ public function testDoesNotSetDataIfOperatorNotNotNullOrNullNoFromToValues() foreach (array_keys($operators) as $operator) { $mock->setData(['operator' => $operator]); - $this->assertAttributeEquals([ - 'operator' => Column::OPERATOR_LIKE, - 'from' => Column::DEFAULT_VALUE, - 'to' => Column::DEFAULT_VALUE, - ], 'data', $mock); + $this->assertEquals( + [ + 'operator' => Column::OPERATOR_LIKE, + 'from' => Column::DEFAULT_VALUE, + 'to' => Column::DEFAULT_VALUE, + ], + $mock->getDataAttribute() + ); } } @@ -633,11 +615,14 @@ public function testItSetsData() foreach (array_keys($operators) as $operator) { $mock->setData(['operator' => $operator, 'from' => 'from', 'to' => 'to']); - $this->assertAttributeEquals([ - 'operator' => $operator, - 'from' => 'from', - 'to' => 'to', - ], 'data', $mock); + $this->assertEquals( + [ + 'operator' => $operator, + 'from' => 'from', + 'to' => 'to', + ], + $mock->getData() + ); } } @@ -646,9 +631,12 @@ public function testGetDataNullOpearatorWithoutValues() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_ISNULL]); - $this->assertEquals([ - 'operator' => Column::OPERATOR_ISNULL, - ], $mock->getData()); + $this->assertEquals( + [ + 'operator' => Column::OPERATOR_ISNULL, + ], + $mock->getData() + ); } public function testGetDataNotNullOpearatorWithoutValues() @@ -657,9 +645,12 @@ public function testGetDataNotNullOpearatorWithoutValues() $mock->setData(['operator' => Column::OPERATOR_ISNOTNULL]); - $this->assertEquals([ - 'operator' => Column::OPERATOR_ISNOTNULL, - ], $mock->getData()); + $this->assertEquals( + [ + 'operator' => Column::OPERATOR_ISNOTNULL, + ], + $mock->getData() + ); } public function testGetEmptyDataIfOperatorNotNotNullOrNullNoFromToValues() @@ -688,11 +679,14 @@ public function testGetData() foreach (array_keys($operators) as $operator) { $mock->setData(['operator' => $operator, 'from' => 'from', 'to' => 'to']); - $this->assertEquals([ - 'operator' => $operator, - 'from' => 'from', - 'to' => 'to', - ], $mock->getData()); + $this->assertEquals( + [ + 'operator' => $operator, + 'from' => 'from', + 'to' => 'to', + ], + $mock->getData() + ); } } @@ -703,14 +697,6 @@ public function testQueryIsAlwaysValid() $this->assertTrue($mock->isQueryValid('foo')); } - public function testSetVisibleForSource() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setVisibleForSource(true); - - $this->assertAttributeEquals(true, 'visibleForSource', $mock); - } - public function testIsVisibleForSource() { $mock = $this->getMockForAbstractClass(Column::class); @@ -719,14 +705,6 @@ public function testIsVisibleForSource() $this->assertTrue($mock->isVisibleForSource()); } - public function testSetPrimary() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setPrimary(true); - - $this->assertAttributeEquals(true, 'primary', $mock); - } - public function testIsPrimary() { $mock = $this->getMockForAbstractClass(Column::class); @@ -744,14 +722,6 @@ public function testItThrowsExceptionIfSetAnAlignNotAllowed() $mock->setAlign('foo'); } - public function testSetAlign() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setAlign(Column::ALIGN_RIGHT); - - $this->assertAttributeEquals(Column::ALIGN_RIGHT, 'align', $mock); - } - public function testGetAlign() { $mock = $this->getMockForAbstractClass(Column::class); @@ -760,14 +730,6 @@ public function testGetAlign() $this->assertEquals(Column::ALIGN_RIGHT, $mock->getAlign()); } - public function testSetInputType() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setInputType('string'); - - $this->assertAttributeEquals('string', 'inputType', $mock); - } - public function testGetInputType() { $mock = $this->getMockForAbstractClass(Column::class); @@ -776,14 +738,6 @@ public function testGetInputType() $this->assertEquals('string', $mock->getInputType()); } - public function testSetField() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setField('foo'); - - $this->assertAttributeEquals('foo', 'field', $mock); - } - public function testGetField() { $mock = $this->getMockForAbstractClass(Column::class); @@ -792,15 +746,6 @@ public function testGetField() $this->assertEquals('foo', $mock->getField()); } - public function testSetRole() - { - $role = $this->createMock(Role::class); - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setRole($role); - - $this->assertAttributeEquals($role, 'role', $mock); - } - public function testGetRole() { $role = $this->createMock(Role::class); @@ -810,14 +755,6 @@ public function testGetRole() $this->assertEquals($role, $mock->getRole()); } - public function testSetFilterType() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setFilterType('TEXTBOX'); - - $this->assertAttributeEquals('textbox', 'filterType', $mock); - } - public function testGetFilterType() { $mock = $this->getMockForAbstractClass(Column::class); @@ -826,14 +763,6 @@ public function testGetFilterType() $this->assertEquals('textbox', $mock->getFilterType()); } - public function testSetDataJunction() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setDataJunction(Column::DATA_DISJUNCTION); - - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $mock); - } - public function testGetDataJunction() { $mock = $this->getMockForAbstractClass(Column::class); @@ -851,14 +780,6 @@ public function testItThrowsExceptionIfSetDefaultOperatorWithOperatorNotAllowed( $mock->setDefaultOperator('foo'); } - public function testSetDefaultOperator() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setDefaultOperator(Column::OPERATOR_LTE); - - $this->assertAttributeEquals(Column::OPERATOR_LTE, 'defaultOperator', $mock); - } - public function testGetDefaultOperator() { $mock = $this->getMockForAbstractClass(Column::class); @@ -875,14 +796,6 @@ public function testHasOperator() $this->assertFalse($mock->hasOperator('foo')); } - public function testSetOperatorsVisible() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setOperatorsVisible(false); - - $this->assertAttributeEquals(false, 'operatorsVisible', $mock); - } - public function testGetOperatorsVisible() { $mock = $this->getMockForAbstractClass(Column::class); @@ -891,16 +804,6 @@ public function testGetOperatorsVisible() $this->assertFalse($mock->getOperatorsVisible()); } - public function testSetValues() - { - $mock = $this->getMockForAbstractClass(Column::class); - - $values = [0 => 'foo', 1 => 'bar']; - $mock->setValues($values); - - $this->assertAttributeEquals($values, 'values', $mock); - } - public function testGetValues() { $mock = $this->getMockForAbstractClass(Column::class); @@ -911,14 +814,6 @@ public function testGetValues() $this->assertEquals($values, $mock->getValues()); } - public function testSetSelectFrom() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSelectFrom('source'); - - $this->assertAttributeEquals('source', 'selectFrom', $mock); - } - public function testGetSelectFrom() { $mock = $this->getMockForAbstractClass(Column::class); @@ -927,14 +822,6 @@ public function testGetSelectFrom() $this->assertEquals('source', $mock->getSelectFrom()); } - public function testSetSelectMulti() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSelectMulti(true); - - $this->assertAttributeEquals(true, 'selectMulti', $mock); - } - public function testGetSelectMulti() { $mock = $this->getMockForAbstractClass(Column::class); @@ -943,14 +830,6 @@ public function testGetSelectMulti() $this->assertTrue($mock->getSelectMulti()); } - public function testSetSelectExpanded() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSelectExpanded(true); - - $this->assertAttributeEquals(true, 'selectExpanded', $mock); - } - public function testGetSelectExpanded() { $mock = $this->getMockForAbstractClass(Column::class); @@ -966,7 +845,7 @@ public function testSetAuthChecker() $authChecker = $this->createMock(AuthorizationCheckerInterface::class); $mock->setAuthorizationChecker($authChecker); - $this->assertAttributeEquals($authChecker, 'authorizationChecker', $mock); + $this->assertEquals($authChecker, $mock->getAuthorizationChecker()); } public function testNoParentType() @@ -996,14 +875,6 @@ public function testIsFilterSubmitOnChange() $this->assertTrue($mock->isFilterSubmitOnChange()); } - public function testSetSearchOnClick() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSearchOnClick(false); - - $this->assertAttributeEquals(false, 'searchOnClick', $mock); - } - public function testGetSearchOnClick() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1012,14 +883,6 @@ public function testGetSearchOnClick() $this->assertFalse($mock->getSearchOnClick()); } - public function testSetSafe() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSafe('html'); - - $this->assertAttributeEquals('html', 'safe', $mock); - } - public function testGetSafe() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1028,14 +891,6 @@ public function testGetSafe() $this->assertEquals('html', $mock->getSafe()); } - public function testSetSeparator() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setSeparator(';'); - - $this->assertAttributeEquals(';', 'separator', $mock); - } - public function testGetSeparator() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1044,14 +899,6 @@ public function testGetSeparator() $this->assertEquals(';', $mock->getSeparator()); } - public function testSetJoinType() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setJoinType('left'); - - $this->assertAttributeEquals('left', 'joinType', $mock); - } - public function testGetJoinType() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1060,14 +907,6 @@ public function testGetJoinType() $this->assertEquals('left', $mock->getJoinType()); } - public function testSetExport() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setExport(true); - - $this->assertAttributeEquals(true, 'export', $mock); - } - public function testGetExport() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1076,14 +915,6 @@ public function testGetExport() $this->assertTrue($mock->getExport()); } - public function testSetClass() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setClass('aClass'); - - $this->assertAttributeEquals('aClass', 'class', $mock); - } - public function testGetClass() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1092,14 +923,6 @@ public function testGetClass() $this->assertEquals('aClass', $mock->getClass()); } - public function testSetIsManualField() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setIsManualField(true); - - $this->assertAttributeEquals(true, 'isManualField', $mock); - } - public function testGetIsManualField() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1108,14 +931,6 @@ public function testGetIsManualField() $this->assertTrue($mock->getIsManualField()); } - public function testSetIsAggregate() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setIsAggregate(true); - - $this->assertAttributeEquals(true, 'isAggregate', $mock); - } - public function testGetIsAggregate() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1124,14 +939,6 @@ public function testGetIsAggregate() $this->assertTrue($mock->getIsAggregate()); } - public function testSetUsePrefixTitle() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setUsePrefixTitle(false); - - $this->assertAttributeEquals(false, 'usePrefixTitle', $mock); - } - public function testGetUsePrefixTitle() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1140,14 +947,6 @@ public function testGetUsePrefixTitle() $this->assertFalse($mock->getUsePrefixTitle()); } - public function testSetTranslationDomain() - { - $mock = $this->getMockForAbstractClass(Column::class); - $mock->setTranslationDomain('it'); - - $this->assertAttributeEquals('it', 'translationDomain', $mock); - } - public function testGetTranslationDomain() { $mock = $this->getMockForAbstractClass(Column::class); @@ -1168,9 +967,12 @@ public function testGetFiltersBtwWithoutFrom() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_BTW, 'to' => 10]); - $this->assertEquals([ - new Filter(Column::OPERATOR_LT, 10), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_LT, 10), + ], + $mock->getFilters('aSource') + ); } public function testGetFiltersBtwWithoutTo() @@ -1178,9 +980,12 @@ public function testGetFiltersBtwWithoutTo() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_BTW, 'from' => 1]); - $this->assertEquals([ - new Filter(Column::OPERATOR_GT, 1), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GT, 1), + ], + $mock->getFilters('aSource') + ); } public function testGetFiltersBtw() @@ -1188,10 +993,13 @@ public function testGetFiltersBtw() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_BTW, 'from' => 1, 'to' => 10]); - $this->assertEquals([ - new Filter(Column::OPERATOR_GT, 1), - new Filter(Column::OPERATOR_LT, 10), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GT, 1), + new Filter(Column::OPERATOR_LT, 10), + ], + $mock->getFilters('aSource') + ); } public function testGetFiltersBtweWithoutFrom() @@ -1200,8 +1008,8 @@ public function testGetFiltersBtweWithoutFrom() $mock->setData(['operator' => Column::OPERATOR_BTWE, 'to' => 10]); $this->assertEquals([ - new Filter(Column::OPERATOR_LTE, 10), - ], $mock->getFilters('aSource')); + new Filter(Column::OPERATOR_LTE, 10), + ], $mock->getFilters('aSource')); } public function testGetFiltersBtweWithoutTo() @@ -1209,9 +1017,12 @@ public function testGetFiltersBtweWithoutTo() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_BTWE, 'from' => 1]); - $this->assertEquals([ - new Filter(Column::OPERATOR_GTE, 1), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GTE, 1), + ], + $mock->getFilters('aSource') + ); } public function testGetFiltersBtwe() @@ -1220,9 +1031,9 @@ public function testGetFiltersBtwe() $mock->setData(['operator' => Column::OPERATOR_BTWE, 'from' => 1, 'to' => 10]); $this->assertEquals([ - new Filter(Column::OPERATOR_GTE, 1), - new Filter(Column::OPERATOR_LTE, 10), - ], $mock->getFilters('aSource')); + new Filter(Column::OPERATOR_GTE, 1), + new Filter(Column::OPERATOR_LTE, 10), + ], $mock->getFilters('aSource')); } public function testGetFiltersNullNoNull() @@ -1253,7 +1064,7 @@ public function testGetFiltersLikeCombinationsNoMulti() foreach ($operators as $operator) { $mock->setData(['operator' => $operator]); $this->assertEmpty($mock->getFilters('aSource')); - $this->assertAttributeEquals(Column::DATA_CONJUNCTION, 'dataJunction', $mock); + $this->assertEquals(Column::DATA_CONJUNCTION, $mock->getDataJunction()); } } @@ -1275,7 +1086,7 @@ public function testGetFiltersLikeCombinationsMulti() foreach ($operators as $operator) { $mock->setData(['operator' => $operator]); $this->assertEmpty($mock->getFilters('aSource')); - $this->assertAttributeEquals(Column::DATA_DISJUNCTION, 'dataJunction', $mock); + $this->assertEquals(Column::DATA_DISJUNCTION, $mock->getDataJunction()); } } @@ -1291,11 +1102,14 @@ public function testGetFiltersNotLikeCombination() foreach ($operators as $operator) { $mock->setData(['operator' => $operator, 'from' => [1, 2, 3]]); - $this->assertEquals([ - new Filter($operator, 1), - new Filter($operator, 2), - new Filter($operator, 3), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter($operator, 1), + new Filter($operator, 2), + new Filter($operator, 3), + ], + $mock->getFilters('aSource') + ); } } @@ -1304,23 +1118,31 @@ public function testGetFiltersWithNotHandledOperator() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => 'foo', 'from' => 'bar']); - $this->assertEquals([ - new Filter(Column::OPERATOR_LIKE, 'bar'), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_LIKE, 'bar'), + ], + $mock->getFilters('aSource') + ); } public function testSetOperators() { $mock = $this->getMockForAbstractClass(Column::class); - $mock->setOperators([ - Column::OPERATOR_ISNULL, - Column::OPERATOR_ISNOTNULL, - ]); + $mock->setOperators( + [ + Column::OPERATOR_ISNULL, + Column::OPERATOR_ISNOTNULL, + ] + ); - $this->assertAttributeEquals([ - Column::OPERATOR_ISNULL, - Column::OPERATOR_ISNOTNULL, - ], 'operators', $mock); + $this->assertEquals( + [ + Column::OPERATOR_ISNULL, + Column::OPERATOR_ISNOTNULL, + ], + $mock->getOperators() + ); } public function testGetOperators() @@ -1345,18 +1167,21 @@ public function testItHasDqlFunctionWithMatchesResultArray() $result = []; $this->assertEquals(1, $mock->hasDQLFunction($result)); - $this->assertEquals([ - 0 => 'foo:bar:foobar', - 'all' => 'foo:bar:foobar', - 1 => 'foo:bar:foobar', - 'field' => 'foo', - 2 => 'foo', - 'function' => 'bar', - 3 => 'bar', - 4 => ':', - 'parameters' => 'foobar', - 5 => 'foobar', - ], $result); + $this->assertEquals( + [ + 0 => 'foo:bar:foobar', + 'all' => 'foo:bar:foobar', + 1 => 'foo:bar:foobar', + 'field' => 'foo', + 2 => 'foo', + 'function' => 'bar', + 3 => 'bar', + 4 => ':', + 'parameters' => 'foobar', + 5 => 'foobar', + ], + $result + ); } public function testItHasNotDqlFunctionWithoutMatchesResultArray() From 4d949d3ac264ffe78ef67d707dac3ed66c7d329d Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 15:13:15 -0500 Subject: [PATCH 29/41] Address incorrect route generation issues and remove deprecated function use --- src/Grid/Grid.php | 4 ++++ src/Grid/Row.php | 4 ++++ tests/Grid/GridTest.php | 5 ++--- tests/Grid/RowTest.php | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Grid/Grid.php b/src/Grid/Grid.php index bce8ec91..1408a892 100644 --- a/src/Grid/Grid.php +++ b/src/Grid/Grid.php @@ -1341,6 +1341,10 @@ public function getTweaks() return $this->tweaks; } + public function getAllTweaks(): ?array { + return $this->tweaks; + } + public function getActiveTweaks() { return (array)$this->get('tweaks'); diff --git a/src/Grid/Row.php b/src/Grid/Row.php index aba6056a..14083301 100644 --- a/src/Grid/Row.php +++ b/src/Grid/Row.php @@ -51,6 +51,10 @@ public function setRepository(EntityRepository $repository) $this->repository = $repository; } + public function getRepository(): ?EntityRepository { + return $this->repository; + } + /** * @return null|object */ diff --git a/tests/Grid/GridTest.php b/tests/Grid/GridTest.php index a9ebaf13..7b827cee 100644 --- a/tests/Grid/GridTest.php +++ b/tests/Grid/GridTest.php @@ -101,7 +101,6 @@ public function testInitializeWithoutAnyConfiguration() $this->assertFalse($this->grid->getPersistence()); $this->assertEmpty($this->grid->getRouteParameters()); - $this->assertEmpty($this->grid->getRouteUrl()); $this->assertEmpty($this->grid->getSource()); $this->assertEmpty($this->grid->getDefaultOrder()); $this->assertEmpty($this->grid->getLimits()); @@ -674,7 +673,7 @@ public function testAddTweakWithId() $result = [$id => array_merge(['title' => $title, 'id' => $id, 'group' => $group], $tweak)]; - $this->assertSame($result, $this->grid->getTweaks()); + $this->assertEquals($result, $this->grid->getAllTweaks()); } public function testAddTweakWithoutId() @@ -687,7 +686,7 @@ public function testAddTweakWithoutId() $result = [0 => array_merge(['title' => $title, 'id' => null, 'group' => $group], $tweak)]; - $this->assertSame($result, $this->grid->getTweaks()); + $this->assertEquals($result, $this->grid->getAllTweaks()); } public function testAddRowActionWithoutRole() diff --git a/tests/Grid/RowTest.php b/tests/Grid/RowTest.php index 92f635cc..3e0cede0 100644 --- a/tests/Grid/RowTest.php +++ b/tests/Grid/RowTest.php @@ -21,7 +21,7 @@ public function testSetRepository() $repo = $this->createMock(EntityRepository::class); $this->row->setRepository($repo); - $this->assertAttributeSame($repo, 'repository', $this->row); + $this->assertEquals($repo, $this->row->getRepository()); } public function testSetPrimaryField() From dfd9e9d1ec63e94228d9a78c7e88f3b1899f5014 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 15:34:32 -0500 Subject: [PATCH 30/41] Update phpunit version, remove deprecations --- composer.json | 2 +- tests/Grid/GridTest.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index ffbe09ff..9295a34e 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/tests/Grid/GridTest.php b/tests/Grid/GridTest.php index 7b827cee..ad231ab9 100644 --- a/tests/Grid/GridTest.php +++ b/tests/Grid/GridTest.php @@ -1421,9 +1421,8 @@ public function testCreateHashWithMd5DuringHandleRequest() $this ->request - ->expects($this->at(1)) + ->expects($this->any()) ->method('get') - ->with('_controller') ->willReturn($controller); $this->grid->handleRequest($this->request); @@ -3173,9 +3172,8 @@ public function testCreateHashWithMd5DuringRedirect() $this ->request - ->expects($this->at(0)) + ->expects($this->any()) ->method('get') - ->with('_controller') ->willReturn($controller); $this->grid->isReadyForRedirect(); From 5604fa6c272a6f570d835c307ed8847f7be284c4 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 15:38:03 -0500 Subject: [PATCH 31/41] Cast index for array_slice() --- src/Grid/Columns.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Grid/Columns.php b/src/Grid/Columns.php index d0b0201a..c1fed216 100644 --- a/src/Grid/Columns.php +++ b/src/Grid/Columns.php @@ -57,6 +57,7 @@ public function getIterator($showOnlySourceColumns = false) */ public function addColumn(Column $column, $position = 0) { + $position = (int)$position; $column->setAuthorizationChecker($this->authorizationChecker); if ($position == 0) { From b06195aa845f749542ccc3ef64e5867bc326c50e Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 15:45:04 -0500 Subject: [PATCH 32/41] Add php8.2 to tests, update to run on 22.04, update min php version to be >= 8.0 --- .github/workflows/phpunit.yml | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 65ba6431..de15038a 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -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 diff --git a/composer.json b/composer.json index 9295a34e..5a476865 100644 --- a/composer.json +++ b/composer.json @@ -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", From 61bfc0a5c5effb8438ac53368597e73fe17212f6 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 15:50:55 -0500 Subject: [PATCH 33/41] Add return type --- src/Grid/Column/Column.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Grid/Column/Column.php b/src/Grid/Column/Column.php index e97a21c8..c887e957 100644 --- a/src/Grid/Column/Column.php +++ b/src/Grid/Column/Column.php @@ -240,7 +240,7 @@ public function manipulateRenderCell($callback) return $this; } - public function getCallback() { + public function getCallback(): mixed { return $this->callback; } From db427d851f19b57885d021d53eab838c92bbb66a Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 2 Feb 2023 15:55:25 -0500 Subject: [PATCH 34/41] Formatting --- src/Grid/Mapping/Metadata/Metadata.php | 14 ++++-- tests/Grid/Column/ActionsColumnTest.php | 38 ++++++++------- tests/Grid/Column/ArrayColumnTest.php | 23 ++++++---- tests/Grid/Column/DateColumnTest.php | 11 +++-- tests/Grid/Source/VectorTest.php | 61 ++++++++++++++----------- 5 files changed, 86 insertions(+), 61 deletions(-) diff --git a/src/Grid/Mapping/Metadata/Metadata.php b/src/Grid/Mapping/Metadata/Metadata.php index 84824342..b0270e87 100644 --- a/src/Grid/Mapping/Metadata/Metadata.php +++ b/src/Grid/Mapping/Metadata/Metadata.php @@ -15,8 +15,11 @@ class Metadata { protected $name; + protected $fields; + protected $fieldsMappings; + protected $groupBy; public function setFields($fields) @@ -46,7 +49,8 @@ public function getFieldMapping($field) return $this->fieldsMappings[$field]; } - public function getFieldsMappings(): array { + public function getFieldsMappings(): array + { return $this->fieldsMappings; } @@ -80,13 +84,13 @@ public function getName() } /** - * @todo move to another place - * * @param $columnExtensions * + * @return \SplObjectStorage * @throws \Exception * - * @return \SplObjectStorage + * @todo move to another place + * */ public function getColumnsFromMapping($columnExtensions) { @@ -94,7 +98,7 @@ public function getColumnsFromMapping($columnExtensions) foreach ($this->getFields() as $value) { $params = $this->getFieldMapping($value); - $type = $this->getFieldMappingType($value); + $type = $this->getFieldMappingType($value); /* todo move available extensions from columns */ if ($columnExtensions->hasExtensionForColumnType($type)) { diff --git a/tests/Grid/Column/ActionsColumnTest.php b/tests/Grid/Column/ActionsColumnTest.php index 968bc133..88155a1e 100644 --- a/tests/Grid/Column/ActionsColumnTest.php +++ b/tests/Grid/Column/ActionsColumnTest.php @@ -157,22 +157,26 @@ public function testGetRouteParameters() ->withConsecutive(['foo.bar'], ['barFoo']) ->willReturnOnConsecutiveCalls(null, 'aName'); - $rowAction->method('getRouteParameters')->willReturn([ - 'foo' => 1, - 'foo.bar.foobar' => 2, - 1 => 'foo.bar', - '2' => 'barFoo', - ]); - - $this->assertEquals([ - 'foo' => 1, - 'fooBarFoobar' => 2, - 'fooBar' => 'testValue', - 'aName' => 'aValue', - ], - $this->column->getRouteParameters( - $row, - $rowAction - )); + $rowAction->method('getRouteParameters')->willReturn( + [ + 'foo' => 1, + 'foo.bar.foobar' => 2, + 1 => 'foo.bar', + '2' => 'barFoo', + ] + ); + + $this->assertEquals( + [ + 'foo' => 1, + 'fooBarFoobar' => 2, + 'fooBar' => 'testValue', + 'aName' => 'aValue', + ], + $this->column->getRouteParameters( + $row, + $rowAction + ) + ); } } diff --git a/tests/Grid/Column/ArrayColumnTest.php b/tests/Grid/Column/ArrayColumnTest.php index c2519d42..801e1563 100644 --- a/tests/Grid/Column/ArrayColumnTest.php +++ b/tests/Grid/Column/ArrayColumnTest.php @@ -103,10 +103,14 @@ public function testIsNullFilter() { $this->column->setData(['operator' => Column::OPERATOR_ISNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNULL), - new Filter(Column::OPERATOR_EQ, 'a:0:{}'), - ], $this->column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNULL), + new Filter(Column::OPERATOR_EQ, 'a:0:{}'), + ], + $this->column->getFilters('asource') + ); + $this->assertSame(Column::DATA_DISJUNCTION, $this->column->getDataJunction()); } @@ -114,10 +118,13 @@ public function testIsNotNullFilter() { $this->column->setData(['operator' => Column::OPERATOR_ISNOTNULL]); - $this->assertEquals([ - new Filter(Column::OPERATOR_ISNOTNULL), - new Filter(Column::OPERATOR_NEQ, 'a:0:{}'), - ], $this->column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_ISNOTNULL), + new Filter(Column::OPERATOR_NEQ, 'a:0:{}'), + ], + $this->column->getFilters('asource') + ); } public function testRenderCellWithoutCallback() diff --git a/tests/Grid/Column/DateColumnTest.php b/tests/Grid/Column/DateColumnTest.php index c409ae4a..5cba7ba0 100644 --- a/tests/Grid/Column/DateColumnTest.php +++ b/tests/Grid/Column/DateColumnTest.php @@ -56,10 +56,13 @@ public function testGetFiltersOperatorEq() $this->column->setData(['operator' => Column::OPERATOR_EQ, 'from' => $from, 'to' => $to]); - $this->assertEquals([ - new Filter(Column::OPERATOR_GTE, new \DateTime($from . ' 00:00:00')), - new Filter(Column::OPERATOR_LTE, new \DateTime($from . '23:59:59')), - ], $this->column->getFilters('asource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GTE, new \DateTime($from . ' 00:00:00')), + new Filter(Column::OPERATOR_LTE, new \DateTime($from . '23:59:59')), + ], + $this->column->getFilters('asource') + ); } public function testGetFiltersOperatorNeq() diff --git a/tests/Grid/Source/VectorTest.php b/tests/Grid/Source/VectorTest.php index 705e9b88..4fa7e837 100644 --- a/tests/Grid/Source/VectorTest.php +++ b/tests/Grid/Source/VectorTest.php @@ -75,26 +75,31 @@ public function testInizialiseWithGuessedColumnsMergedToAlreadySettedColumns() $vector = new Vector([['c3Id' => 'c3', 'c4Id' => 'c4']], [$column, $column2]); - $uc1 = new UntypedColumn([ - 'id' => 'c3Id', - 'title' => 'c3Id', - 'source' => true, - 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => 'c3Id', - ]); + $uc1 = new UntypedColumn( + [ + 'id' => 'c3Id', + 'title' => 'c3Id', + 'source' => true, + 'filterable' => true, + 'sortable' => true, + 'visible' => true, + 'field' => 'c3Id', + ] + ); + $uc1->setType('text'); - $uc2 = new UntypedColumn([ - 'id' => 'c4Id', - 'title' => 'c4Id', - 'source' => true, - 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => 'c4Id', - ]); + $uc2 = new UntypedColumn( + [ + 'id' => 'c4Id', + 'title' => 'c4Id', + 'source' => true, + 'filterable' => true, + 'sortable' => true, + 'visible' => true, + 'field' => 'c4Id', + ] + ); $uc2->setType('text'); $vector->initialise($this->createMock(Container::class)); @@ -205,15 +210,17 @@ public function testId() public function guessedColumnProvider() { - $uc = new UntypedColumn([ - 'id' => 'c1Id', - 'title' => 'c1Id', - 'source' => true, - 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => 'c1Id', - ]); + $uc = new UntypedColumn( + [ + 'id' => 'c1Id', + 'title' => 'c1Id', + 'source' => true, + 'filterable' => true, + 'sortable' => true, + 'visible' => true, + 'field' => 'c1Id', + ] + ); $date = new \DateTime(); $date->setTime(0, 0, 0); From 37aa20a66b0661b4799f4053010117884be952d8 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 9 Feb 2023 11:25:05 -0500 Subject: [PATCH 35/41] Remove .idea from .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 011b104b..e01bc6ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /vendor/ -/.idea/ /.phpunit.result.cache /composer.lock /phpunit.xml From c0e6acb25830075ed3b0f91bb17a28a36f862fae Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 9 Feb 2023 11:27:53 -0500 Subject: [PATCH 36/41] Clean up spacing --- tests/Grid/Column/ColumnTest.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/Grid/Column/ColumnTest.php b/tests/Grid/Column/ColumnTest.php index cf3cc342..f29d3ac2 100644 --- a/tests/Grid/Column/ColumnTest.php +++ b/tests/Grid/Column/ColumnTest.php @@ -1007,9 +1007,12 @@ public function testGetFiltersBtweWithoutFrom() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_BTWE, 'to' => 10]); - $this->assertEquals([ - new Filter(Column::OPERATOR_LTE, 10), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_LTE, 10), + ], + $mock->getFilters('aSource') + ); } public function testGetFiltersBtweWithoutTo() @@ -1030,10 +1033,13 @@ public function testGetFiltersBtwe() $mock = $this->getMockForAbstractClass(Column::class); $mock->setData(['operator' => Column::OPERATOR_BTWE, 'from' => 1, 'to' => 10]); - $this->assertEquals([ - new Filter(Column::OPERATOR_GTE, 1), - new Filter(Column::OPERATOR_LTE, 10), - ], $mock->getFilters('aSource')); + $this->assertEquals( + [ + new Filter(Column::OPERATOR_GTE, 1), + new Filter(Column::OPERATOR_LTE, 10), + ], + $mock->getFilters('aSource') + ); } public function testGetFiltersNullNoNull() From 9dfcd3a7b8644d0c233405694235753160b4b01e Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 22 Jun 2023 10:52:36 -0400 Subject: [PATCH 37/41] Clean up --- src/Grid/Column/Column.php | 25 ++++++++++++++----------- src/Grid/Columns.php | 3 +-- src/Grid/Grid.php | 6 +++--- src/Grid/Row.php | 5 +++-- src/Grid/Source/Vector.php | 35 ++++++++++++++--------------------- 5 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/Grid/Column/Column.php b/src/Grid/Column/Column.php index c887e957..9ff03c50 100644 --- a/src/Grid/Column/Column.php +++ b/src/Grid/Column/Column.php @@ -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) @@ -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 @@ -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]; } @@ -240,7 +240,8 @@ public function manipulateRenderCell($callback) return $this; } - public function getCallback(): mixed { + public function getCallback(): ?\Closure + { return $this->callback; } @@ -567,7 +568,8 @@ public function getData() return $result; } - public function getDataAttribute(): array { + public function getDataAttribute(): array + { return $this->data; } @@ -700,7 +702,7 @@ public function setFilterType($filterType) { $this->filterType = strtolower($filterType); - return $this; + return $this; } public function getFilterType() @@ -750,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; @@ -806,7 +808,7 @@ public function getOperators() self::OPERATOR_GT, self::OPERATOR_GTE, self::OPERATOR_BTW, - self::OPERATOR_BTWE, ]); + self::OPERATOR_BTWE,]); } return $this->operators; @@ -918,7 +920,8 @@ public function setAuthorizationChecker(AuthorizationCheckerInterface $authoriza return $this; } - public function getAuthorizationChecker(): ?AuthorizationCheckerInterface { + public function getAuthorizationChecker(): ?AuthorizationCheckerInterface + { return $this->authorizationChecker; } diff --git a/src/Grid/Columns.php b/src/Grid/Columns.php index c1fed216..91669297 100644 --- a/src/Grid/Columns.php +++ b/src/Grid/Columns.php @@ -55,9 +55,8 @@ public function getIterator($showOnlySourceColumns = false) * * @return Columns */ - public function addColumn(Column $column, $position = 0) + public function addColumn(Column $column, int $position = 0) { - $position = (int)$position; $column->setAuthorizationChecker($this->authorizationChecker); if ($position == 0) { diff --git a/src/Grid/Grid.php b/src/Grid/Grid.php index 1408a892..2d63c2e6 100644 --- a/src/Grid/Grid.php +++ b/src/Grid/Grid.php @@ -1341,7 +1341,7 @@ public function getTweaks() return $this->tweaks; } - public function getAllTweaks(): ?array { + public function getAllTweaks(): array { return $this->tweaks; } @@ -1788,7 +1788,7 @@ public function setDefaultTweak($tweakId) return $this; } - public function getDefaultTweak(): ?string + public function getDefaultTweak(): string { return $this->defaultTweak; } @@ -1879,7 +1879,7 @@ public function setMaxResults($maxResults = null) return $this; } - public function getMaxResults() + public function getMaxResults(): int { return $this->maxResults; } diff --git a/src/Grid/Row.php b/src/Grid/Row.php index 14083301..c9d6ceb0 100644 --- a/src/Grid/Row.php +++ b/src/Grid/Row.php @@ -40,7 +40,7 @@ class Row public function __construct() { $this->fields = []; - $this->color = ''; + $this->color = ''; } /** @@ -51,7 +51,8 @@ public function setRepository(EntityRepository $repository) $this->repository = $repository; } - public function getRepository(): ?EntityRepository { + public function getRepository(): ?EntityRepository + { return $this->repository; } diff --git a/src/Grid/Source/Vector.php b/src/Grid/Source/Vector.php index a72f322e..1540765f 100644 --- a/src/Grid/Source/Vector.php +++ b/src/Grid/Source/Vector.php @@ -74,18 +74,18 @@ public function initialise($container) protected function guessColumns() { $guessedColumns = []; - $dataColumnIds = array_keys(reset($this->data)); + $dataColumnIds = array_keys(reset($this->data)); foreach ($dataColumnIds as $id) { if (!$this->hasColumn($id)) { - $params = [ - 'id' => $id, - 'title' => $id, - 'source' => true, + $params = [ + 'id' => $id, + 'title' => $id, + 'source' => true, 'filterable' => true, - 'sortable' => true, - 'visible' => true, - 'field' => $id, + 'sortable' => true, + 'visible' => true, + 'field' => $id, ]; $guessedColumns[] = new UntypedColumn($params); } @@ -101,7 +101,7 @@ protected function guessColumns() continue; } - $i = 0; + $i = 0; $fieldTypes = []; foreach ($this->data as $row) { @@ -199,10 +199,10 @@ public function getColumns($columns) /** * @param \APY\DataGridBundle\Grid\Column\Column[] $columns - * @param int $page Page Number - * @param int $limit Rows Per Page - * @param int $maxResults Max rows - * @param int $gridDataJunction Grid data junction + * @param int $page Page Number + * @param int $limit Rows Per Page + * @param int $maxResults Max rows + * @param int $gridDataJunction Grid data junction * * @return Rows */ @@ -223,14 +223,7 @@ public function getTotalCount($maxResults = null) public function getHash() { - return __CLASS__ . md5( - implode( - '', - array_map(function ($c) { - return $c->getId(); - }, $this->columns) - ) - ); + return __CLASS__ . md5(implode('', array_map(fn($c) => $c->getId(), $this->columns))); } /** From 38666a734d84a8c2676e0ab6495769c02350e7ac Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 22 Jun 2023 10:55:15 -0400 Subject: [PATCH 38/41] Updates to pass tests --- src/Grid/Grid.php | 2 +- tests/Grid/ColumnsTest.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Grid/Grid.php b/src/Grid/Grid.php index 2d63c2e6..863f6514 100644 --- a/src/Grid/Grid.php +++ b/src/Grid/Grid.php @@ -1879,7 +1879,7 @@ public function setMaxResults($maxResults = null) return $this; } - public function getMaxResults(): int + public function getMaxResults(): ?int { return $this->maxResults; } diff --git a/tests/Grid/ColumnsTest.php b/tests/Grid/ColumnsTest.php index ffc77114..61428aaf 100644 --- a/tests/Grid/ColumnsTest.php +++ b/tests/Grid/ColumnsTest.php @@ -44,8 +44,7 @@ public function testAddColumnsOrder() ->addColumn($column1) ->addColumn($column2, 1) ->addColumn($column3, 2) - ->addColumn($column4, -1) - ->addColumn($column5, 'foo'); + ->addColumn($column4, -1); $this->assertSame([$column2, $column3, $column4, $column1, $column5], iterator_to_array($this->columns->getIterator())); } From 50876bfcef24cebb9ea44d5cf4c167776d0fa68f Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 22 Jun 2023 10:58:02 -0400 Subject: [PATCH 39/41] Remvoe test --- tests/Grid/GridTest.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/Grid/GridTest.php b/tests/Grid/GridTest.php index ad231ab9..bb8cdd69 100644 --- a/tests/Grid/GridTest.php +++ b/tests/Grid/GridTest.php @@ -1084,15 +1084,6 @@ public function testSetMaxResultWithInvalidValueRaiseException() $this->grid->setMaxResults(-1); } - // @todo: has this case sense? Should not raise exception? - public function testSetMaxResultWithStringValue() - { - $maxResult = 'foo'; - $this->grid->setMaxResults($maxResult); - - $this->assertSame($maxResult, $this->grid->getMaxResults()); - } - public function testSetMaxResult() { $maxResult = 1; From 69da3814a4246359fc4372b5c4fb415d2c5287b9 Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 22 Jun 2023 11:33:02 -0400 Subject: [PATCH 40/41] Remove unused column from test --- tests/Grid/ColumnsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Grid/ColumnsTest.php b/tests/Grid/ColumnsTest.php index 61428aaf..35975fa1 100644 --- a/tests/Grid/ColumnsTest.php +++ b/tests/Grid/ColumnsTest.php @@ -38,7 +38,7 @@ public function testAddColumn() public function testAddColumnsOrder() { - [$column1, $column2, $column3, $column4, $column5] = $this->buildColumnMocks(5); + [$column1, $column2, $column3, $column4] = $this->buildColumnMocks(5); $this->columns ->addColumn($column1) @@ -46,7 +46,7 @@ public function testAddColumnsOrder() ->addColumn($column3, 2) ->addColumn($column4, -1); - $this->assertSame([$column2, $column3, $column4, $column1, $column5], iterator_to_array($this->columns->getIterator())); + $this->assertSame([$column2, $column3, $column4, $column1], iterator_to_array($this->columns->getIterator())); } public function testRaiseExceptionIfGetColumnByIdDoesNotExists() From 50888d2c969758e626cc2b638155f34930e6025b Mon Sep 17 00:00:00 2001 From: Cody deVries Date: Thu, 22 Jun 2023 12:16:16 -0400 Subject: [PATCH 41/41] Build the correct number of mock columns --- tests/Grid/ColumnsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Grid/ColumnsTest.php b/tests/Grid/ColumnsTest.php index 35975fa1..a98d7513 100644 --- a/tests/Grid/ColumnsTest.php +++ b/tests/Grid/ColumnsTest.php @@ -38,7 +38,7 @@ public function testAddColumn() public function testAddColumnsOrder() { - [$column1, $column2, $column3, $column4] = $this->buildColumnMocks(5); + [$column1, $column2, $column3, $column4] = $this->buildColumnMocks(4); $this->columns ->addColumn($column1)