Skip to content

Commit 523eaa7

Browse files
committed
Added testing files
1 parent aa2b641 commit 523eaa7

6 files changed

+142
-4
lines changed

.travis.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
language: php
2+
3+
env:
4+
global:
5+
- COMPOSER_ROOT_VERSION=4.0.x-dev
6+
- CODECOV_TOKEN=
7+
- SCRUT_TOKEN=
8+
9+
matrix:
10+
include:
11+
- php: 7.1
12+
env: DB=MYSQL PHPUNIT_TEST=1
13+
- php: 7.2
14+
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
15+
- php: 7.3
16+
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
17+
18+
before_script:
19+
# Init PHP
20+
- phpenv rehash
21+
- phpenv config-rm xdebug.ini
22+
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
23+
24+
# Install composer dependencies
25+
- composer require --prefer-dist --no-update silverstripe-themes/simple:~3.2
26+
- composer update --no-suggest --prefer-dist
27+
28+
script:
29+
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
30+
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml && wget https://scrutinizer-ci.com/ocular.phar; fi
31+
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi
32+
33+
after_success:
34+
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -t $CODECOV_TOKEN && travis_retry php ocular.phar code-coverage:upload --format=php-clover --access-token=$SCRUT_TOKEN coverage.xml; fi

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# SilverStripe GridField Groupable
2+
[![Build Status](https://travis-ci.org/micschk/silverstripe-groupable-gridfield.svg?branch=master)](https://travis-ci.org/micschk/silverstripe-groupable-gridfield)
3+
[![codecov.io](https://codecov.io/github/micschk/silverstripe-groupable-gridfield/coverage.svg?branch=master)](https://codecov.io/github/micschk/silverstripe-groupable-gridfield?branch=master)
24

35
This module allows drag & drop grouping of items in a GridField.
46
It bolts on top of- and depends on GridFieldOrderableRows for the drag & drop sorting functionality
@@ -17,7 +19,7 @@ Example application (Block Enhancements module): assign content blocks to block-
1719

1820
### Requirements (all pulled in by composer)
1921

20-
* SilverStripe CMS ~3.1
22+
* SilverStripe Framework ~4.0
2123
* SilverStripe GridFieldExtensions
2224

2325
## Usage:

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
],
1717
"license": "MIT",
1818
"require": {
19-
"silverstripe/framework": "^4.0",
2019
"silverstripe/vendor-plugin": "^1.0",
21-
"symbiote/silverstripe-gridfieldextensions": "^3",
22-
"ext-json": "*"
20+
"symbiote/silverstripe-gridfieldextensions": "^3"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^5.7",
24+
"squizlabs/php_codesniffer": "*"
2325
},
2426
"suggest": {
2527
"micschk/silverstripe-block_enhancements": "Enhancements to the Silverstripe Blocks module"

phpcs.xml.dist

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="SS4">
3+
<description>Coding standard for SilverStripe 4.x</description>
4+
5+
<!-- Don't sniff third party libraries -->
6+
<exclude-pattern>*/vendor/*</exclude-pattern>
7+
<exclude-pattern>*/thirdparty/*</exclude-pattern>
8+
9+
<!-- Show progress and output sniff names on violation, and add colours -->
10+
<arg value="sp"/>
11+
<arg name="colors"/>
12+
13+
<!-- Use PSR-2 as a base standard -->
14+
<rule ref="PSR2">
15+
<!-- Allow classes to not declare a namespace -->
16+
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
17+
18+
<!-- Allow underscores in class names -->
19+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
20+
21+
<!-- Allow non camel cased method names -->
22+
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
23+
</rule>
24+
</ruleset>

phpunit.xml.dist

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
2+
<testsuite name="groupalble-gridfield">
3+
<directory>tests</directory>
4+
</testsuite>
5+
6+
<filter>
7+
<whitelist addUncoveredFilesFromWhitelist="true">
8+
<directory suffix=".php">src/</directory>
9+
<exclude>
10+
<directory suffix=".php">tests/</directory>
11+
</exclude>
12+
</whitelist>
13+
</filter>
14+
</phpunit>

tests/GridFieldGroupableTest.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace micschk\GroupableGridfield\Test;
4+
5+
use micschk\GroupableGridfield\GridFieldGroupable;
6+
use SilverStripe\Dev\SapphireTest;
7+
use SilverStripe\ORM\DataObject;
8+
9+
/**
10+
* Class GridFieldGroupableTest
11+
*/
12+
class GridFieldGroupableTest extends SapphireTest
13+
{
14+
15+
/**
16+
*
17+
*/
18+
public function testGetURLHandlers()
19+
{
20+
$groupable = new GridFieldGroupable();
21+
$this->assertInternalType('array', $groupable->getURLHandlers(null));
22+
}
23+
24+
/**
25+
*
26+
*/
27+
public function testGetColumnsHandled()
28+
{
29+
$groupable = new GridFieldGroupable();
30+
$this->assertInternalType('array', $groupable->getColumnsHandled(null));
31+
}
32+
33+
/**
34+
*
35+
*/
36+
public function testGetColumnContent()
37+
{
38+
$groupable = new GridFieldGroupable();
39+
$this->assertNull($groupable->getColumnContent(null, null, ''));
40+
}
41+
42+
/**
43+
*
44+
*/
45+
public function testGetColumnAttributes()
46+
{
47+
$groupable = new GridFieldGroupable('ID');
48+
$record = DataObject::create();
49+
$attributes = $groupable->getColumnAttributes(null, $record, null);
50+
$this->assertInternalType('array', $attributes);
51+
$this->assertArrayHasKey('data-groupable-group', $attributes);
52+
}
53+
54+
/**
55+
*
56+
*/
57+
public function testGetColumnMetadata()
58+
{
59+
$groupable = new GridFieldGroupable();
60+
$this->assertInternalType('array', $groupable->getColumnMetadata(null,''));
61+
}
62+
}

0 commit comments

Comments
 (0)