-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move methods from extension into core - Modify tests to remove App namespacing - Add test objects
- Loading branch information
Showing
7 changed files
with
469 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Versioned\Tests; | ||
|
||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\ORM\ValidationException; | ||
use SilverStripe\Versioned\Tests\VersionedNestedTest\PrimaryObject; | ||
use SilverStripe\Versioned\Tests\VersionedNestedTest\ColumnObject; | ||
use SilverStripe\Versioned\Tests\VersionedNestedTest\GroupObject; | ||
use SilverStripe\Versioned\Tests\VersionedNestedTest\ChildObject; | ||
|
||
class VersionedNestedTest extends SapphireTest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected static $fixture_file = 'VersionedNestedTest.yml'; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
protected static $extra_dataobjects = [ | ||
PrimaryObject::class, | ||
ColumnObject::class, | ||
GroupObject::class, | ||
ChildObject::class, | ||
]; | ||
|
||
/** | ||
* @param string $class | ||
* @param string $identifier | ||
* @param bool $delete | ||
* @throws ValidationException | ||
* @dataProvider objectsProvider | ||
*/ | ||
public function testStageDiffersRecursive(string $class, string $identifier, bool $delete): void | ||
{ | ||
/** @var PrimaryObject $primaryItem */ | ||
$primaryItem = $this->objFromFixture(PrimaryObject::class, 'primary-object-1'); | ||
$primaryItem->publishRecursive(); | ||
|
||
$this->assertFalse($primaryItem->stagesDifferRecursive()); | ||
|
||
$record = $this->objFromFixture($class, $identifier); | ||
|
||
if ($delete) { | ||
$record->delete(); | ||
} else { | ||
$record->Title = 'New Title'; | ||
$record->write(); | ||
} | ||
|
||
$this->assertTrue($primaryItem->stagesDifferRecursive()); | ||
} | ||
|
||
public function objectsProvider(): array | ||
{ | ||
return [ | ||
[PrimaryObject::class, 'primary-object-1', false], | ||
[ColumnObject::class, 'column-1', false], | ||
[GroupObject::class, 'group-1', false], | ||
[ChildObject::class, 'child-object-1', false], | ||
[ColumnObject::class, 'column-1', true], | ||
[GroupObject::class, 'group-1', true], | ||
[ChildObject::class, 'child-object-1', true], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# site-config-1 | ||
# -> primary-object-1 (top level publish object) | ||
# --> column-1 | ||
# ---> group-1 | ||
# ----> child-object-1 | ||
|
||
SilverStripe\Versioned\Tests\VersionedNestedTest\PrimaryObject: | ||
primary-object-1: | ||
Title: PrimaryObject1 | ||
|
||
SilverStripe\Versioned\Tests\VersionedNestedTest\ColumnObject: | ||
column-1: | ||
Title: Column1 | ||
PrimaryObject: =>SilverStripe\Versioned\Tests\VersionedNestedTest\PrimaryObject.primary-object-1 | ||
|
||
SilverStripe\Versioned\Tests\VersionedNestedTest\GroupObject: | ||
group-1: | ||
Title: Group1 | ||
Column: =>SilverStripe\Versioned\Tests\VersionedNestedTest\ColumnObject.column-1 | ||
|
||
SilverStripe\Versioned\Tests\VersionedNestedTest\ChildObject: | ||
child-object-1: | ||
Title: Item1 | ||
Group: =>SilverStripe\Versioned\Tests\VersionedNestedTest\GroupObject.group-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Versioned\Tests\VersionedNestedTest; | ||
|
||
use SilverStripe\Dev\TestOnly; | ||
use SilverStripe\ORM\DataObject; | ||
use SilverStripe\Versioned\Versioned; | ||
|
||
class ChildObject extends DataObject implements TestOnly | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'VersionedNestedTest_ChildObject'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $db = [ | ||
'Title' => 'Varchar(255)', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $extensions = [ | ||
Versioned::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $has_one = [ | ||
'Group' => GroupObject::class, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Versioned\Tests\VersionedNestedTest; | ||
|
||
use SilverStripe\Dev\TestOnly; | ||
use SilverStripe\ORM\DataObject; | ||
use SilverStripe\Versioned\Versioned; | ||
|
||
class ColumnObject extends DataObject implements TestOnly | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'VersionedNestedTest_ColumnObject'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $db = [ | ||
'Title' => 'Varchar(255)', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $extensions = [ | ||
Versioned::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $has_one = [ | ||
'PrimaryObject' => PrimaryObject::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $has_many = [ | ||
'Groups' => GroupObject::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $owns = [ | ||
'Groups', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $cascade_duplicates = [ | ||
'Groups', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $cascade_deletes = [ | ||
'Groups', | ||
]; | ||
} |
Oops, something went wrong.