Skip to content

Commit 821f9c9

Browse files
committed
Release 4.0.0-beta.4
1 parent 2d5ee91 commit 821f9c9

File tree

91 files changed

+2540
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2540
-54
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
class UnnamespacedClass
4+
{
5+
}

_support/CIDatabaseTestCase.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
use CodeIgniter\Test;
4+
5+
class CIDatabaseTestCase extends Test\CIDatabaseTestCase
6+
{
7+
8+
}

_support/CIUnitTestCase.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
use CodeIgniter\Test;
4+
5+
class CIUnitTestCase extends Test\CIUnitTestCase
6+
{
7+
8+
}
+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<?php namespace Tests\Support\Cache\Handlers;
2+
3+
use CodeIgniter\Cache\CacheInterface;
4+
5+
class MockHandler implements CacheInterface
6+
{
7+
/**
8+
* Prefixed to all cache names.
9+
*
10+
* @var string
11+
*/
12+
protected $prefix;
13+
14+
/**
15+
* Mock cache storage.
16+
*
17+
* @var array
18+
*/
19+
protected $cache = [];
20+
21+
//--------------------------------------------------------------------
22+
23+
/**
24+
* Takes care of any handler-specific setup that must be done.
25+
*/
26+
public function initialize()
27+
{
28+
// Not to see here...
29+
}
30+
31+
//--------------------------------------------------------------------
32+
33+
/**
34+
* Attempts to fetch an item from the cache store.
35+
*
36+
* @param string $key Cache item name
37+
*
38+
* @return mixed
39+
*/
40+
public function get(string $key)
41+
{
42+
$key = $this->prefix . $key;
43+
44+
return array_key_exists($key, $this->cache)
45+
? $this->cache[$key]
46+
: null;
47+
}
48+
49+
//--------------------------------------------------------------------
50+
51+
/**
52+
* Saves an item to the cache store.
53+
*
54+
* The $raw parameter is only utilized by Mamcache in order to
55+
* allow usage of increment() and decrement().
56+
*
57+
* @param string $key Cache item name
58+
* @param $value the data to save
59+
* @param null $ttl Time To Live, in seconds (default 60)
60+
* @param boolean $raw Whether to store the raw value.
61+
*
62+
* @return mixed
63+
*/
64+
public function save(string $key, $value, int $ttl = 60, bool $raw = false)
65+
{
66+
$key = $this->prefix . $key;
67+
68+
$this->cache[$key] = $value;
69+
70+
return true;
71+
}
72+
73+
//--------------------------------------------------------------------
74+
75+
/**
76+
* Deletes a specific item from the cache store.
77+
*
78+
* @param string $key Cache item name
79+
*
80+
* @return mixed
81+
*/
82+
public function delete(string $key)
83+
{
84+
unset($this->cache[$key]);
85+
}
86+
87+
//--------------------------------------------------------------------
88+
89+
/**
90+
* Performs atomic incrementation of a raw stored value.
91+
*
92+
* @param string $key Cache ID
93+
* @param integer $offset Step/value to increase by
94+
*
95+
* @return mixed
96+
*/
97+
public function increment(string $key, int $offset = 1)
98+
{
99+
$key = $this->prefix . $key;
100+
101+
$data = $this->cache[$key] ?: null;
102+
103+
if (empty($data))
104+
{
105+
$data = 0;
106+
}
107+
elseif (! is_int($data))
108+
{
109+
return false;
110+
}
111+
112+
return $this->save($key, $data + $offset);
113+
}
114+
115+
//--------------------------------------------------------------------
116+
117+
/**
118+
* Performs atomic decrementation of a raw stored value.
119+
*
120+
* @param string $key Cache ID
121+
* @param integer $offset Step/value to increase by
122+
*
123+
* @return mixed
124+
*/
125+
public function decrement(string $key, int $offset = 1)
126+
{
127+
$key = $this->prefix . $key;
128+
129+
$data = $this->cache[$key] ?: null;
130+
131+
if (empty($data))
132+
{
133+
$data = 0;
134+
}
135+
elseif (! is_int($data))
136+
{
137+
return false;
138+
}
139+
140+
return $this->save($key, $data - $offset);
141+
}
142+
143+
//--------------------------------------------------------------------
144+
145+
/**
146+
* Will delete all items in the entire cache.
147+
*
148+
* @return mixed
149+
*/
150+
public function clean()
151+
{
152+
$this->cache = [];
153+
}
154+
155+
//--------------------------------------------------------------------
156+
157+
/**
158+
* Returns information on the entire cache.
159+
*
160+
* The information returned and the structure of the data
161+
* varies depending on the handler.
162+
*
163+
* @return mixed
164+
*/
165+
public function getCacheInfo()
166+
{
167+
return [];
168+
}
169+
170+
//--------------------------------------------------------------------
171+
172+
/**
173+
* Returns detailed information about the specific item in the cache.
174+
*
175+
* @param string $key Cache item name.
176+
*
177+
* @return mixed
178+
*/
179+
public function getMetaData(string $key)
180+
{
181+
return false;
182+
}
183+
184+
//--------------------------------------------------------------------
185+
186+
/**
187+
* Determines if the driver is supported on this system.
188+
*
189+
* @return boolean
190+
*/
191+
public function isSupported(): bool
192+
{
193+
return true;
194+
}
195+
196+
//--------------------------------------------------------------------
197+
198+
}

_support/Commands/AbstractInfo.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace Tests\Support\Commands;
3+
4+
use CodeIgniter\CLI\BaseCommand;
5+
6+
abstract class AbstractInfo extends BaseCommand
7+
{
8+
9+
protected $group = 'demo';
10+
protected $name = 'app:pablo';
11+
protected $description = 'Displays basic application information.';
12+
13+
}

_support/Commands/AppInfo.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace Tests\Support\Commands;
3+
4+
use CodeIgniter\CLI\BaseCommand;
5+
use CodeIgniter\CLI\CLI;
6+
use CodeIgniter\CodeIgniter;
7+
8+
class AppInfo extends BaseCommand
9+
{
10+
11+
protected $group = 'demo';
12+
protected $name = 'app:info';
13+
protected $description = 'Displays basic application information.';
14+
15+
public function run(array $params)
16+
{
17+
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
18+
}
19+
20+
public function bomb()
21+
{
22+
try
23+
{
24+
CLI::color('test', 'white', 'Background');
25+
}
26+
catch (\RuntimeException $oops)
27+
{
28+
$this->showError($oops);
29+
}
30+
}
31+
32+
public function helpme()
33+
{
34+
$this->call('help');
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace CodeIgniter\Commands;
2+
3+
class CommandsTestStreamFilter extends \php_user_filter
4+
{
5+
public static $buffer = '';
6+
7+
public function filter($in, $out, &$consumed, $closing)
8+
{
9+
while ($bucket = stream_bucket_make_writeable($in))
10+
{
11+
self::$buffer .= $bucket->data;
12+
$consumed += $bucket->datalen;
13+
}
14+
return PSFS_PASS_ON;
15+
}
16+
}
17+
18+
stream_filter_register('CommandsTestStreamFilter', 'CodeIgniter\Commands\CommandsTestStreamFilter');

_support/Config/BadRegistrar.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace Tests\Support\Config;
2+
3+
/**
4+
* Class BadRegistrar
5+
*
6+
* Doesn't provides a basic registrar class for testing BaseConfig registration functions,
7+
* because it doesn't return an associative array
8+
*/
9+
10+
class BadRegistrar
11+
{
12+
13+
public static function RegistrarConfig()
14+
{
15+
return 'I am not worthy';
16+
}
17+
18+
}

_support/Config/MockAppConfig.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php namespace Tests\Support\Config;
2+
3+
class MockAppConfig
4+
{
5+
public $baseURL = 'http://example.com';
6+
7+
public $uriProtocol = 'REQUEST_URI';
8+
9+
public $cookiePrefix = '';
10+
public $cookieDomain = '';
11+
public $cookiePath = '/';
12+
public $cookieSecure = false;
13+
public $cookieHTTPOnly = false;
14+
15+
public $proxyIPs = '';
16+
17+
public $CSRFProtection = false;
18+
public $CSRFTokenName = 'csrf_test_name';
19+
public $CSRFCookieName = 'csrf_cookie_name';
20+
public $CSRFExpire = 7200;
21+
public $CSRFRegenerate = true;
22+
public $CSRFExcludeURIs = ['http://example.com'];
23+
public $CSRFRedirect = false;
24+
25+
public $CSPEnabled = false;
26+
27+
public $defaultLocale = 'en';
28+
public $negotiateLocale = false;
29+
public $supportedLocales = [
30+
'en',
31+
'es',
32+
];
33+
}

_support/Config/MockAutoload.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php namespace Tests\Support\Config;
2+
3+
use Config\Autoload;
4+
5+
class MockAutoload extends Autoload
6+
{
7+
public $psr4 = [];
8+
9+
public $classmap = [];
10+
11+
//--------------------------------------------------------------------
12+
13+
public function __construct()
14+
{
15+
// Don't call the parent since we don't want the default mappings.
16+
// parent::__construct();
17+
}
18+
19+
//--------------------------------------------------------------------
20+
21+
}

0 commit comments

Comments
 (0)