Skip to content

Commit

Permalink
Moves abstract classes to helper folder for better orgnisation and au…
Browse files Browse the repository at this point in the history
…toloading. [skip ci]
  • Loading branch information
Steve "uru" West committed Oct 25, 2015
1 parent 897e5ba commit 0e4ad25
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: php

sudo: false

php:
- 5.4
- 5.5
Expand Down
102 changes: 102 additions & 0 deletions tests/_helpers/AbstractRequiredTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/**
* @package Fuel\Validation
* @version 2.0
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2013 Fuel Development Team
* @link http://fuelphp.com
*/

namespace Fuel\Validation\Rule;

class AbstractRequiredTest extends AbstractRuleTest
{

/**
* {@inheritdocs}
*/
protected $message = 'The field is required and has not been specified.';

protected function _before()
{
$this->object = new Required;
}

/**
* @dataProvider validateProvider
*/
public function testValidate()
{
list($value, $field, $expected, $data) = func_get_args();

$this->assertEquals(
$expected,
$this->object->validate($value, $field, $data)
);
}

/**
* {@inheritdocs}
*/
public function validateProvider()
{
return array(
0 => array('[email protected]', null, false, null),
1 => array('', null, false, null),
2 => array(array(), null, false, null),
3 => array(null, null, false, null),
4 => array(false, null, false, null),

5 => array('test string 5', 'test', false,
array()
),

6 => array('test string 6', 'test', false,
array(
'foo' => 'bar',
'baz' => 'bat',
)
),

7 => array('test string 7', 'test', true,
array(
'foo' => 'bar',
'test' => 'value',
'baz' => 'bat',
)
),

8 => array('bla', 'test', true, null),
9 => array('', 'test', false, null),
10 => array('bla', null, false, array()),
11 => array('', null, false, array()),

12 => array(false, 'foo', true,
array(
'foo' => false,
)
),
13 => array(true, 'foo', true,
array(
'foo' => true,
)
),

14 => array(false, 'bar', true,
array(
'bar' => false,
)
),
15 => array(0, 'test', true,
array(
'foo' => 'bar',
'test' => 0,
'baz' => 'bat',
)
),
16 => array(0, 'test', true, array('test' => 0)),
);
}

}
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/_helpers/_generated/CodeGuyActions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php //[STAMP] 8cfe98b3e6ddaa718333872e2edd6e01
<?php //[STAMP] a8cf3c7461a512a056a510cd9f14df23
namespace _generated;

// This class was automatically generated by build task
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Rule/RequiredIfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Fuel\Validation\Rule;

class RequiredIfTest extends RequiredTest
class RequiredIfTest extends AbstractRequiredTest
{

protected function _before()
Expand Down
88 changes: 1 addition & 87 deletions tests/unit/Rule/RequiredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,93 +10,7 @@

namespace Fuel\Validation\Rule;

class RequiredTest extends AbstractRuleTest
class RequiredTest extends AbstractRequiredTest
{

/**
* {@inheritdocs}
*/
protected $message = 'The field is required and has not been specified.';

protected function _before()
{
$this->object = new Required;
}

/**
* @dataProvider validateProvider
*/
public function testValidate()
{
list($value, $field, $expected, $data) = func_get_args();

$this->assertEquals(
$expected,
$this->object->validate($value, $field, $data)
);
}

/**
* {@inheritdocs}
*/
public function validateProvider()
{
return array(
0 => array('[email protected]', null, false, null),
1 => array('', null, false, null),
2 => array(array(), null, false, null),
3 => array(null, null, false, null),
4 => array(false, null, false, null),

5 => array('test string 5', 'test', false,
array()
),

6 => array('test string 6', 'test', false,
array(
'foo' => 'bar',
'baz' => 'bat',
)
),

7 => array('test string 7', 'test', true,
array(
'foo' => 'bar',
'test' => 'value',
'baz' => 'bat',
)
),

8 => array('bla', 'test', true, null),
9 => array('', 'test', false, null),
10 => array('bla', null, false, array()),
11 => array('', null, false, array()),

12 => array(false, 'foo', true,
array(
'foo' => false,
)
),
13 => array(true, 'foo', true,
array(
'foo' => true,
)
),

14 => array(false, 'bar', true,
array(
'bar' => false,
)
),
15 => array(0, 'test', true,
array(
'foo' => 'bar',
'test' => 0,
'baz' => 'bat',
)
),
16 => array(0, 'test', true, array('test' => 0)),
);
}

}
2 changes: 1 addition & 1 deletion tests/unit/Rule/RequiredWithTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Fuel\Validation\Rule;

class RequiredWithTest extends RequiredTest
class RequiredWithTest extends AbstractRequiredTest
{

protected function _before()
Expand Down

0 comments on commit 0e4ad25

Please sign in to comment.