mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Merge pull request #209 from creative-commoners/pulls/3.0/new-travis-config
FIX New Travis configuration, linting and updating existing skipped unit tests
This commit is contained in:
commit
f764303ed0
45
.travis.yml
45
.travis.yml
@ -1,28 +1,31 @@
|
|||||||
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
dist: precise
|
|
||||||
|
|
||||||
php:
|
|
||||||
- 5.6
|
|
||||||
- 7.0
|
|
||||||
- 7.1
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DB=MYSQL CORE_RELEASE=4
|
global:
|
||||||
- DB=PGSQL CORE_RELEASE=4
|
- COMPOSER_ROOT_VERSION="4.0.x-dev"
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- php: 5.6
|
||||||
|
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||||
|
- php: 7.0
|
||||||
|
env: DB=PGSQL PHPUNIT_TEST=1
|
||||||
|
- php: 7.1
|
||||||
|
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update || true
|
- phpenv rehash
|
||||||
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
- phpenv config-rm xdebug.ini
|
||||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
|
||||||
- cd ~/builds/ss
|
- composer validate
|
||||||
- composer install --prefer-dist --no-progress --no-suggest
|
- composer require silverstripe/recipe-core 1.0.x-dev --no-update
|
||||||
- composer require silverstripe/versioned:1.x-dev --prefer-dist --no-progress --no-suggest
|
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi
|
||||||
- composer dump-autoload --optimize
|
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit gridfieldextensions/tests
|
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi
|
||||||
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
||||||
|
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=framework/phpcs.xml.dist src/ tests/ ; fi
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
||||||
|
1
codecov.yml
Normal file
1
codecov.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
comment: false
|
@ -22,7 +22,9 @@
|
|||||||
"silverstripe/framework": "~4.0"
|
"silverstripe/framework": "~4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.7"
|
"phpunit/phpunit": "^5.7",
|
||||||
|
"squizlabs/php_codesniffer": "^3.0",
|
||||||
|
"silverstripe/versioned": "^1@dev"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"installer-name": "gridfieldextensions",
|
"installer-name": "gridfieldextensions",
|
||||||
@ -40,7 +42,8 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Symbiote\\GridFieldExtensions\\": "src/"
|
"Symbiote\\GridFieldExtensions\\": "src/",
|
||||||
|
"Symbiote\\GridFieldExtensions\\Tests\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
14
phpunit.xml.dist
Normal file
14
phpunit.xml.dist
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<phpunit bootstrap="framework/tests/bootstrap.php" colors="true">
|
||||||
|
<testsuite name="Default">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">src/</directory>
|
||||||
|
<exclude>
|
||||||
|
<directory suffix=".php">tests/</directory>
|
||||||
|
</exclude>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
@ -158,7 +158,7 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sanitised = array();
|
$sanitised = array();
|
||||||
foreach($result as $class=>$title) {
|
foreach ($result as $class => $title) {
|
||||||
$sanitised[$this->sanitiseClassName($class)] = $title;
|
$sanitised[$this->sanitiseClassName($class)] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,11 +516,11 @@ class GridFieldOrderableRows extends RequestHandler implements
|
|||||||
$sortTable = $this->getSortTable($list);
|
$sortTable = $this->getSortTable($list);
|
||||||
$additionalSQL = '';
|
$additionalSQL = '';
|
||||||
$baseTable = $sortTable;
|
$baseTable = $sortTable;
|
||||||
if(class_exists($sortTable)) {
|
if (class_exists($sortTable)) {
|
||||||
$baseTable = singleton($sortTable)->baseTable();
|
$baseTable = singleton($sortTable)->baseTable();
|
||||||
}
|
}
|
||||||
$isBaseTable = ($baseTable == $sortTable);
|
$isBaseTable = ($baseTable == $sortTable);
|
||||||
if(!$list instanceof ManyManyList && $isBaseTable){
|
if (!$list instanceof ManyManyList && $isBaseTable) {
|
||||||
$additionalSQL = ', "LastEdited" = NOW()';
|
$additionalSQL = ', "LastEdited" = NOW()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ class GridFieldOrderableRows extends RequestHandler implements
|
|||||||
$this->getSortTableClauseForIds($list, $id)
|
$this->getSortTableClauseForIds($list, $id)
|
||||||
));
|
));
|
||||||
|
|
||||||
if(!$isBaseTable) {
|
if (!$isBaseTable) {
|
||||||
DB::query(sprintf(
|
DB::query(sprintf(
|
||||||
'UPDATE "%s" SET "LastEdited" = NOW() WHERE %s',
|
'UPDATE "%s" SET "LastEdited" = NOW() WHERE %s',
|
||||||
$baseTable,
|
$baseTable,
|
||||||
@ -570,11 +570,11 @@ class GridFieldOrderableRows extends RequestHandler implements
|
|||||||
|
|
||||||
$additionalSQL = '';
|
$additionalSQL = '';
|
||||||
$baseTable = $table;
|
$baseTable = $table;
|
||||||
if(class_exists($table)) {
|
if (class_exists($table)) {
|
||||||
$baseTable = singleton($table)->baseTable();
|
$baseTable = singleton($table)->baseTable();
|
||||||
}
|
}
|
||||||
$isBaseTable = ($baseTable == $table);
|
$isBaseTable = ($baseTable == $table);
|
||||||
if(!$list instanceof ManyManyList && $isBaseTable){
|
if (!$list instanceof ManyManyList && $isBaseTable) {
|
||||||
$additionalSQL = ', "LastEdited" = NOW()';
|
$additionalSQL = ', "LastEdited" = NOW()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ class GridFieldOrderableRows extends RequestHandler implements
|
|||||||
$this->getSortTableClauseForIds($list, $id)
|
$this->getSortTableClauseForIds($list, $id)
|
||||||
));
|
));
|
||||||
|
|
||||||
if(!$isBaseTable) {
|
if (!$isBaseTable) {
|
||||||
DB::query(sprintf(
|
DB::query(sprintf(
|
||||||
'UPDATE "%s" SET "LastEdited" = NOW() WHERE %s',
|
'UPDATE "%s" SET "LastEdited" = NOW() WHERE %s',
|
||||||
$baseTable,
|
$baseTable,
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests;
|
||||||
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
|
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
|
||||||
|
use Symbiote\GridFieldExtensions\Tests\Stub\StubA;
|
||||||
|
use Symbiote\GridFieldExtensions\Tests\Stub\StubB;
|
||||||
|
use Symbiote\GridFieldExtensions\Tests\Stub\StubC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link GridFieldAddNewMultiClass}.
|
* Tests for {@link GridFieldAddNewMultiClass}.
|
||||||
@ -14,59 +19,32 @@ class GridFieldAddNewMultiClassTest extends SapphireTest
|
|||||||
public function testGetClasses()
|
public function testGetClasses()
|
||||||
{
|
{
|
||||||
$grid = new GridField('TestGridField');
|
$grid = new GridField('TestGridField');
|
||||||
$grid->setModelClass('GridFieldAddNewMultiClassTest_A');
|
$grid->setModelClass(StubA::class);
|
||||||
|
|
||||||
$component = new GridFieldAddNewMultiClass();
|
$component = new GridFieldAddNewMultiClass();
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
'GridFieldAddNewMultiClassTest_A' => 'A',
|
'Symbiote-GridFieldExtensions-Tests-Stub-StubA' => 'A',
|
||||||
'GridFieldAddNewMultiClassTest_B' => 'B',
|
'Symbiote-GridFieldExtensions-Tests-Stub-StubB' => 'B',
|
||||||
'GridFieldAddNewMultiClassTest_C' => 'C'
|
'Symbiote-GridFieldExtensions-Tests-Stub-StubC' => 'C'
|
||||||
),
|
),
|
||||||
$component->getClasses($grid),
|
$component->getClasses($grid),
|
||||||
'Subclasses are populated by default and sorted'
|
'Subclasses are populated by default and sorted'
|
||||||
);
|
);
|
||||||
|
|
||||||
$component->setClasses(array(
|
$component->setClasses(array(
|
||||||
'GridFieldAddNewMultiClassTest_B' => 'Custom Title',
|
StubB::class => 'Custom Title',
|
||||||
'GridFieldAddNewMultiClassTest_A'
|
StubA::class
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
'GridFieldAddNewMultiClassTest_B' => 'Custom Title',
|
'Symbiote-GridFieldExtensions-Tests-Stub-StubB' => 'Custom Title',
|
||||||
'GridFieldAddNewMultiClassTest_A' => 'A'
|
'Symbiote-GridFieldExtensions-Tests-Stub-StubA' => 'A'
|
||||||
),
|
),
|
||||||
$component->getClasses($grid),
|
$component->getClasses($grid),
|
||||||
'Sorting and custom titles can be specified'
|
'Sorting and custom titles can be specified'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
|
|
||||||
class GridFieldAddNewMultiClassTest_A implements TestOnly
|
|
||||||
{
|
|
||||||
public function i18n_singular_name()
|
|
||||||
{
|
|
||||||
$class = get_class($this);
|
|
||||||
return substr($class, strpos($class, '_') + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function canCreate()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GridFieldAddNewMultiClassTest_B extends GridFieldAddNewMultiClassTest_A implements TestOnly
|
|
||||||
{
|
|
||||||
}
|
|
||||||
class GridFieldAddNewMultiClassTest_C extends GridFieldAddNewMultiClassTest_A implements TestOnly
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**#@-*/
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Symbiote\Test;
|
namespace Symbiote\GridFieldExtensions\Tests;
|
||||||
|
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
@ -12,55 +12,42 @@ use SilverStripe\Forms\GridField\GridField;
|
|||||||
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||||
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
|
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
|
||||||
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClassHandler;
|
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClassHandler;
|
||||||
|
use Symbiote\GridFieldExtensions\Tests\Stub\NamespacedClass;
|
||||||
|
|
||||||
class GridFieldAddNewMultiClassWithNamespacesTest extends SapphireTest {
|
class GridFieldAddNewMultiClassWithNamespacesTest extends SapphireTest
|
||||||
|
{
|
||||||
|
|
||||||
public function testGetClassesWithNamespaces() {
|
public function testGetClassesWithNamespaces()
|
||||||
$grid = new GridField('TestGridField');
|
{
|
||||||
$grid->setModelClass('Symbiote\\Test\\NamespacedClass');
|
$grid = new GridField('TestGridField');
|
||||||
|
$grid->setModelClass(NamespacedClass::class);
|
||||||
|
|
||||||
$component = new GridFieldAddNewMultiClass();
|
$component = new GridFieldAddNewMultiClass();
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
'Symbiote-Test-NamespacedClass' => 'NamespacedClass'
|
'Symbiote-GridFieldExtensions-Tests-Stub-NamespacedClass' => 'NamespacedClass'
|
||||||
),
|
),
|
||||||
$component->getClasses($grid),
|
$component->getClasses($grid),
|
||||||
'Namespaced classes are sanitised'
|
'Namespaced classes are sanitised'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandleAddWithNamespaces() {
|
public function testHandleAddWithNamespaces()
|
||||||
$grid = new GridField('TestGridField');
|
{
|
||||||
$grid->getConfig()->addComponent(new GridFieldDetailForm());
|
$grid = new GridField('TestGridField');
|
||||||
$grid->setModelClass('Symbiote\\Test\\NamespacedClass');
|
$grid->getConfig()->addComponent(new GridFieldDetailForm());
|
||||||
$grid->setForm(Form::create(Controller::create(), 'test', FieldList::create(), FieldList::create()));
|
$grid->setModelClass(NamespacedClass::class);
|
||||||
|
$grid->setForm(Form::create(Controller::create(), 'test', FieldList::create(), FieldList::create()));
|
||||||
|
|
||||||
$request = new HTTPRequest('POST', 'test');
|
$request = new HTTPRequest('POST', 'test');
|
||||||
$request->setRouteParams(array('ClassName' => 'Symbiote-Test-NamespacedClass'));
|
$request->setRouteParams(array('ClassName' => 'Symbiote-GridFieldExtensions-Tests-Stub-NamespacedClass'));
|
||||||
|
|
||||||
$component = new GridFieldAddNewMultiClass();
|
$component = new GridFieldAddNewMultiClass();
|
||||||
$response = $component->handleAdd($grid, $request);
|
$response = $component->handleAdd($grid, $request);
|
||||||
|
|
||||||
$record = new \ReflectionProperty(GridFieldAddNewMultiClassHandler::class, 'record');
|
|
||||||
$record->setAccessible(true);
|
|
||||||
$this->assertInstanceOf('Symbiote\\Test\\NamespacedClass', $record->getValue($response));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$record = new \ReflectionProperty(GridFieldAddNewMultiClassHandler::class, 'record');
|
||||||
|
$record->setAccessible(true);
|
||||||
|
$this->assertInstanceOf(NamespacedClass::class, $record->getValue($response));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
|
|
||||||
class NamespacedClass implements TestOnly {
|
|
||||||
public function i18n_singular_name() {
|
|
||||||
return 'NamespacedClass';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function canCreate() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**#@-*/
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests;
|
||||||
|
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests;
|
||||||
|
|
||||||
|
use ReflectionMethod;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Dev\TestOnly;
|
|
||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
|
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
|
||||||
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
|
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
|
||||||
use SilverStripe\ORM\DataObject;
|
use Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered;
|
||||||
|
use Symbiote\GridFieldExtensions\Tests\Stub\StubParent;
|
||||||
|
use Symbiote\GridFieldExtensions\Tests\Stub\StubSubclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link GridFieldOrderableRows} component.
|
* Tests for the {@link GridFieldOrderableRows} component.
|
||||||
@ -15,27 +19,21 @@ class GridFieldOrderableRowsTest extends SapphireTest
|
|||||||
|
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
// protected static $fixture_file = 'GridFieldOrderableRowsTest.yml';
|
protected static $fixture_file = 'GridFieldOrderableRowsTest.yml';
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected static $extra_dataobjects = array(
|
||||||
'GridFieldOrderableRowsTest_Parent',
|
StubParent::class,
|
||||||
'GridFieldOrderableRowsTest_Ordered',
|
StubOrdered::class,
|
||||||
'GridFieldOrderableRowsTest_Subclass',
|
StubSubclass::class,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->markTestSkipped('Upgrade to 4.0: Needs to be re-implemented.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testReorderItems()
|
public function testReorderItems()
|
||||||
{
|
{
|
||||||
$orderable = new GridFieldOrderableRows('ManyManySort');
|
$orderable = new GridFieldOrderableRows('ManyManySort');
|
||||||
$reflection = new ReflectionMethod($orderable, 'executeReorder');
|
$reflection = new ReflectionMethod($orderable, 'executeReorder');
|
||||||
$reflection->setAccessible(true);
|
$reflection->setAccessible(true);
|
||||||
|
|
||||||
$parent = $this->objFromFixture('GridFieldOrderableRowsTest_Parent', 'parent');
|
$parent = $this->objFromFixture(StubParent::class, 'parent');
|
||||||
|
|
||||||
$config = new GridFieldConfig_RelationEditor();
|
$config = new GridFieldConfig_RelationEditor();
|
||||||
$config->addComponent($orderable);
|
$config->addComponent($orderable);
|
||||||
@ -71,70 +69,27 @@ class GridFieldOrderableRowsTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
$orderable = new GridFieldOrderableRows();
|
$orderable = new GridFieldOrderableRows();
|
||||||
|
|
||||||
$parent = new GridFieldOrderableRowsTest_Parent();
|
$parent = new StubParent();
|
||||||
$parent->write();
|
$parent->write();
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'GridFieldOrderableRowsTest_Ordered',
|
'StubOrdered',
|
||||||
$orderable->getSortTable($parent->MyHasMany())
|
$orderable->getSortTable($parent->MyHasMany())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'GridFieldOrderableRowsTest_Ordered',
|
'StubOrdered',
|
||||||
$orderable->getSortTable($parent->MyHasManySubclass())
|
$orderable->getSortTable($parent->MyHasManySubclass())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'GridFieldOrderableRowsTest_Ordered',
|
'StubOrdered',
|
||||||
$orderable->getSortTable($parent->MyManyMany())
|
$orderable->getSortTable($parent->MyManyMany())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'GridFieldOrderableRowsTest_Parent_MyManyMany',
|
'StubParent_MyManyMany',
|
||||||
$orderable->setSortField('ManyManySort')->getSortTable($parent->MyManyMany())
|
$orderable->setSortField('ManyManySort')->getSortTable($parent->MyManyMany())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
|
|
||||||
class GridFieldOrderableRowsTest_Parent extends DataObject implements TestOnly
|
|
||||||
{
|
|
||||||
|
|
||||||
private static $has_many = array(
|
|
||||||
'MyHasMany' => 'GridFieldOrderableRowsTest_Ordered',
|
|
||||||
'MyHasManySubclass' => 'GridFieldOrderableRowsTest_Subclass'
|
|
||||||
);
|
|
||||||
|
|
||||||
private static $many_many = array(
|
|
||||||
'MyManyMany' => 'GridFieldOrderableRowsTest_Ordered'
|
|
||||||
);
|
|
||||||
|
|
||||||
private static $many_many_extraFields = array(
|
|
||||||
'MyManyMany' => array('ManyManySort' => 'Int')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class GridFieldOrderableRowsTest_Ordered extends DataObject implements TestOnly
|
|
||||||
{
|
|
||||||
|
|
||||||
private static $db = array(
|
|
||||||
'Sort' => 'Int'
|
|
||||||
);
|
|
||||||
|
|
||||||
private static $has_one = array(
|
|
||||||
'Parent' => 'GridFieldOrderableRowsTest_Parent'
|
|
||||||
);
|
|
||||||
|
|
||||||
private static $belongs_many_many =array(
|
|
||||||
'MyManyMany' => 'GridFieldOrderableRowsTest_Parent',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class GridFieldOrderableRowsTest_Subclass extends GridFieldOrderableRowsTest_Ordered implements TestOnly
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**#@-*/
|
|
||||||
|
@ -1,22 +1,29 @@
|
|||||||
GridFieldOrderableRowsTest_Ordered:
|
Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered:
|
||||||
item1:
|
item1:
|
||||||
|
Sort: 1
|
||||||
item2:
|
item2:
|
||||||
|
Sort: 2
|
||||||
item3:
|
item3:
|
||||||
|
Sort: 3
|
||||||
item4:
|
item4:
|
||||||
|
Sort: 4
|
||||||
item5:
|
item5:
|
||||||
|
Sort: 5
|
||||||
item6:
|
item6:
|
||||||
GridFieldOrderableRowsTest_Parent:
|
Sort: 6
|
||||||
|
|
||||||
|
Symbiote\GridFieldExtensions\Tests\Stub\StubParent:
|
||||||
parent:
|
parent:
|
||||||
MyManyMany:
|
MyManyMany:
|
||||||
- 0: =>GridFieldOrderableRowsTest_Ordered.item1
|
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item1:
|
||||||
ManyManySort: 1
|
ManyManySort: 1
|
||||||
- 1: =>GridFieldOrderableRowsTest_Ordered.item2
|
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item2:
|
||||||
ManyManySort: 1
|
ManyManySort: 1
|
||||||
- 2: =>GridFieldOrderableRowsTest_Ordered.item3
|
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item3:
|
||||||
ManyManySort: 2
|
ManyManySort: 2
|
||||||
- 3: =>GridFieldOrderableRowsTest_Ordered.item4
|
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item4:
|
||||||
ManyManySort: 2
|
ManyManySort: 2
|
||||||
- 4: =>GridFieldOrderableRowsTest_Ordered.item5
|
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item5:
|
||||||
ManyManySort: 108
|
ManyManySort: 108
|
||||||
- 5: =>GridFieldOrderableRowsTest_Ordered.item6
|
- =>Symbiote\GridFieldExtensions\Tests\Stub\StubOrdered.item6:
|
||||||
ManyManySort: 108
|
ManyManySort: 108
|
||||||
|
18
tests/Stub/NamespacedClass.php
Normal file
18
tests/Stub/NamespacedClass.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use Silverstripe\Dev\TestOnly;
|
||||||
|
|
||||||
|
class NamespacedClass implements TestOnly
|
||||||
|
{
|
||||||
|
public function i18n_singular_name()
|
||||||
|
{
|
||||||
|
return 'NamespacedClass';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canCreate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
19
tests/Stub/StubA.php
Normal file
19
tests/Stub/StubA.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
|
||||||
|
class StubA implements TestOnly
|
||||||
|
{
|
||||||
|
public function i18n_singular_name()
|
||||||
|
{
|
||||||
|
$class = get_class($this);
|
||||||
|
return substr($class, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canCreate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
9
tests/Stub/StubB.php
Normal file
9
tests/Stub/StubB.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
|
||||||
|
class StubB extends StubA implements TestOnly
|
||||||
|
{
|
||||||
|
}
|
9
tests/Stub/StubC.php
Normal file
9
tests/Stub/StubC.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
|
||||||
|
class StubC extends StubA implements TestOnly
|
||||||
|
{
|
||||||
|
}
|
23
tests/Stub/StubOrdered.php
Normal file
23
tests/Stub/StubOrdered.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class StubOrdered extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $db = array(
|
||||||
|
'Sort' => 'Int'
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $has_one = array(
|
||||||
|
'Parent' => StubParent::class
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $belongs_many_many =array(
|
||||||
|
'MyManyMany' => StubParent::class,
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $table_name = 'StubOrdered';
|
||||||
|
}
|
24
tests/Stub/StubParent.php
Normal file
24
tests/Stub/StubParent.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class StubParent extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $has_many = array(
|
||||||
|
'MyHasMany' => StubOrdered::class,
|
||||||
|
'MyHasManySubclass' => StubSubclass::class
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $many_many = array(
|
||||||
|
'MyManyMany' => StubOrdered::class
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $many_many_extraFields = array(
|
||||||
|
'MyManyMany' => array('ManyManySort' => 'Int')
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $table_name = 'StubParent';
|
||||||
|
}
|
11
tests/Stub/StubSubclass.php
Normal file
11
tests/Stub/StubSubclass.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symbiote\GridFieldExtensions\Tests\Stub;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class StubSubclass extends StubOrdered implements TestOnly
|
||||||
|
{
|
||||||
|
private static $table_name = 'StubSubclass';
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user