Add files using upload-large-folder tool
Browse files- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/input.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/lang.php +73 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/migrate.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/model.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/num.php +186 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/pagination.php +696 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/profiler.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/redis.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/request.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/response.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/route.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/router.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/security.php +88 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/session.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/str.php +363 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/testcase.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/unzip.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/upload.php +24 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/uri.php +154 -0
- benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/validation.php +840 -0
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/input.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Input class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Input
|
| 20 |
+
*/
|
| 21 |
+
class Test_Input extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/lang.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Lang class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Lang
|
| 20 |
+
*/
|
| 21 |
+
class Test_Lang extends TestCase
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Test for Lang::get()
|
| 26 |
+
*
|
| 27 |
+
* @test
|
| 28 |
+
*/
|
| 29 |
+
public function test_line()
|
| 30 |
+
{
|
| 31 |
+
Lang::load('test');
|
| 32 |
+
$output = Lang::get('hello', array('name' => 'Bob'));
|
| 33 |
+
$expected = 'Hello there Bob!';
|
| 34 |
+
$this->assertEquals($expected, $output);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Test for Lang::get()
|
| 39 |
+
*
|
| 40 |
+
* @test
|
| 41 |
+
*/
|
| 42 |
+
public function test_line_invalid()
|
| 43 |
+
{
|
| 44 |
+
Lang::load('test');
|
| 45 |
+
$output = Lang::get('non_existant_hello', array('name' => 'Bob'));
|
| 46 |
+
$expected = false;
|
| 47 |
+
$this->assertEquals($expected, $output);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Test for Lang::set()
|
| 52 |
+
*
|
| 53 |
+
* @test
|
| 54 |
+
*/
|
| 55 |
+
public function test_set_return_true()
|
| 56 |
+
{
|
| 57 |
+
$output = Lang::set('testing_set_valid', 'Ahoy :name!');
|
| 58 |
+
$this->assertNull($output);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Test for Lang::set()
|
| 63 |
+
*
|
| 64 |
+
* @test
|
| 65 |
+
*/
|
| 66 |
+
public function test_set()
|
| 67 |
+
{
|
| 68 |
+
Lang::set('testing_set_valid', 'Ahoy :name!');
|
| 69 |
+
$output = Lang::get('testing_set_valid', array('name' => 'Bob'));
|
| 70 |
+
$expected = 'Ahoy Bob!';
|
| 71 |
+
$this->assertEquals($expected, $output);
|
| 72 |
+
}
|
| 73 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/migrate.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Migrate class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Migrate
|
| 20 |
+
*/
|
| 21 |
+
class Test_Migrate extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/model.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Model class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Model
|
| 20 |
+
*/
|
| 21 |
+
class Test_Model extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/num.php
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Numeric helper tests
|
| 17 |
+
*
|
| 18 |
+
* @package Fuel
|
| 19 |
+
* @category Core
|
| 20 |
+
* @author Chase "Syntaqx" Hutchins
|
| 21 |
+
*
|
| 22 |
+
* @group Core
|
| 23 |
+
* @group Num
|
| 24 |
+
*/
|
| 25 |
+
class Test_Num extends TestCase
|
| 26 |
+
{
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @see Num::bytes
|
| 30 |
+
*/
|
| 31 |
+
public function test_bytes()
|
| 32 |
+
{
|
| 33 |
+
$output = Num::bytes('200K');
|
| 34 |
+
$expected = '204800';
|
| 35 |
+
|
| 36 |
+
$this->assertEquals($expected, $output);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* @see Num::bytes
|
| 41 |
+
* @expectedException Exception
|
| 42 |
+
*/
|
| 43 |
+
public function test_bytes_exception()
|
| 44 |
+
{
|
| 45 |
+
$output = Num::bytes('invalid');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @see Num::format_bytes
|
| 50 |
+
*/
|
| 51 |
+
public function test_format_bytes()
|
| 52 |
+
{
|
| 53 |
+
$output = Num::format_bytes('204800');
|
| 54 |
+
$expected = '200 KB';
|
| 55 |
+
|
| 56 |
+
$this->assertEquals($expected, $output);
|
| 57 |
+
|
| 58 |
+
$output = Num::format_bytes('invalid');
|
| 59 |
+
$this->assertFalse($output);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* @see Num::quantity
|
| 64 |
+
*/
|
| 65 |
+
public function test_quantity()
|
| 66 |
+
{
|
| 67 |
+
// Return the same
|
| 68 |
+
$output = Num::quantity('100');
|
| 69 |
+
$expected = '100';
|
| 70 |
+
|
| 71 |
+
$this->assertEquals($expected, $output);
|
| 72 |
+
|
| 73 |
+
$output = Num::quantity('7500');
|
| 74 |
+
$expected = '8K';
|
| 75 |
+
|
| 76 |
+
$this->assertEquals($expected, $output);
|
| 77 |
+
|
| 78 |
+
$output = Num::quantity('1500000');
|
| 79 |
+
$expected = '2M';
|
| 80 |
+
|
| 81 |
+
$this->assertEquals($expected, $output);
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
$output = Num::quantity('1000000000');
|
| 85 |
+
$expected = '1B';
|
| 86 |
+
|
| 87 |
+
$this->assertEquals($expected, $output);
|
| 88 |
+
|
| 89 |
+
// Get current localized decimal separator
|
| 90 |
+
$locale_conv = localeconv();
|
| 91 |
+
$decimal_point = isset($locale_conv['decimal_point']) ? $locale_conv['decimal_point'] : '.';
|
| 92 |
+
|
| 93 |
+
$output = Num::quantity('7500', 1);
|
| 94 |
+
$expected = '7'.$decimal_point.'5K';
|
| 95 |
+
|
| 96 |
+
$this->assertEquals($expected, $output);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* @see Num::format
|
| 101 |
+
*/
|
| 102 |
+
public function test_format()
|
| 103 |
+
{
|
| 104 |
+
$output = Num::format('1234567890', '(000) 000-0000');
|
| 105 |
+
$expected = '(123) 456-7890';
|
| 106 |
+
|
| 107 |
+
$this->assertEquals($expected, $output);
|
| 108 |
+
|
| 109 |
+
$output = Num::format(null, '(000) 000-0000');
|
| 110 |
+
$this->assertNull($output);
|
| 111 |
+
|
| 112 |
+
$output = Num::format('1234567890', null);
|
| 113 |
+
$expected = '1234567890';
|
| 114 |
+
|
| 115 |
+
$this->assertEquals($expected, $output);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* @see Num::mask_string
|
| 120 |
+
*/
|
| 121 |
+
public function test_mask_string()
|
| 122 |
+
{
|
| 123 |
+
$output = Num::mask_string('1234567812345678', '**** - **** - **** - 0000', ' -');
|
| 124 |
+
$expected = '**** - **** - **** - 5678';
|
| 125 |
+
|
| 126 |
+
$this->assertEquals($expected, $output);
|
| 127 |
+
|
| 128 |
+
// Return the same
|
| 129 |
+
$output = Num::mask_string('1234567812345678');
|
| 130 |
+
$expected = '1234567812345678';
|
| 131 |
+
|
| 132 |
+
$this->assertEquals($expected, $output);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* @see Num::format_phone
|
| 137 |
+
*/
|
| 138 |
+
public function test_format_phone()
|
| 139 |
+
{
|
| 140 |
+
$output = Num::format_phone('1234567890');
|
| 141 |
+
$expected = '(123) 456-7890';
|
| 142 |
+
|
| 143 |
+
$this->assertEquals($expected, $output);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* @see Num::smart_format_phone
|
| 148 |
+
*/
|
| 149 |
+
public function test_smart_format_phone()
|
| 150 |
+
{
|
| 151 |
+
$output = Num::smart_format_phone('1234567');
|
| 152 |
+
$expected = '123-4567';
|
| 153 |
+
|
| 154 |
+
$this->assertEquals($expected, $output);
|
| 155 |
+
|
| 156 |
+
// Return the same
|
| 157 |
+
$output = Num::smart_format_phone('123456');
|
| 158 |
+
$expected = '123456';
|
| 159 |
+
|
| 160 |
+
$this->assertEquals($expected, $output);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* @see Num::format_exp
|
| 165 |
+
*/
|
| 166 |
+
public function test_format_exp()
|
| 167 |
+
{
|
| 168 |
+
$output = Num::format_exp('1234');
|
| 169 |
+
$expected = '12-34';
|
| 170 |
+
|
| 171 |
+
$this->assertEquals($expected, $output);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
* @see Num::mask_credit_card
|
| 176 |
+
*/
|
| 177 |
+
public function test_mask_credit_card()
|
| 178 |
+
{
|
| 179 |
+
$output = Num::mask_credit_card('1234567812345678');
|
| 180 |
+
$expected = '**** **** **** 5678';
|
| 181 |
+
|
| 182 |
+
$this->assertEquals($expected, $output);
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
/* End of file num.php */
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/pagination.php
ADDED
|
@@ -0,0 +1,696 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Pagination class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Pagination
|
| 20 |
+
*/
|
| 21 |
+
class Test_Pagination extends TestCase
|
| 22 |
+
{
|
| 23 |
+
protected function set_request($uri)
|
| 24 |
+
{
|
| 25 |
+
// fake the uri for this request
|
| 26 |
+
isset($_SERVER['PATH_INFO']) and $this->pathinfo = $_SERVER['PATH_INFO'];
|
| 27 |
+
$_SERVER['PATH_INFO'] = '/'.$uri;
|
| 28 |
+
|
| 29 |
+
// set Request::$main
|
| 30 |
+
$this->request = \Request::forge($uri);
|
| 31 |
+
$rp = new \ReflectionProperty($this->request, 'main');
|
| 32 |
+
$rp->setAccessible(true);
|
| 33 |
+
$rp->setValue($this->request, $this->request);
|
| 34 |
+
|
| 35 |
+
// set Request::$active
|
| 36 |
+
$rp = new \ReflectionProperty($this->request, 'active');
|
| 37 |
+
$rp->setAccessible(true);
|
| 38 |
+
$rp->setValue($this->request, $this->request);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public function tearDown()
|
| 42 |
+
{
|
| 43 |
+
// remove the fake uri
|
| 44 |
+
if (property_exists($this, 'pathinfo'))
|
| 45 |
+
{
|
| 46 |
+
$_SERVER['PATH_INFO'] = $this->pathinfo;
|
| 47 |
+
}
|
| 48 |
+
else
|
| 49 |
+
{
|
| 50 |
+
unset($_SERVER['PATH_INFO']);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// reset Request::$main
|
| 54 |
+
$request = \Request::forge();
|
| 55 |
+
$rp = new \ReflectionProperty($request, 'main');
|
| 56 |
+
$rp->setAccessible(true);
|
| 57 |
+
$rp->setValue($request, false);
|
| 58 |
+
|
| 59 |
+
// reset Request::$active
|
| 60 |
+
$rp = new \ReflectionProperty($request, 'active');
|
| 61 |
+
$rp->setAccessible(true);
|
| 62 |
+
$rp->setValue($request, false);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**********************************
|
| 66 |
+
* Tests for URI Segment Pagination
|
| 67 |
+
**********************************/
|
| 68 |
+
|
| 69 |
+
protected function set_uri_segment_config()
|
| 70 |
+
{
|
| 71 |
+
$this->config = array(
|
| 72 |
+
'uri_segment' => 3,
|
| 73 |
+
'pagination_url' => 'http://docs.fuelphp.com/welcome/index/',
|
| 74 |
+
'total_items' => 100,
|
| 75 |
+
'per_page' => 10,
|
| 76 |
+
'wrapper' => "<div class=\"pagination\">\n\t{pagination}\n</div>\n",
|
| 77 |
+
|
| 78 |
+
'first' => "<span class=\"first\">\n\t{link}\n</span>\n",
|
| 79 |
+
'first-marker' => "««",
|
| 80 |
+
'first-link' => "\t\t<a href=\"{uri}\">{page}</a>\n",
|
| 81 |
+
|
| 82 |
+
'first-inactive' => "",
|
| 83 |
+
'first-inactive-link' => "",
|
| 84 |
+
|
| 85 |
+
'previous' => "<span class=\"previous\">\n\t{link}\n</span>\n",
|
| 86 |
+
'previous-marker' => "«",
|
| 87 |
+
'previous-link' => "\t\t<a href=\"{uri}\" rel=\"prev\">{page}</a>\n",
|
| 88 |
+
|
| 89 |
+
'previous-inactive' => "<span class=\"previous-inactive\">\n\t{link}\n</span>\n",
|
| 90 |
+
'previous-inactive-link' => "\t\t<a href=\"#\" rel=\"prev\">{page}</a>\n",
|
| 91 |
+
|
| 92 |
+
'regular' => "<span>\n\t{link}\n</span>\n",
|
| 93 |
+
'regular-link' => "\t\t<a href=\"{uri}\">{page}</a>\n",
|
| 94 |
+
|
| 95 |
+
'active' => "<span class=\"active\">\n\t{link}\n</span>\n",
|
| 96 |
+
'active-link' => "\t\t<a href=\"#\">{page}</a>\n",
|
| 97 |
+
|
| 98 |
+
'next' => "<span class=\"next\">\n\t{link}\n</span>\n",
|
| 99 |
+
'next-marker' => "»",
|
| 100 |
+
'next-link' => "\t\t<a href=\"{uri}\" rel=\"next\">{page}</a>\n",
|
| 101 |
+
|
| 102 |
+
'next-inactive' => "<span class=\"next-inactive\">\n\t{link}\n</span>\n",
|
| 103 |
+
'next-inactive-link' => "\t\t<a href=\"#\" rel=\"next\">{page}</a>\n",
|
| 104 |
+
|
| 105 |
+
'last' => "<span class=\"last\">\n\t{link}\n</span>\n",
|
| 106 |
+
'last-marker' => "»»",
|
| 107 |
+
'last-link' => "\t\t<a href=\"{uri}\">{page}</a>\n",
|
| 108 |
+
|
| 109 |
+
'last-inactive' => "",
|
| 110 |
+
'last-inactive-link' => "",
|
| 111 |
+
);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
public function test_uri_segment_auto_detect_pagination_url()
|
| 115 |
+
{
|
| 116 |
+
// set base_url
|
| 117 |
+
Config::set('base_url', 'http://docs.fuelphp.com/');
|
| 118 |
+
// set Request::$main & $active
|
| 119 |
+
$this->set_request('welcome/index/5');
|
| 120 |
+
|
| 121 |
+
$this->set_uri_segment_config();
|
| 122 |
+
$this->config['pagination_url'] = null;
|
| 123 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 124 |
+
|
| 125 |
+
// set _make_link() accessible
|
| 126 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 127 |
+
$_make_link->setAccessible(true);
|
| 128 |
+
|
| 129 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 130 |
+
$expected = 'http://docs.fuelphp.com/welcome/index/1';
|
| 131 |
+
$this->assertEquals($expected, $test);
|
| 132 |
+
|
| 133 |
+
// reset base_url
|
| 134 |
+
Config::set('base_url', null);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
public function test_uri_segment_set_pagination_url_after_forging_fail()
|
| 138 |
+
{
|
| 139 |
+
// set Request::$main & $active
|
| 140 |
+
$this->set_request('welcome/index/3');
|
| 141 |
+
|
| 142 |
+
$this->set_uri_segment_config();
|
| 143 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 144 |
+
$pagination->pagination_url = 'http://example.com/page/';
|
| 145 |
+
|
| 146 |
+
// set _make_link() accessible
|
| 147 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 148 |
+
$_make_link->setAccessible(true);
|
| 149 |
+
|
| 150 |
+
// not enough segments in the URI to add the page number
|
| 151 |
+
$this->setExpectedException('RunTimeException');
|
| 152 |
+
|
| 153 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
public function test_uri_segment_set_pagination_url_after_forging_success()
|
| 157 |
+
{
|
| 158 |
+
// set Request::$main & $active
|
| 159 |
+
$this->set_request('welcome/index/3');
|
| 160 |
+
|
| 161 |
+
$this->set_uri_segment_config();
|
| 162 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 163 |
+
$pagination->pagination_url = 'http://example.com/this/page/';
|
| 164 |
+
|
| 165 |
+
// set _make_link() accessible
|
| 166 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 167 |
+
$_make_link->setAccessible(true);
|
| 168 |
+
|
| 169 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 170 |
+
$expected = 'http://example.com/this/page/1';
|
| 171 |
+
$this->assertEquals($expected, $test);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
public function test_uri_segment_get_total_pages()
|
| 175 |
+
{
|
| 176 |
+
// set Request::$main & $active
|
| 177 |
+
$this->set_request('welcome/index/');
|
| 178 |
+
|
| 179 |
+
$this->set_uri_segment_config();
|
| 180 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 181 |
+
$test = $pagination->total_pages;
|
| 182 |
+
$expected = 10;
|
| 183 |
+
$this->assertEquals($expected, $test);
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
public function test_current_page_calculation_from_link()
|
| 187 |
+
{
|
| 188 |
+
// set Request::$main & $active
|
| 189 |
+
$this->set_request('welcome/index/4');
|
| 190 |
+
|
| 191 |
+
$this->set_uri_segment_config();
|
| 192 |
+
|
| 193 |
+
$config = array(
|
| 194 |
+
'total_items' => 12,
|
| 195 |
+
'per_page' => 3,
|
| 196 |
+
'uri_segment' => 3,
|
| 197 |
+
);
|
| 198 |
+
|
| 199 |
+
$pagination = Pagination::forge(__METHOD__.'-1', $config);
|
| 200 |
+
$test = $pagination->current_page;
|
| 201 |
+
$expected = 4;
|
| 202 |
+
$this->assertEquals($expected, $test);
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
public function test_current_page_calculation_from_config()
|
| 206 |
+
{
|
| 207 |
+
$this->set_request('welcome/index/6');
|
| 208 |
+
|
| 209 |
+
$config = array(
|
| 210 |
+
'per_page' => 3,
|
| 211 |
+
'total_items' => 12,
|
| 212 |
+
'uri_segment' => 3,
|
| 213 |
+
'current_page' => 4,
|
| 214 |
+
);
|
| 215 |
+
|
| 216 |
+
$pagination = Pagination::forge(__METHOD__.'-2', $config);
|
| 217 |
+
$test = $pagination->current_page;
|
| 218 |
+
$expected = 4;
|
| 219 |
+
$this->assertEquals($expected, $test);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
/**
|
| 223 |
+
* raw render
|
| 224 |
+
*
|
| 225 |
+
*/
|
| 226 |
+
public function test_pagination_raw_render()
|
| 227 |
+
{
|
| 228 |
+
// set Request::$main & $active
|
| 229 |
+
$this->set_request('welcome/index/5');
|
| 230 |
+
|
| 231 |
+
$this->set_uri_segment_config();
|
| 232 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 233 |
+
|
| 234 |
+
$expected = array(
|
| 235 |
+
'previous' => array(
|
| 236 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/4",
|
| 237 |
+
'title' => "«",
|
| 238 |
+
'type' => "previous",
|
| 239 |
+
),
|
| 240 |
+
0 => array(
|
| 241 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/1",
|
| 242 |
+
'title' => 1,
|
| 243 |
+
'type' => "regular",
|
| 244 |
+
),
|
| 245 |
+
1 => array(
|
| 246 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/2",
|
| 247 |
+
'title' => 2,
|
| 248 |
+
'type' => "regular",
|
| 249 |
+
),
|
| 250 |
+
2 => array(
|
| 251 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/3",
|
| 252 |
+
'title' => 3,
|
| 253 |
+
'type' => "regular",
|
| 254 |
+
),
|
| 255 |
+
3 => array(
|
| 256 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/4",
|
| 257 |
+
'title' => 4,
|
| 258 |
+
'type' => "regular",
|
| 259 |
+
),
|
| 260 |
+
4 => array(
|
| 261 |
+
'uri' => "#",
|
| 262 |
+
'title' => 5,
|
| 263 |
+
'type' => "active",
|
| 264 |
+
),
|
| 265 |
+
5 => array(
|
| 266 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/6",
|
| 267 |
+
'title' => 6,
|
| 268 |
+
'type' => "regular",
|
| 269 |
+
),
|
| 270 |
+
6 => array(
|
| 271 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/7",
|
| 272 |
+
'title' => 7,
|
| 273 |
+
'type' => "regular",
|
| 274 |
+
),
|
| 275 |
+
7 => array(
|
| 276 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/8",
|
| 277 |
+
'title' => 8,
|
| 278 |
+
'type' => "regular",
|
| 279 |
+
),
|
| 280 |
+
8 => array(
|
| 281 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/9",
|
| 282 |
+
'title' => 9,
|
| 283 |
+
'type' => "regular",
|
| 284 |
+
),
|
| 285 |
+
9 => array(
|
| 286 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/10",
|
| 287 |
+
'title' => 10,
|
| 288 |
+
'type' => "regular",
|
| 289 |
+
),
|
| 290 |
+
'next' => array(
|
| 291 |
+
'uri' => "http://docs.fuelphp.com/welcome/index/6",
|
| 292 |
+
'title' => "»",
|
| 293 |
+
'type' => "next",
|
| 294 |
+
),
|
| 295 |
+
);
|
| 296 |
+
|
| 297 |
+
$test = $pagination->render(true);
|
| 298 |
+
$this->assertEquals($expected, $test);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* first page
|
| 303 |
+
*
|
| 304 |
+
*/
|
| 305 |
+
public function test_uri_segment_first_page()
|
| 306 |
+
{
|
| 307 |
+
// set Request::$main & $active
|
| 308 |
+
$this->set_request('welcome/index/');
|
| 309 |
+
|
| 310 |
+
$this->set_uri_segment_config();
|
| 311 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 312 |
+
|
| 313 |
+
$output = $pagination->previous();
|
| 314 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 315 |
+
$expected = '<span class="previous-inactive"><a href="#" rel="prev">«</a></span>';
|
| 316 |
+
$this->assertEquals($expected, $output);
|
| 317 |
+
|
| 318 |
+
$output = $pagination->pages_render();
|
| 319 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 320 |
+
$expected = '<span class="active"><a href="#">1</a></span><span><a href="http://docs.fuelphp.com/welcome/index/2">2</a></span><span><a href="http://docs.fuelphp.com/welcome/index/3">3</a></span><span><a href="http://docs.fuelphp.com/welcome/index/4">4</a></span><span><a href="http://docs.fuelphp.com/welcome/index/5">5</a></span><span><a href="http://docs.fuelphp.com/welcome/index/6">6</a></span>';
|
| 321 |
+
$this->assertEquals($expected, $output);
|
| 322 |
+
|
| 323 |
+
$output = $pagination->next();
|
| 324 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 325 |
+
$expected = '<span class="next"><a href="http://docs.fuelphp.com/welcome/index/2" rel="next">»</a></span>';
|
| 326 |
+
$this->assertEquals($expected, $output);
|
| 327 |
+
|
| 328 |
+
$output = $pagination->render();
|
| 329 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 330 |
+
$expected = '<div class="pagination"><span class="previous-inactive"><a href="#" rel="prev">«</a></span><span class="active"><a href="#">1</a></span><span><a href="http://docs.fuelphp.com/welcome/index/2">2</a></span><span><a href="http://docs.fuelphp.com/welcome/index/3">3</a></span><span><a href="http://docs.fuelphp.com/welcome/index/4">4</a></span><span><a href="http://docs.fuelphp.com/welcome/index/5">5</a></span><span><a href="http://docs.fuelphp.com/welcome/index/6">6</a></span><span class="next"><a href="http://docs.fuelphp.com/welcome/index/2" rel="next">»</a></span></div>';
|
| 331 |
+
$this->assertEquals($expected, $output);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
/**
|
| 335 |
+
* last page
|
| 336 |
+
*
|
| 337 |
+
*/
|
| 338 |
+
public function test_uri_segment_nextlink_inactive()
|
| 339 |
+
{
|
| 340 |
+
// set Request::$main & $active
|
| 341 |
+
$this->set_request('welcome/index/11');
|
| 342 |
+
|
| 343 |
+
$this->set_uri_segment_config();
|
| 344 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 345 |
+
|
| 346 |
+
$output = $pagination->next();
|
| 347 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 348 |
+
$expected = '<span class="next-inactive"><a href="#" rel="next">»</a></span>';
|
| 349 |
+
$this->assertEquals($expected, $output);
|
| 350 |
+
|
| 351 |
+
$this->set_request('welcome/index/10');
|
| 352 |
+
|
| 353 |
+
$output = $pagination->pages_render();
|
| 354 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 355 |
+
$expected = '<span><a href="http://docs.fuelphp.com/welcome/index/6">6</a></span><span><a href="http://docs.fuelphp.com/welcome/index/7">7</a></span><span><a href="http://docs.fuelphp.com/welcome/index/8">8</a></span><span><a href="http://docs.fuelphp.com/welcome/index/9">9</a></span><span class="active"><a href="#">10</a></span>';
|
| 356 |
+
$this->assertEquals($expected, $output);
|
| 357 |
+
|
| 358 |
+
$output = $pagination->previous();
|
| 359 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 360 |
+
$expected = '<span class="previous"><a href="http://docs.fuelphp.com/welcome/index/9" rel="prev">«</a></span>';
|
| 361 |
+
$this->assertEquals($expected, $output);
|
| 362 |
+
|
| 363 |
+
$output = $pagination->render();
|
| 364 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 365 |
+
$expected = '<div class="pagination"><span class="previous"><a href="http://docs.fuelphp.com/welcome/index/9" rel="prev">«</a></span><span><a href="http://docs.fuelphp.com/welcome/index/6">6</a></span><span><a href="http://docs.fuelphp.com/welcome/index/7">7</a></span><span><a href="http://docs.fuelphp.com/welcome/index/8">8</a></span><span><a href="http://docs.fuelphp.com/welcome/index/9">9</a></span><span class="active"><a href="#">10</a></span><span class="next-inactive"><a href="#" rel="next">»</a></span></div>';
|
| 366 |
+
$this->assertEquals($expected, $output);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
/**
|
| 370 |
+
* total page is 1
|
| 371 |
+
*
|
| 372 |
+
*/
|
| 373 |
+
public function test_uri_segment_total_page_is_one()
|
| 374 |
+
{
|
| 375 |
+
// set Request::$main & $active
|
| 376 |
+
$this->set_request('welcome/index/10');
|
| 377 |
+
|
| 378 |
+
$this->set_uri_segment_config();
|
| 379 |
+
$this->config['per_page'] = 1000;
|
| 380 |
+
|
| 381 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 382 |
+
|
| 383 |
+
$output = $pagination->pages_render();
|
| 384 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 385 |
+
$expected = '';
|
| 386 |
+
$this->assertEquals($expected, $output);
|
| 387 |
+
|
| 388 |
+
$output = $pagination->render();
|
| 389 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 390 |
+
$expected = '';
|
| 391 |
+
$this->assertEquals($expected, $output);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
public function test_uri_segment_make_link_with_no_query_string_ending_page_number()
|
| 395 |
+
{
|
| 396 |
+
// set Request::$main & $active
|
| 397 |
+
$this->set_request('welcome/index/10');
|
| 398 |
+
$this->set_uri_segment_config();
|
| 399 |
+
$this->config['pagination_url'] = 'http://docs.fuelphp.com/welcome/index/55';
|
| 400 |
+
|
| 401 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 402 |
+
|
| 403 |
+
// set _make_link() accessible
|
| 404 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 405 |
+
$_make_link->setAccessible(true);
|
| 406 |
+
|
| 407 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 408 |
+
$expected = 'http://docs.fuelphp.com/welcome/index/1';
|
| 409 |
+
$this->assertEquals($expected, $test);
|
| 410 |
+
|
| 411 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 412 |
+
$expected = 'http://docs.fuelphp.com/welcome/index/99';
|
| 413 |
+
$this->assertEquals($expected, $test);
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
public function test_uri_segment_make_link_with_no_query_string_ending_slash()
|
| 417 |
+
{
|
| 418 |
+
// set Request::$main & $active
|
| 419 |
+
$this->set_request('welcome/index/');
|
| 420 |
+
$this->set_uri_segment_config();
|
| 421 |
+
$this->config['pagination_url'] = 'http://docs.fuelphp.com/welcome/index/';
|
| 422 |
+
|
| 423 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 424 |
+
|
| 425 |
+
// set _make_link() accessible
|
| 426 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 427 |
+
$_make_link->setAccessible(true);
|
| 428 |
+
|
| 429 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 430 |
+
$expected = 'http://docs.fuelphp.com/welcome/index/1';
|
| 431 |
+
$this->assertEquals($expected, $test);
|
| 432 |
+
|
| 433 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 434 |
+
$expected = 'http://docs.fuelphp.com/welcome/index/99';
|
| 435 |
+
$this->assertEquals($expected, $test);
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
public function test_uri_segment_make_link_with_query_string_ending_page_number()
|
| 439 |
+
{
|
| 440 |
+
// set Request::$main & $active
|
| 441 |
+
$this->set_request('welcome/index/55?foo=bar&fuel[]=php1&fuel[]=php2&');
|
| 442 |
+
$this->set_uri_segment_config();
|
| 443 |
+
|
| 444 |
+
// no define pagination_url
|
| 445 |
+
$this->config['pagination_url'] = null;
|
| 446 |
+
|
| 447 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 448 |
+
|
| 449 |
+
// set _make_link() accessible
|
| 450 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 451 |
+
$_make_link->setAccessible(true);
|
| 452 |
+
|
| 453 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 454 |
+
$expected = '/welcome/index/1?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2';
|
| 455 |
+
$this->assertEquals($expected, $test);
|
| 456 |
+
|
| 457 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 458 |
+
$expected = '/welcome/index/99?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2';
|
| 459 |
+
$this->assertEquals($expected, $test);
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
public function test_uri_segment_make_link_with_query_string_ending_slash()
|
| 463 |
+
{
|
| 464 |
+
// set Request::$main & $active
|
| 465 |
+
$this->set_request('welcome/index/?foo=bar&fuel[]=php1&fuel[]=php2&');
|
| 466 |
+
$this->set_uri_segment_config();
|
| 467 |
+
|
| 468 |
+
// no define pagination_url
|
| 469 |
+
$this->config['pagination_url'] = null;
|
| 470 |
+
|
| 471 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 472 |
+
|
| 473 |
+
// set _make_link() accessible
|
| 474 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 475 |
+
$_make_link->setAccessible(true);
|
| 476 |
+
|
| 477 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 478 |
+
$expected = '/welcome/index/1?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2';
|
| 479 |
+
$this->assertEquals($expected, $test);
|
| 480 |
+
|
| 481 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 482 |
+
$expected = '/welcome/index/99?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2';
|
| 483 |
+
$this->assertEquals($expected, $test);
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
/***********************************
|
| 487 |
+
* Tests for Query String Pagination
|
| 488 |
+
***********************************/
|
| 489 |
+
|
| 490 |
+
protected function set_query_string_config()
|
| 491 |
+
{
|
| 492 |
+
$this->config = array(
|
| 493 |
+
'uri_segment' => 'p',
|
| 494 |
+
'pagination_url' => 'http://docs.fuelphp.com/',
|
| 495 |
+
'total_items' => 100,
|
| 496 |
+
'per_page' => 10,
|
| 497 |
+
'wrapper' => "<div class=\"pagination\">\n\t{pagination}\n</div>\n",
|
| 498 |
+
|
| 499 |
+
'first' => "<span class=\"first\">\n\t{link}\n</span>\n",
|
| 500 |
+
'first-marker' => "««",
|
| 501 |
+
'first-link' => "\t\t<a href=\"{uri}\">{page}</a>\n",
|
| 502 |
+
|
| 503 |
+
'first-inactive' => "",
|
| 504 |
+
'first-inactive-link' => "",
|
| 505 |
+
|
| 506 |
+
'previous' => "<span class=\"previous\">\n\t{link}\n</span>\n",
|
| 507 |
+
'previous-marker' => "«",
|
| 508 |
+
'previous-link' => "\t\t<a href=\"{uri}\" rel=\"prev\">{page}</a>\n",
|
| 509 |
+
|
| 510 |
+
'previous-inactive' => "<span class=\"previous-inactive\">\n\t{link}\n</span>\n",
|
| 511 |
+
'previous-inactive-link' => "\t\t<a href=\"#\" rel=\"prev\">{page}</a>\n",
|
| 512 |
+
|
| 513 |
+
'regular' => "<span>\n\t{link}\n</span>\n",
|
| 514 |
+
'regular-link' => "\t\t<a href=\"{uri}\">{page}</a>\n",
|
| 515 |
+
|
| 516 |
+
'active' => "<span class=\"active\">\n\t{link}\n</span>\n",
|
| 517 |
+
'active-link' => "\t\t<a href=\"#\">{page}</a>\n",
|
| 518 |
+
|
| 519 |
+
'next' => "<span class=\"next\">\n\t{link}\n</span>\n",
|
| 520 |
+
'next-marker' => "»",
|
| 521 |
+
'next-link' => "\t\t<a href=\"{uri}\" rel=\"next\">{page}</a>\n",
|
| 522 |
+
|
| 523 |
+
'next-inactive' => "<span class=\"next-inactive\">\n\t{link}\n</span>\n",
|
| 524 |
+
'next-inactive-link' => "\t\t<a href=\"#\" rel=\"next\">{page}</a>\n",
|
| 525 |
+
|
| 526 |
+
'last' => "<span class=\"last\">\n\t{link}\n</span>\n",
|
| 527 |
+
'last-marker' => "»»",
|
| 528 |
+
'last-link' => "\t\t<a href=\"{uri}\">{page}</a>\n",
|
| 529 |
+
|
| 530 |
+
'last-inactive' => "",
|
| 531 |
+
'last-inactive-link' => "",
|
| 532 |
+
);
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
public function test_query_string_auto_detect_pagination_url()
|
| 536 |
+
{
|
| 537 |
+
// set base_url
|
| 538 |
+
Config::set('base_url', 'http://docs.fuelphp.com/');
|
| 539 |
+
// set Request::$main & $active
|
| 540 |
+
$this->set_request('/');
|
| 541 |
+
|
| 542 |
+
$this->set_query_string_config();
|
| 543 |
+
$this->config['pagination_url'] = null;
|
| 544 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 545 |
+
|
| 546 |
+
// set _make_link() accessible
|
| 547 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 548 |
+
$_make_link->setAccessible(true);
|
| 549 |
+
|
| 550 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 551 |
+
$expected = 'http://docs.fuelphp.com/?p=1';
|
| 552 |
+
$this->assertEquals($expected, $test);
|
| 553 |
+
|
| 554 |
+
// reset base_url
|
| 555 |
+
Config::set('base_url', null);
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
public function test_query_string_get_total_pages()
|
| 559 |
+
{
|
| 560 |
+
// set Request::$main & $active
|
| 561 |
+
$this->set_request('/');
|
| 562 |
+
|
| 563 |
+
$this->set_query_string_config();
|
| 564 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 565 |
+
$test = $pagination->total_pages;
|
| 566 |
+
$expected = 10;
|
| 567 |
+
$this->assertEquals($expected, $test);
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
/**
|
| 571 |
+
* first page
|
| 572 |
+
*
|
| 573 |
+
*/
|
| 574 |
+
public function test_query_string_first_page()
|
| 575 |
+
{
|
| 576 |
+
// set Request::$main & $active
|
| 577 |
+
$this->set_request('/');
|
| 578 |
+
|
| 579 |
+
$this->set_query_string_config();
|
| 580 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 581 |
+
$pagination->current_page = 1;
|
| 582 |
+
|
| 583 |
+
$output = $pagination->previous();
|
| 584 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 585 |
+
$expected = '<span class="previous-inactive"><a href="#" rel="prev">«</a></span>';
|
| 586 |
+
$this->assertEquals($expected, $output);
|
| 587 |
+
|
| 588 |
+
$output = $pagination->pages_render();
|
| 589 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 590 |
+
$expected = '<span class="active"><a href="#">1</a></span><span><a href="http://docs.fuelphp.com/?p=2">2</a></span><span><a href="http://docs.fuelphp.com/?p=3">3</a></span><span><a href="http://docs.fuelphp.com/?p=4">4</a></span><span><a href="http://docs.fuelphp.com/?p=5">5</a></span><span><a href="http://docs.fuelphp.com/?p=6">6</a></span>';
|
| 591 |
+
$this->assertEquals($expected, $output);
|
| 592 |
+
|
| 593 |
+
$output = $pagination->next();
|
| 594 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 595 |
+
$expected = '<span class="next"><a href="http://docs.fuelphp.com/?p=2" rel="next">»</a></span>';
|
| 596 |
+
$this->assertEquals($expected, $output);
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
/**
|
| 600 |
+
* last page
|
| 601 |
+
*
|
| 602 |
+
*/
|
| 603 |
+
public function test_query_string_nextlink_inactive()
|
| 604 |
+
{
|
| 605 |
+
// set Request::$main & $active
|
| 606 |
+
$this->set_request('/');
|
| 607 |
+
|
| 608 |
+
$this->set_query_string_config();
|
| 609 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 610 |
+
$pagination->current_page = 10;
|
| 611 |
+
|
| 612 |
+
$output = $pagination->next();
|
| 613 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 614 |
+
$expected = '<span class="next-inactive"><a href="#" rel="next">»</a></span>';
|
| 615 |
+
$this->assertEquals($expected, $output);
|
| 616 |
+
|
| 617 |
+
$output = $pagination->pages_render();
|
| 618 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 619 |
+
$expected = '<span><a href="http://docs.fuelphp.com/?p=6">6</a></span><span><a href="http://docs.fuelphp.com/?p=7">7</a></span><span><a href="http://docs.fuelphp.com/?p=8">8</a></span><span><a href="http://docs.fuelphp.com/?p=9">9</a></span><span class="active"><a href="#">10</a></span>';
|
| 620 |
+
$this->assertEquals($expected, $output);
|
| 621 |
+
|
| 622 |
+
$output = $pagination->previous();
|
| 623 |
+
$output = str_replace(array("\n", "\t"), "", $output);
|
| 624 |
+
$expected = '<span class="previous"><a href="http://docs.fuelphp.com/?p=9" rel="prev">«</a></span>';
|
| 625 |
+
$this->assertEquals($expected, $output);
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
public function test_query_string_make_link_by_request()
|
| 629 |
+
{
|
| 630 |
+
// set Request::$main & $active
|
| 631 |
+
$this->set_request('welcome/index/?foo=bar&fuel[]=php1&fuel[]=php2&p=40');
|
| 632 |
+
|
| 633 |
+
$this->set_query_string_config();
|
| 634 |
+
$this->config['pagination_url'] = null;
|
| 635 |
+
|
| 636 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 637 |
+
|
| 638 |
+
// set _make_link() accessible
|
| 639 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 640 |
+
$_make_link->setAccessible(true);
|
| 641 |
+
|
| 642 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 643 |
+
$expected = 'welcome/index/?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2&p=1';
|
| 644 |
+
$this->assertEquals($expected, $test);
|
| 645 |
+
|
| 646 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 647 |
+
$expected = 'welcome/index/?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2&p=99';
|
| 648 |
+
$this->assertEquals($expected, $test);
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
public function test_query_string_make_link_by_pagination_url()
|
| 652 |
+
{
|
| 653 |
+
// set Request::$main & $active
|
| 654 |
+
$this->set_request('welcome/index/?foo=bar&fuel[]=php1&fuel[]=php2&p=40');
|
| 655 |
+
|
| 656 |
+
$this->set_query_string_config();
|
| 657 |
+
$this->config['pagination_url'] = 'http://docs.fuelphp.com/?foo=bar&fuel[]=php1&fuel[]=php2';
|
| 658 |
+
|
| 659 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 660 |
+
|
| 661 |
+
// set _make_link() accessible
|
| 662 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 663 |
+
$_make_link->setAccessible(true);
|
| 664 |
+
|
| 665 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 666 |
+
$expected = 'http://docs.fuelphp.com/?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2&p=1';
|
| 667 |
+
$this->assertEquals($expected, $test);
|
| 668 |
+
|
| 669 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 670 |
+
$expected = 'http://docs.fuelphp.com/?foo=bar&fuel%5B0%5D=php1&fuel%5B1%5D=php2&p=99';
|
| 671 |
+
$this->assertEquals($expected, $test);
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
public function test_query_string_make_link_by_pagination_url_include_page_number()
|
| 675 |
+
{
|
| 676 |
+
// set Request::$main & $active
|
| 677 |
+
$this->set_request('welcome/index/?foo=bar&fuel[]=php1&fuel[]=php2&p=40');
|
| 678 |
+
|
| 679 |
+
$this->set_query_string_config();
|
| 680 |
+
$this->config['pagination_url'] = 'http://docs.fuelphp.com/?foo=bar&p=123&fuel[]=php1&fuel[]=php2';
|
| 681 |
+
|
| 682 |
+
$pagination = Pagination::forge(__METHOD__, $this->config);
|
| 683 |
+
|
| 684 |
+
// set _make_link() accessible
|
| 685 |
+
$_make_link = new \ReflectionMethod($pagination, '_make_link');
|
| 686 |
+
$_make_link->setAccessible(true);
|
| 687 |
+
|
| 688 |
+
$test = $_make_link->invoke($pagination, 1);
|
| 689 |
+
$expected = 'http://docs.fuelphp.com/?foo=bar&p=1&fuel%5B0%5D=php1&fuel%5B1%5D=php2';
|
| 690 |
+
$this->assertEquals($expected, $test);
|
| 691 |
+
|
| 692 |
+
$test = $_make_link->invoke($pagination, 99);
|
| 693 |
+
$expected = 'http://docs.fuelphp.com/?foo=bar&p=99&fuel%5B0%5D=php1&fuel%5B1%5D=php2';
|
| 694 |
+
$this->assertEquals($expected, $test);
|
| 695 |
+
}
|
| 696 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/profiler.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Profiler class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Profiler
|
| 20 |
+
*/
|
| 21 |
+
class Test_Profiler extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/redis.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Redis class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Redis
|
| 20 |
+
*/
|
| 21 |
+
class Test_Redis extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/request.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Request class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Request
|
| 20 |
+
*/
|
| 21 |
+
class Test_Request extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/response.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Response class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Response
|
| 20 |
+
*/
|
| 21 |
+
class Test_Response extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/route.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Route class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Route
|
| 20 |
+
*/
|
| 21 |
+
class Test_Route extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/router.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Router class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Router
|
| 20 |
+
*/
|
| 21 |
+
class Test_Router extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/security.php
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Security class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Security
|
| 20 |
+
*/
|
| 21 |
+
class Test_Security extends TestCase
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* Tests Security::htmlentities()
|
| 25 |
+
*
|
| 26 |
+
* @test
|
| 27 |
+
*/
|
| 28 |
+
public function test_htmlentities_doublequote_and_ampersand()
|
| 29 |
+
{
|
| 30 |
+
$output = Security::htmlentities('"H&M"');
|
| 31 |
+
$expected = '"H&M"';
|
| 32 |
+
$this->assertEquals($expected, $output);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Tests Security::htmlentities()
|
| 37 |
+
*
|
| 38 |
+
* @test
|
| 39 |
+
*/
|
| 40 |
+
public function test_htmlentities_singlequote()
|
| 41 |
+
{
|
| 42 |
+
$output = Security::htmlentities("'");
|
| 43 |
+
$expected = ''';
|
| 44 |
+
$this->assertEquals($expected, $output);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Tests Security::htmlentities()
|
| 49 |
+
*
|
| 50 |
+
* @test
|
| 51 |
+
*/
|
| 52 |
+
public function test_htmlentities_charactor_references_no_double_encode()
|
| 53 |
+
{
|
| 54 |
+
$output = Security::htmlentities('You must write & as &');
|
| 55 |
+
$expected = 'You must write & as &';
|
| 56 |
+
$this->assertEquals($expected, $output);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Tests Security::htmlentities()
|
| 61 |
+
*
|
| 62 |
+
* @test
|
| 63 |
+
*/
|
| 64 |
+
public function test_htmlentities_charactor_references_double_encode()
|
| 65 |
+
{
|
| 66 |
+
$config = \Config::get('security.htmlentities_double_encode');
|
| 67 |
+
\Config::set('security.htmlentities_double_encode', true);
|
| 68 |
+
|
| 69 |
+
$output = Security::htmlentities('You must write & as &');
|
| 70 |
+
$expected = 'You must write & as &amp;';
|
| 71 |
+
$this->assertEquals($expected, $output);
|
| 72 |
+
|
| 73 |
+
\Config::set('security.htmlentities_double_encode', $config);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Tests Security::htmlentities()
|
| 78 |
+
*
|
| 79 |
+
* @test
|
| 80 |
+
*/
|
| 81 |
+
public function test_htmlentities_double_encode()
|
| 82 |
+
{
|
| 83 |
+
$output = Security::htmlentities('"H&M"');
|
| 84 |
+
$output = Security::htmlentities($output);
|
| 85 |
+
$expected = '"H&M"';
|
| 86 |
+
$this->assertEquals($expected, $output);
|
| 87 |
+
}
|
| 88 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/session.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Session class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Session
|
| 20 |
+
*/
|
| 21 |
+
class Test_Session extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/str.php
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Str class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Str
|
| 20 |
+
*/
|
| 21 |
+
class Test_Str extends TestCase
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
public function truncate_provider()
|
| 25 |
+
{
|
| 26 |
+
return array(
|
| 27 |
+
array(15, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'),
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Test for Str::truncate()
|
| 33 |
+
*
|
| 34 |
+
* @test
|
| 35 |
+
* @dataProvider truncate_provider
|
| 36 |
+
*/
|
| 37 |
+
public function test_truncate_plain($limit, $string)
|
| 38 |
+
{
|
| 39 |
+
$output = Str::truncate($string, $limit);
|
| 40 |
+
$expected = 'Lorem ipsum dol...';
|
| 41 |
+
$this->assertEquals($expected, $output);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Test for Str::truncate()
|
| 46 |
+
*
|
| 47 |
+
* @test
|
| 48 |
+
* @dataProvider truncate_provider
|
| 49 |
+
*/
|
| 50 |
+
public function test_truncate_custom_continuation($limit, $string)
|
| 51 |
+
{
|
| 52 |
+
$output = Str::truncate($string, $limit, '..');
|
| 53 |
+
$expected = 'Lorem ipsum dol..';
|
| 54 |
+
$this->assertEquals($expected, $output);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Test for Str::truncate()
|
| 59 |
+
*
|
| 60 |
+
* @test
|
| 61 |
+
* @dataProvider truncate_provider
|
| 62 |
+
*/
|
| 63 |
+
public function test_truncate_not_html($limit, $string)
|
| 64 |
+
{
|
| 65 |
+
$string = '<h1>'.$string.'</h1>';
|
| 66 |
+
|
| 67 |
+
$output = Str::truncate($string, $limit, '...', false);
|
| 68 |
+
$expected = '<h1>Lorem ipsum...';
|
| 69 |
+
$this->assertEquals($expected, $output);
|
| 70 |
+
|
| 71 |
+
$output = Str::truncate($string, $limit, '...', true);
|
| 72 |
+
$expected = '<h1>Lorem ipsum dol...</h1>';
|
| 73 |
+
$this->assertEquals($expected, $output);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Test for Str::truncate()
|
| 78 |
+
*
|
| 79 |
+
* @test
|
| 80 |
+
* @dataProvider truncate_provider
|
| 81 |
+
*/
|
| 82 |
+
public function test_truncate_is_html($limit, $string)
|
| 83 |
+
{
|
| 84 |
+
$string = '<h1>'.$string.'</h1>';
|
| 85 |
+
|
| 86 |
+
$output = Str::truncate($string, $limit, '...', true);
|
| 87 |
+
$expected = '<h1>Lorem ipsum dol...</h1>';
|
| 88 |
+
$this->assertEquals($expected, $output);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Test for Str::truncate()
|
| 93 |
+
*
|
| 94 |
+
* @test
|
| 95 |
+
* @dataProvider truncate_provider
|
| 96 |
+
*/
|
| 97 |
+
public function test_truncate_multiple_tags($limit, $string)
|
| 98 |
+
{
|
| 99 |
+
$limit = 400;
|
| 100 |
+
$string = '<p><strong>'.$string.'</strong></p>';
|
| 101 |
+
|
| 102 |
+
$output = Str::truncate($string, $limit, '...', true);
|
| 103 |
+
$this->assertEquals($string, $output);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* Test for Str::increment()
|
| 108 |
+
*
|
| 109 |
+
* @test
|
| 110 |
+
*/
|
| 111 |
+
public function test_increment()
|
| 112 |
+
{
|
| 113 |
+
$values = array('valueA', 'valueB', 'valueC');
|
| 114 |
+
|
| 115 |
+
for ($i = 0; $i < count($values); $i ++)
|
| 116 |
+
{
|
| 117 |
+
$output = Str::increment($values[$i], $i);
|
| 118 |
+
$expected = $values[$i].'_'.$i;
|
| 119 |
+
|
| 120 |
+
$this->assertEquals($expected, $output);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Test for Str::lower()
|
| 126 |
+
*
|
| 127 |
+
* @test
|
| 128 |
+
*/
|
| 129 |
+
public function test_lower()
|
| 130 |
+
{
|
| 131 |
+
$output = Str::lower('HELLO WORLD');
|
| 132 |
+
$expected = "hello world";
|
| 133 |
+
|
| 134 |
+
$this->assertEquals($expected, $output);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Test for Str::upper()
|
| 139 |
+
*
|
| 140 |
+
* @test
|
| 141 |
+
*/
|
| 142 |
+
public function test_upper()
|
| 143 |
+
{
|
| 144 |
+
$output = Str::upper('hello world');
|
| 145 |
+
$expected = "HELLO WORLD";
|
| 146 |
+
|
| 147 |
+
$this->assertEquals($expected, $output);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Test for Str::lcfirst()
|
| 152 |
+
*
|
| 153 |
+
* @test
|
| 154 |
+
*/
|
| 155 |
+
public function test_lcfirst()
|
| 156 |
+
{
|
| 157 |
+
$output = Str::lcfirst('Hello World');
|
| 158 |
+
$expected = "hello World";
|
| 159 |
+
|
| 160 |
+
$this->assertEquals($expected, $output);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Test for Str::ucfirst()
|
| 165 |
+
*
|
| 166 |
+
* @test
|
| 167 |
+
*/
|
| 168 |
+
public function test_ucfirst()
|
| 169 |
+
{
|
| 170 |
+
$output = Str::ucfirst('hello world');
|
| 171 |
+
$expected = "Hello world";
|
| 172 |
+
|
| 173 |
+
$this->assertEquals($expected, $output);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Test for Str::ucwords()
|
| 178 |
+
*
|
| 179 |
+
* @test
|
| 180 |
+
*/
|
| 181 |
+
public function test_ucwords()
|
| 182 |
+
{
|
| 183 |
+
$output = Str::ucwords('hello world');
|
| 184 |
+
$expected = "Hello World";
|
| 185 |
+
|
| 186 |
+
$this->assertEquals($expected, $output);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* Test for Str::random()
|
| 191 |
+
*
|
| 192 |
+
* @test
|
| 193 |
+
*/
|
| 194 |
+
public function test_random()
|
| 195 |
+
{
|
| 196 |
+
// testing length
|
| 197 |
+
$output = Str::random('alnum', 34);
|
| 198 |
+
$this->assertEquals(34, strlen($output));
|
| 199 |
+
|
| 200 |
+
// testing alnum
|
| 201 |
+
$output = Str::random('alnum', 15);
|
| 202 |
+
$this->assertTrue(ctype_alnum($output));
|
| 203 |
+
|
| 204 |
+
// testing numeric
|
| 205 |
+
$output = Str::random('numeric', 20);
|
| 206 |
+
$this->assertTrue(ctype_digit($output));
|
| 207 |
+
|
| 208 |
+
// testing alpha
|
| 209 |
+
$output = Str::random('alpha', 35);
|
| 210 |
+
$this->assertTrue(ctype_alpha($output));
|
| 211 |
+
|
| 212 |
+
// testing nozero
|
| 213 |
+
$output = Str::random('nozero', 22);
|
| 214 |
+
$this->assertFalse(strpos($output, '0'));
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Test for Str::is_json()
|
| 219 |
+
*
|
| 220 |
+
* @test
|
| 221 |
+
*/
|
| 222 |
+
public function test_is_json()
|
| 223 |
+
{
|
| 224 |
+
$values = array('fuelphp','is' => array('awesome' => true));
|
| 225 |
+
|
| 226 |
+
$string = json_encode($values);
|
| 227 |
+
$this->assertTrue(Str::is_json($string));
|
| 228 |
+
|
| 229 |
+
$string = serialize($values);
|
| 230 |
+
$this->assertFalse(Str::is_json($string));
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
/**
|
| 234 |
+
* Test for Str::is_xml()
|
| 235 |
+
*
|
| 236 |
+
* @test
|
| 237 |
+
* @requires extension libxml
|
| 238 |
+
*/
|
| 239 |
+
public function test_is_xml()
|
| 240 |
+
{
|
| 241 |
+
$valid_xml = '<?xml version="1.0" encoding="UTF-8"?>
|
| 242 |
+
<phpunit colors="true" stopOnFailure="false" bootstrap="bootstrap_phpunit.php">
|
| 243 |
+
<php>
|
| 244 |
+
<server name="doc_root" value="../../"/>
|
| 245 |
+
<server name="app_path" value="fuel/app"/>
|
| 246 |
+
<server name="core_path" value="fuel/core"/>
|
| 247 |
+
<server name="package_path" value="fuel/packages"/>
|
| 248 |
+
</php>
|
| 249 |
+
</phpunit>';
|
| 250 |
+
|
| 251 |
+
$invalid_xml = '<?xml version="1.0" encoding="UTF-8"?>
|
| 252 |
+
<phpunit colors="true" stopOnFailure="false" bootstrap="bootstrap_phpunit.php">
|
| 253 |
+
<php>
|
| 254 |
+
<server name="doc_root" value="../../"/>
|
| 255 |
+
<server name="app_path" value="fuel/app"/>
|
| 256 |
+
<server name="core_path" value="fuel/core"/>
|
| 257 |
+
<server name="package_path" value="fuel/packages"/>
|
| 258 |
+
</
|
| 259 |
+
</phpunit>';
|
| 260 |
+
|
| 261 |
+
$this->assertTrue(Str::is_xml($valid_xml));
|
| 262 |
+
$this->assertFalse(Str::is_xml($invalid_xml));
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/**
|
| 266 |
+
* Test for Str::is_serialized()
|
| 267 |
+
*
|
| 268 |
+
* @test
|
| 269 |
+
*/
|
| 270 |
+
public function test_is_serialized()
|
| 271 |
+
{
|
| 272 |
+
$values = array('fuelphp','is' => array('awesome' => true));
|
| 273 |
+
|
| 274 |
+
$string = json_encode($values);
|
| 275 |
+
$this->assertFalse(Str::is_serialized($string));
|
| 276 |
+
|
| 277 |
+
$string = serialize($values);
|
| 278 |
+
$this->assertTrue(Str::is_serialized($string));
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Test for Str::is_html()
|
| 283 |
+
*
|
| 284 |
+
* @test
|
| 285 |
+
*/
|
| 286 |
+
public function test_is_html()
|
| 287 |
+
{
|
| 288 |
+
$html = '<div class="row"><div class="span12"><strong>FuelPHP</strong> is a simple, flexible, <i>community<i> driven PHP 5.3 web framework based on the best ideas of other frameworks with a fresh start.</p>';
|
| 289 |
+
$simple_string = strip_tags($html);
|
| 290 |
+
|
| 291 |
+
$this->assertTrue(Str::is_html($html));
|
| 292 |
+
$this->assertFalse(Str::is_html($simple_string));
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* Test for Str::starts_with()
|
| 297 |
+
*
|
| 298 |
+
* @test
|
| 299 |
+
*/
|
| 300 |
+
public function test_starts_with()
|
| 301 |
+
{
|
| 302 |
+
$string = 'HELLO WORLD';
|
| 303 |
+
|
| 304 |
+
$output = Str::starts_with($string, 'HELLO');
|
| 305 |
+
$this->assertTrue($output);
|
| 306 |
+
|
| 307 |
+
$output = Str::starts_with($string, 'hello');
|
| 308 |
+
$this->assertFalse($output);
|
| 309 |
+
|
| 310 |
+
$output = Str::starts_with($string, 'hello', true);
|
| 311 |
+
$this->assertTrue($output);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
/**
|
| 315 |
+
* Test for Str::ends_with()
|
| 316 |
+
*
|
| 317 |
+
* @test
|
| 318 |
+
*/
|
| 319 |
+
public function test_ends_with()
|
| 320 |
+
{
|
| 321 |
+
$string = 'HELLO WORLD';
|
| 322 |
+
|
| 323 |
+
$output = Str::ends_with($string, 'WORLD');
|
| 324 |
+
$this->assertTrue($output);
|
| 325 |
+
|
| 326 |
+
$output = Str::ends_with($string, 'world');
|
| 327 |
+
$this->assertFalse($output);
|
| 328 |
+
|
| 329 |
+
$output = Str::ends_with($string, 'world', true);
|
| 330 |
+
$this->assertTrue($output);
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
* Test for Str::alternator()
|
| 335 |
+
*
|
| 336 |
+
* @test
|
| 337 |
+
*/
|
| 338 |
+
public function test_alternator()
|
| 339 |
+
{
|
| 340 |
+
$alt = Str::alternator('one', 'two', 'three');
|
| 341 |
+
|
| 342 |
+
$output = $alt();
|
| 343 |
+
$expected = 'one';
|
| 344 |
+
$this->assertEquals($output, $expected);
|
| 345 |
+
|
| 346 |
+
$output = $alt(false);
|
| 347 |
+
$expected = 'two';
|
| 348 |
+
$this->assertEquals($output, $expected);
|
| 349 |
+
|
| 350 |
+
$output = $alt();
|
| 351 |
+
$expected = 'two';
|
| 352 |
+
$this->assertEquals($output, $expected);
|
| 353 |
+
|
| 354 |
+
$output = $alt();
|
| 355 |
+
$expected = 'three';
|
| 356 |
+
$this->assertEquals($output, $expected);
|
| 357 |
+
|
| 358 |
+
$output = $alt();
|
| 359 |
+
$expected = 'one';
|
| 360 |
+
$this->assertEquals($output, $expected);
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/testcase.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Testcase class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Testcase
|
| 20 |
+
*/
|
| 21 |
+
class Test_Testcase extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/unzip.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Unzip class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Unzip
|
| 20 |
+
*/
|
| 21 |
+
class Test_Unzip extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/upload.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Upload class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Upload
|
| 20 |
+
*/
|
| 21 |
+
class Test_Upload extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public function test_foo() {}
|
| 24 |
+
}
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/uri.php
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.6
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Html class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Uri
|
| 20 |
+
*/
|
| 21 |
+
class Test_Uri extends TestCase
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Tests Uri::create()
|
| 26 |
+
*
|
| 27 |
+
* @test
|
| 28 |
+
*/
|
| 29 |
+
public function test_create()
|
| 30 |
+
{
|
| 31 |
+
Config::set('url_suffix', '');
|
| 32 |
+
|
| 33 |
+
$prefix = Uri::create('');
|
| 34 |
+
|
| 35 |
+
Config::set('index_file', 'index.php');
|
| 36 |
+
$output = Uri::create('controller/method');
|
| 37 |
+
$expected = $prefix."index.php/controller/method";
|
| 38 |
+
$this->assertEquals($expected, $output);
|
| 39 |
+
|
| 40 |
+
Config::set('index_file', '');
|
| 41 |
+
|
| 42 |
+
$output = Uri::create('controller/method');
|
| 43 |
+
$expected = $prefix."controller/method";
|
| 44 |
+
$this->assertEquals($expected, $output);
|
| 45 |
+
|
| 46 |
+
$output = Uri::create('controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
|
| 47 |
+
$expected = $prefix."controller/thing?what=more";
|
| 48 |
+
$this->assertEquals($expected, $output);
|
| 49 |
+
|
| 50 |
+
Config::set('url_suffix', '.html');
|
| 51 |
+
|
| 52 |
+
$output = Uri::create('controller/method');
|
| 53 |
+
$expected = $prefix."controller/method.html";
|
| 54 |
+
$this->assertEquals($expected, $output);
|
| 55 |
+
|
| 56 |
+
$output = Uri::create('controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
|
| 57 |
+
$expected = $prefix."controller/thing.html?what=more";
|
| 58 |
+
$this->assertEquals($expected, $output);
|
| 59 |
+
|
| 60 |
+
$output = Uri::create('http://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
|
| 61 |
+
$expected = "http://example.com/controller/thing.html?what=more";
|
| 62 |
+
$this->assertEquals($expected, $output);
|
| 63 |
+
|
| 64 |
+
$output = Uri::create('http://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'), true);
|
| 65 |
+
$expected = "https://example.com/controller/thing.html?what=more";
|
| 66 |
+
$this->assertEquals($expected, $output);
|
| 67 |
+
|
| 68 |
+
$output = Uri::create('https://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'), false);
|
| 69 |
+
$expected = "http://example.com/controller/thing.html?what=more";
|
| 70 |
+
$this->assertEquals($expected, $output);
|
| 71 |
+
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Tests Uri::base()
|
| 76 |
+
*
|
| 77 |
+
* @test
|
| 78 |
+
*/
|
| 79 |
+
public function test_base()
|
| 80 |
+
{
|
| 81 |
+
Config::set('base_url', null);
|
| 82 |
+
Config::set('index_file', false);
|
| 83 |
+
|
| 84 |
+
$output = Uri::base();
|
| 85 |
+
$expected = null;
|
| 86 |
+
$this->assertEquals($expected, $output);
|
| 87 |
+
|
| 88 |
+
Config::set('base_url', 'http://example.com/');
|
| 89 |
+
Config::set('index_file', 'index.php');
|
| 90 |
+
|
| 91 |
+
$output = Uri::base();
|
| 92 |
+
$expected = 'http://example.com/index.php/';
|
| 93 |
+
$this->assertEquals($expected, $output);
|
| 94 |
+
|
| 95 |
+
$output = Uri::base(false);
|
| 96 |
+
$expected = 'http://example.com/';
|
| 97 |
+
$this->assertEquals($expected, $output);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Tests Uri::current()
|
| 102 |
+
*
|
| 103 |
+
* @test
|
| 104 |
+
*/
|
| 105 |
+
public function test_current()
|
| 106 |
+
{
|
| 107 |
+
$output = Uri::current();
|
| 108 |
+
$expected = Uri::create();
|
| 109 |
+
$this->assertEquals($expected, $output);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* Tests Uri::build_query_string()
|
| 114 |
+
*
|
| 115 |
+
* @test
|
| 116 |
+
*/
|
| 117 |
+
public function test_build_query_string()
|
| 118 |
+
{
|
| 119 |
+
$output = Uri::build_query_string(array('varA' => 'varA'), 'varB', array('varC' => 'varC'));
|
| 120 |
+
$expected = "varA=varA&varB=1&varC=varC";
|
| 121 |
+
$this->assertEquals($expected, $output);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Tests Uri::update_query_string()
|
| 126 |
+
*
|
| 127 |
+
* @test
|
| 128 |
+
*/
|
| 129 |
+
public function test_update_query_string()
|
| 130 |
+
{
|
| 131 |
+
Config::set('base_url', 'http://example.com/test');
|
| 132 |
+
Config::set('index_file', null);
|
| 133 |
+
Config::set('url_suffix', '');
|
| 134 |
+
$_GET = array('one' => 1, 'two' => 2);
|
| 135 |
+
|
| 136 |
+
$output = Uri::update_query_string(array('three' => 3));
|
| 137 |
+
$expected = 'http://example.com/test?one=1&two=2&three=3';
|
| 138 |
+
$this->assertEquals($expected, $output);
|
| 139 |
+
|
| 140 |
+
$output = Uri::update_query_string(array('two' => 3));
|
| 141 |
+
$expected = 'http://example.com/test?one=1&two=3';
|
| 142 |
+
$this->assertEquals($expected, $output);
|
| 143 |
+
|
| 144 |
+
$output = Uri::update_query_string(array('four' => 4), 'http://localhost/controller');
|
| 145 |
+
$expected = 'http://localhost/controller?four=4';
|
| 146 |
+
$this->assertEquals($expected, $output);
|
| 147 |
+
|
| 148 |
+
$output = Uri::update_query_string('three', 3, true);
|
| 149 |
+
$expected = 'https://example.com/test?one=1&two=2&three=3';
|
| 150 |
+
$this->assertEquals($expected, $output);
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
|
benchmark/NYU_CTF_Bench/development/2013/CSAW-Finals/web/historypeats/csaw/fuel/core/tests/validation.php
ADDED
|
@@ -0,0 +1,840 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Part of the Fuel framework.
|
| 4 |
+
*
|
| 5 |
+
* @package Fuel
|
| 6 |
+
* @version 1.7
|
| 7 |
+
* @author Fuel Development Team
|
| 8 |
+
* @license MIT License
|
| 9 |
+
* @copyright 2010 - 2013 Fuel Development Team
|
| 10 |
+
* @link http://fuelphp.com
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
namespace Fuel\Core;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Validation class tests
|
| 17 |
+
*
|
| 18 |
+
* @group Core
|
| 19 |
+
* @group Validation
|
| 20 |
+
*/
|
| 21 |
+
class Test_Validation extends TestCase
|
| 22 |
+
{
|
| 23 |
+
public static function form_provider()
|
| 24 |
+
{
|
| 25 |
+
return array(
|
| 26 |
+
array(
|
| 27 |
+
array(
|
| 28 |
+
'foo' => 'bar',
|
| 29 |
+
'bar' => 'foo',
|
| 30 |
+
'boo' => 'bar',
|
| 31 |
+
'cat' => '',
|
| 32 |
+
'dog' => '245abc',
|
| 33 |
+
'php' => 1,
|
| 34 |
+
'sky' => 'blue',
|
| 35 |
+
'one' => 'john@doe.com',
|
| 36 |
+
'two' => 'john@doe.com, jane@doe.com',
|
| 37 |
+
'owt' => 'john@doe.com; jane@doe.com',
|
| 38 |
+
'six' => 6,
|
| 39 |
+
'ten' => 10,
|
| 40 |
+
'dns' => '127.0.0.1',
|
| 41 |
+
'snd' => '127.0.0',
|
| 42 |
+
'url' => 'http://www.google.com',
|
| 43 |
+
)
|
| 44 |
+
)
|
| 45 |
+
);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Validation: required
|
| 50 |
+
* Expecting: success
|
| 51 |
+
*
|
| 52 |
+
* @dataProvider form_provider
|
| 53 |
+
*/
|
| 54 |
+
public function test_validation_required_success($input)
|
| 55 |
+
{
|
| 56 |
+
$val = Validation::forge(__FUNCTION__);
|
| 57 |
+
$val->add_field('foo', 'Foo', 'required');
|
| 58 |
+
|
| 59 |
+
$output = $val->run($input);
|
| 60 |
+
$expected = true;
|
| 61 |
+
|
| 62 |
+
$this->assertEquals($expected, $output);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Validation: required
|
| 67 |
+
* Expecting: failure
|
| 68 |
+
*
|
| 69 |
+
* @dataProvider form_provider
|
| 70 |
+
*/
|
| 71 |
+
public function test_validation_required_failure($input)
|
| 72 |
+
{
|
| 73 |
+
$val = Validation::forge(__FUNCTION__);
|
| 74 |
+
$val->add_field('cat', 'Cat', 'required');
|
| 75 |
+
$val->run($input);
|
| 76 |
+
|
| 77 |
+
$output = $val->error('cat', false) ? true : false;
|
| 78 |
+
$expected = true;
|
| 79 |
+
|
| 80 |
+
$this->assertEquals($expected, $output);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Validation: match_value
|
| 85 |
+
* Expecting: success
|
| 86 |
+
*
|
| 87 |
+
* @dataProvider form_provider
|
| 88 |
+
*/
|
| 89 |
+
public function test_validation_match_value_success($input)
|
| 90 |
+
{
|
| 91 |
+
$val = Validation::forge(__FUNCTION__);
|
| 92 |
+
$val->add_field('foo', 'Foo', 'match_value[bar]');
|
| 93 |
+
|
| 94 |
+
$output = $val->run($input);
|
| 95 |
+
$expected = true;
|
| 96 |
+
|
| 97 |
+
$this->assertEquals($expected, $output);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Validation: match_value
|
| 102 |
+
* Expecting: failure
|
| 103 |
+
*
|
| 104 |
+
* @dataProvider form_provider
|
| 105 |
+
*/
|
| 106 |
+
public function test_validation_match_value_failure($input)
|
| 107 |
+
{
|
| 108 |
+
$val = Validation::forge(__FUNCTION__);
|
| 109 |
+
$val->add_field('foo', 'Foo', "match_value['foo']");
|
| 110 |
+
$val->run($input);
|
| 111 |
+
|
| 112 |
+
$output = $val->error('foo', false) ? true : false;
|
| 113 |
+
$expected = true;
|
| 114 |
+
|
| 115 |
+
$this->assertEquals($expected, $output);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Validation: match_value (strict)
|
| 120 |
+
* Expecting: success
|
| 121 |
+
*
|
| 122 |
+
* @dataProvider form_provider
|
| 123 |
+
*/
|
| 124 |
+
public function test_validation_match_value_strict_success($input)
|
| 125 |
+
{
|
| 126 |
+
$val = Validation::forge(__FUNCTION__);
|
| 127 |
+
$val->add_field('php', 'PHP', '')->add_rule('match_value', 1, 1);
|
| 128 |
+
|
| 129 |
+
$output = $val->run($input);
|
| 130 |
+
$expected = true;
|
| 131 |
+
|
| 132 |
+
$this->assertEquals($expected, $output);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Validation: match_value (strict)
|
| 137 |
+
* Expecting: failure
|
| 138 |
+
*
|
| 139 |
+
* @dataProvider form_provider
|
| 140 |
+
*/
|
| 141 |
+
public function test_validation_match_value_strict_failure($input)
|
| 142 |
+
{
|
| 143 |
+
$val = Validation::forge(__FUNCTION__);
|
| 144 |
+
$val->add_field('php', 'PHP', '')->add_rule('match_value', '1', 1);
|
| 145 |
+
$val->run($input);
|
| 146 |
+
|
| 147 |
+
$output = $val->error('php', false) ? true : false;
|
| 148 |
+
$expected = true;
|
| 149 |
+
|
| 150 |
+
$this->assertEquals($expected, $output);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Validation: match_pattern
|
| 155 |
+
* Expecting: success
|
| 156 |
+
*
|
| 157 |
+
* @dataProvider form_provider
|
| 158 |
+
*/
|
| 159 |
+
public function test_validation_match_pattern_success($input)
|
| 160 |
+
{
|
| 161 |
+
$val = Validation::forge(__FUNCTION__);
|
| 162 |
+
$val->add_field('dog', 'Dog', '')->add_rule('match_pattern', '/\d{3}\w{3}/');
|
| 163 |
+
|
| 164 |
+
$output = $val->run($input);
|
| 165 |
+
$expected = true;
|
| 166 |
+
|
| 167 |
+
$this->assertEquals($expected, $output);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
/**
|
| 171 |
+
* Validation: match_pattern
|
| 172 |
+
* Expecting: failure
|
| 173 |
+
*
|
| 174 |
+
* @dataProvider form_provider
|
| 175 |
+
*/
|
| 176 |
+
public function test_validation_match_pattern_failure($input)
|
| 177 |
+
{
|
| 178 |
+
$val = Validation::forge(__FUNCTION__);
|
| 179 |
+
$val->add_field('dog', 'Dog', '')->add_rule('match_pattern', '/^\d{2}[abc]{3}/');
|
| 180 |
+
$val->run($input);
|
| 181 |
+
|
| 182 |
+
$output = $val->error('dog', false) ? true : false;
|
| 183 |
+
$expected = true;
|
| 184 |
+
|
| 185 |
+
$this->assertEquals($expected, $output);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Validation: match_field
|
| 190 |
+
* Expecting: success
|
| 191 |
+
*
|
| 192 |
+
* @dataProvider form_provider
|
| 193 |
+
*/
|
| 194 |
+
public function test_validation_match_field_success($input)
|
| 195 |
+
{
|
| 196 |
+
$val = Validation::forge(__FUNCTION__);
|
| 197 |
+
$val->add_field('foo', 'Foo', 'valid_string');
|
| 198 |
+
$val->add_field('boo', 'Boo', 'match_field[foo]');
|
| 199 |
+
|
| 200 |
+
$output = $val->run($input);
|
| 201 |
+
$expected = true;
|
| 202 |
+
|
| 203 |
+
$this->assertEquals($expected, $output);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Validation: match_field
|
| 208 |
+
* Expecting: failure
|
| 209 |
+
*
|
| 210 |
+
* @dataProvider form_provider
|
| 211 |
+
*/
|
| 212 |
+
public function test_validation_match_field_failure($input)
|
| 213 |
+
{
|
| 214 |
+
$val = Validation::forge(__FUNCTION__);
|
| 215 |
+
$val->add_field('bar', 'Bar', 'valid_string');
|
| 216 |
+
$val->add_field('boo', 'Boo', 'match_field[bar]');
|
| 217 |
+
$val->run($input);
|
| 218 |
+
|
| 219 |
+
$output = $val->error('boo', false) ? true : false;
|
| 220 |
+
$expected = true;
|
| 221 |
+
|
| 222 |
+
$this->assertEquals($expected, $output);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
* Validation: min_length
|
| 227 |
+
* Expecting: success
|
| 228 |
+
*
|
| 229 |
+
* @dataProvider form_provider
|
| 230 |
+
*/
|
| 231 |
+
public function test_validation_min_length_success($input)
|
| 232 |
+
{
|
| 233 |
+
$val = Validation::forge(__FUNCTION__);
|
| 234 |
+
$val->add_field('boo', 'Boo', 'min_length[2]');
|
| 235 |
+
|
| 236 |
+
$output = $val->run($input);
|
| 237 |
+
$expected = true;
|
| 238 |
+
|
| 239 |
+
$this->assertEquals($expected, $output);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* Validation: min_length
|
| 244 |
+
* Expecting: failure
|
| 245 |
+
*
|
| 246 |
+
* @dataProvider form_provider
|
| 247 |
+
*/
|
| 248 |
+
public function test_validation_min_length_failure($input)
|
| 249 |
+
{
|
| 250 |
+
$val = Validation::forge(__FUNCTION__);
|
| 251 |
+
$val->add_field('boo', 'Boo', 'min_length[4]');
|
| 252 |
+
$val->run($input);
|
| 253 |
+
|
| 254 |
+
$output = $val->error('boo', false) ? true : false;
|
| 255 |
+
$expected = true;
|
| 256 |
+
|
| 257 |
+
$this->assertEquals($expected, $output);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
/**
|
| 261 |
+
* Validation: max_length
|
| 262 |
+
* Expecting: success
|
| 263 |
+
*
|
| 264 |
+
* @dataProvider form_provider
|
| 265 |
+
*/
|
| 266 |
+
public function test_validation_max_length_success($input)
|
| 267 |
+
{
|
| 268 |
+
$val = Validation::forge(__FUNCTION__);
|
| 269 |
+
$val->add_field('boo', 'Boo', 'max_length[4]');
|
| 270 |
+
|
| 271 |
+
$output = $val->run($input);
|
| 272 |
+
$expected = true;
|
| 273 |
+
|
| 274 |
+
$this->assertEquals($expected, $output);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/**
|
| 278 |
+
* Validation: max_length
|
| 279 |
+
* Expecting: failure
|
| 280 |
+
*
|
| 281 |
+
* @dataProvider form_provider
|
| 282 |
+
*/
|
| 283 |
+
public function test_validation_max_length_failure($input)
|
| 284 |
+
{
|
| 285 |
+
$val = Validation::forge(__FUNCTION__);
|
| 286 |
+
$val->add_field('boo', 'Boo', 'max_length[2]');
|
| 287 |
+
$val->run($input);
|
| 288 |
+
|
| 289 |
+
$output = $val->error('boo', false) ? true : false;
|
| 290 |
+
$expected = true;
|
| 291 |
+
|
| 292 |
+
$this->assertEquals($expected, $output);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* Validation: exact_length
|
| 297 |
+
* Expecting: success
|
| 298 |
+
*
|
| 299 |
+
* @dataProvider form_provider
|
| 300 |
+
*/
|
| 301 |
+
public function test_validation_exact_length_success($input)
|
| 302 |
+
{
|
| 303 |
+
$val = Validation::forge(__FUNCTION__);
|
| 304 |
+
$val->add_field('boo', 'Boo', 'exact_length[3]');
|
| 305 |
+
|
| 306 |
+
$output = $val->run($input);
|
| 307 |
+
$expected = true;
|
| 308 |
+
|
| 309 |
+
$this->assertEquals($expected, $output);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
/**
|
| 313 |
+
* Validation: exact_length
|
| 314 |
+
* Expecting: failure
|
| 315 |
+
*
|
| 316 |
+
* @dataProvider form_provider
|
| 317 |
+
*/
|
| 318 |
+
public function test_validation_exact_length_failure($input)
|
| 319 |
+
{
|
| 320 |
+
$val = Validation::forge(__FUNCTION__);
|
| 321 |
+
$val->add_field('boo', 'Boo', 'max_length[2]');
|
| 322 |
+
$val->run($input);
|
| 323 |
+
|
| 324 |
+
$output = $val->error('boo', false) ? true : false;
|
| 325 |
+
$expected = true;
|
| 326 |
+
|
| 327 |
+
$this->assertEquals($expected, $output);
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
* Validation: valid_email
|
| 332 |
+
* Expecting: success
|
| 333 |
+
*
|
| 334 |
+
* @dataProvider form_provider
|
| 335 |
+
*/
|
| 336 |
+
public function test_validation_valid_email_success($input)
|
| 337 |
+
{
|
| 338 |
+
$val = Validation::forge(__FUNCTION__);
|
| 339 |
+
$val->add_field('one', 'Email', 'valid_email');
|
| 340 |
+
|
| 341 |
+
$output = $val->run($input);
|
| 342 |
+
$expected = true;
|
| 343 |
+
|
| 344 |
+
$this->assertEquals($expected, $output);
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/**
|
| 348 |
+
* Validation: valid_email
|
| 349 |
+
* Expecting: failure
|
| 350 |
+
*
|
| 351 |
+
* @dataProvider form_provider
|
| 352 |
+
*/
|
| 353 |
+
public function test_validation_valid_email_failure($input)
|
| 354 |
+
{
|
| 355 |
+
$val = Validation::forge(__FUNCTION__);
|
| 356 |
+
$val->add_field('boo', 'Email', 'valid_email');
|
| 357 |
+
$val->run($input);
|
| 358 |
+
|
| 359 |
+
$output = $val->error('boo', false) ? true : false;
|
| 360 |
+
$expected = true;
|
| 361 |
+
|
| 362 |
+
$this->assertEquals($expected, $output);
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
/**
|
| 366 |
+
* Validation: valid_emails
|
| 367 |
+
* Expecting: success
|
| 368 |
+
*
|
| 369 |
+
* @dataProvider form_provider
|
| 370 |
+
*/
|
| 371 |
+
public function test_validation_valid_emails_success($input)
|
| 372 |
+
{
|
| 373 |
+
$val = Validation::forge(__FUNCTION__);
|
| 374 |
+
$val->add_field('two', 'Emails', 'valid_emails');
|
| 375 |
+
|
| 376 |
+
$output = $val->run($input);
|
| 377 |
+
$expected = true;
|
| 378 |
+
|
| 379 |
+
$this->assertEquals($expected, $output);
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Validation: valid_emails (different separator)
|
| 384 |
+
* Expecting: success
|
| 385 |
+
*
|
| 386 |
+
* @dataProvider form_provider
|
| 387 |
+
*/
|
| 388 |
+
public function test_validation_valid_emails_separator_success($input)
|
| 389 |
+
{
|
| 390 |
+
$val = Validation::forge(__FUNCTION__);
|
| 391 |
+
$val->add('owt', 'Emails')->add_rule('valid_emails', ';');
|
| 392 |
+
|
| 393 |
+
$output = $val->run($input);
|
| 394 |
+
$expected = true;
|
| 395 |
+
|
| 396 |
+
$this->assertEquals($expected, $output);
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
* Validation: valid_emails
|
| 401 |
+
* Expecting: failure
|
| 402 |
+
*
|
| 403 |
+
* @dataProvider form_provider
|
| 404 |
+
*/
|
| 405 |
+
public function test_validation_valid_emails_failure($input)
|
| 406 |
+
{
|
| 407 |
+
$val = Validation::forge(__FUNCTION__);
|
| 408 |
+
$val->add_field('boo', 'Email', 'valid_emails');
|
| 409 |
+
$val->run($input);
|
| 410 |
+
|
| 411 |
+
$output = $val->error('boo', false) ? true : false;
|
| 412 |
+
$expected = true;
|
| 413 |
+
|
| 414 |
+
$this->assertEquals($expected, $output);
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
/**
|
| 418 |
+
* Validation: valid_url
|
| 419 |
+
* Expecting: success
|
| 420 |
+
*
|
| 421 |
+
* @dataProvider form_provider
|
| 422 |
+
*/
|
| 423 |
+
public function test_validation_valid_url_success($input)
|
| 424 |
+
{
|
| 425 |
+
$val = Validation::forge(__FUNCTION__);
|
| 426 |
+
$val->add_field('url', 'Url', 'valid_url');
|
| 427 |
+
|
| 428 |
+
$output = $val->run($input);
|
| 429 |
+
$expected = true;
|
| 430 |
+
|
| 431 |
+
$this->assertEquals($expected, $output);
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
/**
|
| 435 |
+
* Validation: valid_url
|
| 436 |
+
* Expecting: failure
|
| 437 |
+
*
|
| 438 |
+
* @dataProvider form_provider
|
| 439 |
+
*/
|
| 440 |
+
public function test_validation_valid_url_failure($input)
|
| 441 |
+
{
|
| 442 |
+
$val = Validation::forge(__FUNCTION__);
|
| 443 |
+
$val->add_field('boo', 'Url', 'valid_url');
|
| 444 |
+
$val->run($input);
|
| 445 |
+
|
| 446 |
+
$output = $val->error('boo', false) ? true : false;
|
| 447 |
+
$expected = true;
|
| 448 |
+
|
| 449 |
+
$this->assertEquals($expected, $output);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
/**
|
| 453 |
+
* Validation: valid_ip
|
| 454 |
+
* Expecting: success
|
| 455 |
+
*
|
| 456 |
+
* @dataProvider form_provider
|
| 457 |
+
*/
|
| 458 |
+
public function test_validation_valid_ip_success($input)
|
| 459 |
+
{
|
| 460 |
+
$val = Validation::forge(__FUNCTION__);
|
| 461 |
+
$val->add_field('dns', 'IP', 'valid_ip');
|
| 462 |
+
|
| 463 |
+
$output = $val->run($input);
|
| 464 |
+
$expected = true;
|
| 465 |
+
|
| 466 |
+
$this->assertEquals($expected, $output);
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
/**
|
| 470 |
+
* Validation: valid_ip
|
| 471 |
+
* Expecting: failure
|
| 472 |
+
*
|
| 473 |
+
* @dataProvider form_provider
|
| 474 |
+
*/
|
| 475 |
+
public function test_validation_valid_ip_failure($input)
|
| 476 |
+
{
|
| 477 |
+
$val = Validation::forge(__FUNCTION__);
|
| 478 |
+
$val->add_field('snd', 'IP', 'valid_ip');
|
| 479 |
+
$val->run($input);
|
| 480 |
+
|
| 481 |
+
$output = $val->error('snd', false) ? true : false;
|
| 482 |
+
$expected = true;
|
| 483 |
+
|
| 484 |
+
$this->assertEquals($expected, $output);
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
/**
|
| 488 |
+
* Validation: numeric_min
|
| 489 |
+
* Expecting: success
|
| 490 |
+
*
|
| 491 |
+
* @dataProvider form_provider
|
| 492 |
+
*/
|
| 493 |
+
public function test_validation_numeric_min_success($input)
|
| 494 |
+
{
|
| 495 |
+
$val = Validation::forge(__FUNCTION__);
|
| 496 |
+
$val->add_field('six', 'Number', 'numeric_min[4]');
|
| 497 |
+
|
| 498 |
+
$output = $val->run($input);
|
| 499 |
+
$expected = true;
|
| 500 |
+
|
| 501 |
+
$this->assertEquals($expected, $output);
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
/**
|
| 505 |
+
* Validation: numeric_min
|
| 506 |
+
* Expecting: failure
|
| 507 |
+
*
|
| 508 |
+
* @dataProvider form_provider
|
| 509 |
+
*/
|
| 510 |
+
public function test_validation_numeric_min_failure($input)
|
| 511 |
+
{
|
| 512 |
+
$val = Validation::forge(__FUNCTION__);
|
| 513 |
+
$val->add_field('six', 'Number', 'numeric_min[8]');
|
| 514 |
+
$val->run($input);
|
| 515 |
+
|
| 516 |
+
$output = $val->error('six', false) ? true : false;
|
| 517 |
+
$expected = true;
|
| 518 |
+
|
| 519 |
+
$this->assertEquals($expected, $output);
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
/**
|
| 523 |
+
* Validation: numeric_max
|
| 524 |
+
* Expecting: success
|
| 525 |
+
*
|
| 526 |
+
* @dataProvider form_provider
|
| 527 |
+
*/
|
| 528 |
+
public function test_validation_numeric_max_success($input)
|
| 529 |
+
{
|
| 530 |
+
$val = Validation::forge(__FUNCTION__);
|
| 531 |
+
$val->add_field('ten', 'Number', 'numeric_max[11]');
|
| 532 |
+
|
| 533 |
+
$output = $val->run($input);
|
| 534 |
+
$expected = true;
|
| 535 |
+
|
| 536 |
+
$this->assertEquals($expected, $output);
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
/**
|
| 540 |
+
* Validation: numeric_max
|
| 541 |
+
* Expecting: failure
|
| 542 |
+
*
|
| 543 |
+
* @dataProvider form_provider
|
| 544 |
+
*/
|
| 545 |
+
public function test_validation_numeric_max_failure($input)
|
| 546 |
+
{
|
| 547 |
+
$val = Validation::forge(__FUNCTION__);
|
| 548 |
+
$val->add_field('ten', 'Number', 'numeric_max[8]');
|
| 549 |
+
$val->run($input);
|
| 550 |
+
|
| 551 |
+
$output = $val->error('ten', false) ? true : false;
|
| 552 |
+
$expected = true;
|
| 553 |
+
|
| 554 |
+
$this->assertEquals($expected, $output);
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
/**
|
| 558 |
+
* Validation: numeric_between
|
| 559 |
+
* Expecting: success
|
| 560 |
+
*
|
| 561 |
+
* @dataProvider form_provider
|
| 562 |
+
*/
|
| 563 |
+
public function test_validation_numeric_between_success($input)
|
| 564 |
+
{
|
| 565 |
+
$val = Validation::forge(__FUNCTION__);
|
| 566 |
+
$val->add_field('ten', 'Number', 'numeric_between[9,11]');
|
| 567 |
+
|
| 568 |
+
$output = $val->run($input);
|
| 569 |
+
$expected = true;
|
| 570 |
+
|
| 571 |
+
$this->assertEquals($expected, $output);
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
/**
|
| 575 |
+
* Validation: numeric_between
|
| 576 |
+
* Expecting: failure
|
| 577 |
+
*
|
| 578 |
+
* @dataProvider form_provider
|
| 579 |
+
*/
|
| 580 |
+
public function test_validation_numeric_between_failure($input)
|
| 581 |
+
{
|
| 582 |
+
$val = Validation::forge(__FUNCTION__);
|
| 583 |
+
$val->add_field('ten', 'Number', 'numeric_between[7,8]');
|
| 584 |
+
$val->run($input);
|
| 585 |
+
|
| 586 |
+
$output = $val->error('ten', false) ? true : false;
|
| 587 |
+
$expected = true;
|
| 588 |
+
|
| 589 |
+
$this->assertEquals($expected, $output);
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
/**
|
| 593 |
+
* Validation: required_with
|
| 594 |
+
* Expecting: success
|
| 595 |
+
*
|
| 596 |
+
* @dataProvider form_provider
|
| 597 |
+
*/
|
| 598 |
+
public function test_validation_required_with_success($input)
|
| 599 |
+
{
|
| 600 |
+
$val = Validation::forge(__FUNCTION__);
|
| 601 |
+
$val->add_field('foo', 'Foo', 'valid_string');
|
| 602 |
+
$val->add_field('bar', 'Bar', 'required_with[foo]');
|
| 603 |
+
|
| 604 |
+
$output = $val->run($input);
|
| 605 |
+
$expected = true;
|
| 606 |
+
|
| 607 |
+
$this->assertEquals($expected, $output);
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
/**
|
| 611 |
+
* Validation: valid_string numeric
|
| 612 |
+
* Expecting: success
|
| 613 |
+
*/
|
| 614 |
+
public function test_validation_valid_string_numeric_success()
|
| 615 |
+
{
|
| 616 |
+
$post = array(
|
| 617 |
+
'f1' => '123456',
|
| 618 |
+
);
|
| 619 |
+
|
| 620 |
+
$val = Validation::forge(__FUNCTION__);
|
| 621 |
+
$val->add('f1', 'F1')->add_rule('valid_string', 'numeric');
|
| 622 |
+
$test = $val->run($post);
|
| 623 |
+
$expected = true;
|
| 624 |
+
|
| 625 |
+
$this->assertEquals($expected, $test);
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
/**
|
| 629 |
+
* Validation: valid_string numeric
|
| 630 |
+
* Expecting: failure
|
| 631 |
+
*/
|
| 632 |
+
public function test_validation_valid_string_numeric_failure()
|
| 633 |
+
{
|
| 634 |
+
$post = array(
|
| 635 |
+
'f1' => 'a123456',
|
| 636 |
+
);
|
| 637 |
+
|
| 638 |
+
$val = Validation::forge(__FUNCTION__);
|
| 639 |
+
$val->add('f1', 'F1')->add_rule('valid_string', 'numeric');
|
| 640 |
+
$test = $val->run($post);
|
| 641 |
+
$expected = false;
|
| 642 |
+
|
| 643 |
+
$this->assertEquals($expected, $test);
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
/**
|
| 647 |
+
* Validation: valid_string alpha,numeric
|
| 648 |
+
* Expecting: failure
|
| 649 |
+
*/
|
| 650 |
+
public function test_validation_valid_string_multiple_flags_error_message_add_rule() {
|
| 651 |
+
$post = array(
|
| 652 |
+
'f1' => '123 abc',
|
| 653 |
+
);
|
| 654 |
+
|
| 655 |
+
$val = Validation::forge(__FUNCTION__);
|
| 656 |
+
$val->add('f1', 'F1')->add_rule('valid_string', array('alpha', 'numeric'));
|
| 657 |
+
$val->set_message('valid_string', 'The valid string rule :rule(:param:1) failed for field :label');
|
| 658 |
+
$val->run($post);
|
| 659 |
+
|
| 660 |
+
$test = $val->error('f1')->get_message();
|
| 661 |
+
$expected = 'The valid string rule valid_string(alpha, numeric) failed for field F1';
|
| 662 |
+
|
| 663 |
+
$this->assertEquals($expected, $test);
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
/**
|
| 667 |
+
* Validation: valid_string alpha,numeric
|
| 668 |
+
* Expecting: failure
|
| 669 |
+
*/
|
| 670 |
+
public function test_validation_valid_string_multiple_flags_error_message_add_field() {
|
| 671 |
+
$post = array(
|
| 672 |
+
'f1' => '123 abc',
|
| 673 |
+
);
|
| 674 |
+
|
| 675 |
+
$val = Validation::forge(__FUNCTION__);
|
| 676 |
+
$val->add_field('f1', 'F1', 'valid_string[alpha,numeric]');
|
| 677 |
+
$val->set_message('valid_string', 'The valid string rule :rule(:param:1) failed for field :label');
|
| 678 |
+
$val->run($post);
|
| 679 |
+
|
| 680 |
+
$test = $val->error('f1')->get_message();
|
| 681 |
+
$expected = 'The valid string rule valid_string(alpha, numeric) failed for field F1';
|
| 682 |
+
|
| 683 |
+
$this->assertEquals($expected, $test);
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
/**
|
| 687 |
+
* Validation: valid_date
|
| 688 |
+
* Expecting: success
|
| 689 |
+
*/
|
| 690 |
+
public function test_validation_valid_date_none_arguments() {
|
| 691 |
+
$post = array(
|
| 692 |
+
'f1' => '2013/02/26',
|
| 693 |
+
'f2' => '2013-02-26',
|
| 694 |
+
'f3' => '2013/2/26 12:0:33',
|
| 695 |
+
'f4' => '19 Jan 2038 03:14:07',
|
| 696 |
+
'f5' => 'Sat Mar 10 17:16:18 MST 2001',
|
| 697 |
+
'f6' => '',
|
| 698 |
+
);
|
| 699 |
+
|
| 700 |
+
$val = Validation::forge(__FUNCTION__);
|
| 701 |
+
$val->add_field('f1', 'F1', 'valid_date');
|
| 702 |
+
$val->add_field('f2', 'F2', 'valid_date');
|
| 703 |
+
$val->add_field('f3', 'F3', 'valid_date');
|
| 704 |
+
$val->add_field('f4', 'F4', 'valid_date');
|
| 705 |
+
$val->add_field('f5', 'F5', 'valid_date');
|
| 706 |
+
$val->add_field('f6', 'F6', 'valid_date');
|
| 707 |
+
$test = $val->run($post);
|
| 708 |
+
$expected = true;
|
| 709 |
+
|
| 710 |
+
$this->assertEquals($expected, $test);
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
/**
|
| 714 |
+
* Validation: valid_date
|
| 715 |
+
* Expecting: failure
|
| 716 |
+
*/
|
| 717 |
+
public function test_validation_valid_date_none_arguments_error() {
|
| 718 |
+
$post = array(
|
| 719 |
+
'f1' => 'test',
|
| 720 |
+
);
|
| 721 |
+
|
| 722 |
+
$val = Validation::forge(__FUNCTION__);
|
| 723 |
+
$val->add_field('f1', 'F1', 'valid_date');
|
| 724 |
+
$test = $val->run($post);
|
| 725 |
+
$expected = false;
|
| 726 |
+
|
| 727 |
+
$this->assertEquals($expected, $test);
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
/**
|
| 731 |
+
* Validation: valid_date
|
| 732 |
+
* Expecting: failure
|
| 733 |
+
*/
|
| 734 |
+
public function test_validation_valid_date_none_arguments_strict_error() {
|
| 735 |
+
$post = array(
|
| 736 |
+
'f1' => '2013/02/29',
|
| 737 |
+
);
|
| 738 |
+
|
| 739 |
+
$val = Validation::forge(__FUNCTION__);
|
| 740 |
+
$val->add_field('f1', 'F1', 'valid_date');
|
| 741 |
+
$test = $val->run($post);
|
| 742 |
+
$expected = false;
|
| 743 |
+
|
| 744 |
+
$this->assertEquals($expected, $test);
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
/**
|
| 748 |
+
* Validation: valid_date
|
| 749 |
+
* Expecting: success
|
| 750 |
+
*/
|
| 751 |
+
public function test_validation_valid_date_format() {
|
| 752 |
+
$post = array(
|
| 753 |
+
'f1' => '2013/02/26',
|
| 754 |
+
'f2' => '2013-02-26',
|
| 755 |
+
'f3' => '2013/2/26 12:00:33',
|
| 756 |
+
'f4' => '19 Jan 2038 03:14:07',
|
| 757 |
+
'f5' => 'Sat Mar 10 17:16:18 MST 2001',
|
| 758 |
+
'f6' => '',
|
| 759 |
+
);
|
| 760 |
+
|
| 761 |
+
$val = Validation::forge(__FUNCTION__);
|
| 762 |
+
$val->add_field('f1', 'F1', 'valid_date[Y/m/d]');
|
| 763 |
+
$val->add_field('f2', 'F2', 'valid_date[Y-m-d]');
|
| 764 |
+
$val->add_field('f3', 'F3', 'valid_date[Y/m/d H:i:s]');
|
| 765 |
+
$val->add_field('f4', 'F4', 'valid_date[d M Y H:i:s]');
|
| 766 |
+
$val->add_field('f5', 'F5', 'valid_date[D M d H:i:s T Y]');
|
| 767 |
+
$val->add_field('f6', 'F6', 'valid_date[Y/m/d]');
|
| 768 |
+
|
| 769 |
+
$test = $val->run($post);
|
| 770 |
+
$expected = true;
|
| 771 |
+
|
| 772 |
+
$this->assertEquals($expected, $test);
|
| 773 |
+
}
|
| 774 |
+
|
| 775 |
+
/**
|
| 776 |
+
* Validation: valid_date
|
| 777 |
+
* Expecting: failure
|
| 778 |
+
*/
|
| 779 |
+
public function test_validation_valid_date_format_error() {
|
| 780 |
+
$post = array(
|
| 781 |
+
'f1' => '2013/02/26',
|
| 782 |
+
);
|
| 783 |
+
|
| 784 |
+
$val = Validation::forge(__FUNCTION__);
|
| 785 |
+
$val->add_field('f1', 'F1', 'valid_date[Y/m/d H:i:s]');
|
| 786 |
+
|
| 787 |
+
$test = $val->run($post);
|
| 788 |
+
$expected = false;
|
| 789 |
+
|
| 790 |
+
$this->assertEquals($expected, $test);
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
/**
|
| 794 |
+
* Validation: valid_date
|
| 795 |
+
* Expecting: success
|
| 796 |
+
*/
|
| 797 |
+
public function test_validation_valid_date_not_strict() {
|
| 798 |
+
$post = array(
|
| 799 |
+
'f1' => '2013/02/29',
|
| 800 |
+
);
|
| 801 |
+
|
| 802 |
+
$val = Validation::forge(__FUNCTION__);
|
| 803 |
+
$val->add_field('f1', 'F1', 'valid_date[Y/m/d,0]');
|
| 804 |
+
|
| 805 |
+
$test = $val->run($post);
|
| 806 |
+
$expected = true;
|
| 807 |
+
|
| 808 |
+
$this->assertEquals($expected, $test);
|
| 809 |
+
}
|
| 810 |
+
|
| 811 |
+
/**
|
| 812 |
+
* Test for $validation->error_message()
|
| 813 |
+
*
|
| 814 |
+
* @test
|
| 815 |
+
*/
|
| 816 |
+
public function test_error_message() {
|
| 817 |
+
$post = array(
|
| 818 |
+
'title' => '',
|
| 819 |
+
'number' => 'ABC',
|
| 820 |
+
);
|
| 821 |
+
|
| 822 |
+
$val = Validation::forge(__FUNCTION__);
|
| 823 |
+
$val->add_field('title', 'Title', 'required');
|
| 824 |
+
$val->add_field('number', 'Number', 'required|valid_string[numeric]');
|
| 825 |
+
|
| 826 |
+
$val->run($post);
|
| 827 |
+
|
| 828 |
+
$expected = 'The field Title is required and must contain a value.';
|
| 829 |
+
$this->assertEquals($expected, $val->error_message('title'));
|
| 830 |
+
|
| 831 |
+
$expected = 'The valid string rule valid_string(numeric) failed for field Number';
|
| 832 |
+
$this->assertEquals($expected, $val->error_message('number'));
|
| 833 |
+
|
| 834 |
+
$expected = 'The field Title is required and must contain a value.';
|
| 835 |
+
$this->assertEquals($expected, current($val->error_message()));
|
| 836 |
+
|
| 837 |
+
$expected = 'No error';
|
| 838 |
+
$this->assertEquals($expected, $val->error_message('content', 'No error'));
|
| 839 |
+
}
|
| 840 |
+
}
|