silverstripe-framework/tests/php/Dev/SapphireTestTest/DataProvider.php

188 lines
4.9 KiB
PHP
Raw Normal View History

2017-09-27 09:25:37 +02:00
<?php
namespace SilverStripe\Dev\Tests\SapphireTestTest;
use SilverStripe\Dev\TestOnly;
class DataProvider implements TestOnly
{
protected static $oneItemList = [
['FirstName' => 'Ingo', 'Surname' => 'Schommer'],
2017-09-27 09:25:37 +02:00
];
protected static $twoItemList = [
['FirstName' => 'Ingo', 'Surname' => 'Schommer'],
['FirstName' => 'Sam', 'Surname' => 'Minnee'],
];
protected static $memberList = [
['FirstName' => 'Ingo', 'Surname' => 'Schommer', 'Locale' => 'en_US'],
['FirstName' => 'Sam', 'Surname' => 'Minnee', 'Locale' => 'en_US'],
2017-09-27 09:25:37 +02:00
];
/**
* @return array
*/
public static function provideEqualListsWithEmptyList()
{
return array_merge(
[
'emptyLists' => [
2017-09-27 09:25:37 +02:00
[],
[],
],
2017-09-27 09:25:37 +02:00
],
self::provideEqualLists()
);
}
/**
* @return array
*/
public static function provideEqualLists()
{
return [
[
'oneParameterOneItem' => [
['FirstName' => 'Ingo'],
2017-09-27 09:25:37 +02:00
],
self::$oneItemList,
2017-09-27 09:25:37 +02:00
],
[
'twoParametersOneItem' => [
['FirstName' => 'Ingo', 'Surname' => 'Schommer'],
2017-09-27 09:25:37 +02:00
],
self::$oneItemList,
2017-09-27 09:25:37 +02:00
],
[
'oneParameterTwoItems' => [
2017-09-27 09:25:37 +02:00
['FirstName' => 'Ingo'],
['FirstName' => 'Sam'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
[
'twoParametersTwoItems' => [
2017-09-27 09:25:37 +02:00
['FirstName' => 'Ingo', 'Surname' => 'Schommer'],
['FirstName' => 'Sam', 'Surname' => 'Minnee'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
[
'mixedParametersTwoItems' => [
2017-09-27 09:25:37 +02:00
['FirstName' => 'Ingo', 'Surname' => 'Schommer'],
['FirstName' => 'Sam'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
];
}
/**
* @return array
*/
public static function provideNonEqualLists()
{
return [
[
'checkAgainstEmptyList' => [
['FirstName' => 'Ingo'],
2017-09-27 09:25:37 +02:00
],
[],
2017-09-27 09:25:37 +02:00
],
[
'oneItemExpectedListContainsMore' => [
['FirstName' => 'Ingo'],
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
[
'oneExpectationHasWrontParamter' => [
2017-09-27 09:25:37 +02:00
['FirstName' => 'IngoXX'],
['FirstName' => 'Sam'],
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
[
'differentParametersInDifferentItemsAreWrong' => [
2017-09-27 09:25:37 +02:00
['FirstName' => 'IngoXXX', 'Surname' => 'Schommer'],
['FirstName' => 'Sam', 'Surname' => 'MinneeXXX'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
[
'differentParametersNotMatching' => [
2017-09-27 09:25:37 +02:00
['FirstName' => 'Daniel', 'Surname' => 'Foo'],
['FirstName' => 'Dan'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
];
}
/**
* @return array
*/
public static function provideNotContainingList()
{
return [
'listIsEmpty' => [
2017-09-27 09:25:37 +02:00
[
['FirstName' => 'Ingo'],
2017-09-27 09:25:37 +02:00
],
[],
2017-09-27 09:25:37 +02:00
],
'oneItemIsExpected' => [
[
['FirstName' => 'Sam'],
],
self::$oneItemList,
2017-09-27 09:25:37 +02:00
],
'twoParametersAreWrong' => [
[
2017-09-27 09:25:37 +02:00
['FirstName' => 'IngoXXX', 'Surname' => 'Schommer'],
['FirstName' => 'Sam', 'Surname' => 'MinneeXXX'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
'mixedList' => [
[
2017-09-27 09:25:37 +02:00
['FirstName' => 'Daniel', 'Surname' => 'Foo'],
['FirstName' => 'Dan'],
2017-09-27 09:25:37 +02:00
],
self::$twoItemList,
2017-09-27 09:25:37 +02:00
],
];
}
/**
* @return array
*/
public static function provideAllMatchingList()
{
return [
'emptyMatch' => [
[],
self::$memberList,
'empty list did not match',
],
'allItemsWithLocaleSet' => [
['Locale' => 'en_US'],
self::$memberList,
'list with Locale set in all items did not match',
],
2017-09-27 09:25:37 +02:00
];
}
/**
* @return array
*/
public static function provideNotMatchingList()
{
return [
'notAllItemsHaveLocaleSet' => [['FirstName' => 'Ingo'], self::$memberList],
2017-09-27 09:25:37 +02:00
];
}
}