Skip to content

Commit

Permalink
Unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Feb 10, 2020
1 parent 369d1e6 commit be040a9
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 23 deletions.
21 changes: 21 additions & 0 deletions tests/php/UniqueKey/Mountain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace SilverStripe\Tests\UniqueKey;

use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;

class Mountain extends DataObject implements TestOnly
{
/**
* @var string
*/
private static $table_name = 'UniqueKeyTest_Mountain';

/**
* @var array
*/
private static $db = [
'Title' => 'Varchar',
];
}
21 changes: 21 additions & 0 deletions tests/php/UniqueKey/River.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace SilverStripe\Tests\UniqueKey;

use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;

class River extends DataObject implements TestOnly
{
/**
* @var string
*/
private static $table_name = 'UniqueKeyTest_River';

/**
* @var array
*/
private static $db = [
'Title' => 'Varchar',
];
}
21 changes: 10 additions & 11 deletions tests/php/UniqueKey/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use SilverStripe\Core\Extensible;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\Tests\DataObjectTest;

class ServiceTest extends SapphireTest
{
Expand All @@ -17,8 +16,8 @@ class ServiceTest extends SapphireTest
* @var array
*/
protected static $extra_dataobjects = array(
DataObjectTest\Team::class,
DataObjectTest\Player::class,
River::class,
Mountain::class,
);

/**
Expand All @@ -41,14 +40,14 @@ public function testUniqueKey(string $identifier, string $class, bool $extraKeys
public function uniqueKeysProvider(): array
{
return [
['team1', DataObjectTest\Team::class, false, 'ss-Team-1-a4ec237d518051effd373f90dad9a1e2'],
['team1', DataObjectTest\Team::class, true, 'ss-Team-1-acfce8862f3886ae67ed98d4306cec36'],
['team2', DataObjectTest\Team::class, false, 'ss-Team-2-69de0ff334cf4687a528c2dbbe198d7d'],
['team2', DataObjectTest\Team::class, true, 'ss-Team-2-82e2d95b464aa098572aec204f559101'],
['captain1', DataObjectTest\Player::class, false, 'ss-Player-1-8fdb4b4c871b413daa017f89e43aadd5'],
['captain1', DataObjectTest\Player::class, true, 'ss-Player-1-0ebd4a3ed29824276ded856c5e604715'],
['captain2', DataObjectTest\Player::class, false, 'ss-Player-2-096c7afa2396936b75e045a27b708f8b'],
['captain2', DataObjectTest\Player::class, true, 'ss-Player-2-a1299ef5c9a4032819f3a052bbea9f42'],
['river1', River::class, false, 'ss-River-1-7eab00006ab6d090635b03f9fa1187d7'],
['river1', River::class, true, 'ss-River-1-65474ab87fd42ca8cbfc32f87d5840e7'],
['river2', River::class, false, 'ss-River-2-9c63d549d3a7a2f9679f7ce0dbb6a177'],
['river2', River::class, true, 'ss-River-2-a028c9b5ecd2dd68edc6f20192e29c63'],
['mountain1', Mountain::class, false, 'ss-Mountain-1-013d8ba56604ceeb2bda4b09d04c7e29'],
['mountain1', Mountain::class, true, 'ss-Mountain-1-3dba35f13a9d3ad648be466946297444'],
['mountain2', Mountain::class, false, 'ss-Mountain-2-a628f2db748065729d6a832a094cea3f'],
['mountain2', Mountain::class, true, 'ss-Mountain-2-e6236799ab5a00d36ee704fa87d46021'],
];
}
}
22 changes: 10 additions & 12 deletions tests/php/UniqueKey/ServiceTest.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
SilverStripe\ORM\Tests\DataObjectTest\Team:
team1:
Title: Team 1
team2:
Title: Team 2
SilverStripe\Tests\UniqueKey\River:
river1:
Title: BigRiver
river2:
Title: SmallRiver

SilverStripe\ORM\Tests\DataObjectTest\Player:
captain1:
FirstName: Captain
Surname: Zookeeper
captain2:
FirstName: Captain 2
Surname: Aaron
SilverStripe\Tests\UniqueKey\Mountain:
mountain1:
Title: BigMountain
mountain2:
Title: SmallMountain

0 comments on commit be040a9

Please sign in to comment.