Skip to content

Commit 4eca424

Browse files
committed
[test] add phpunit tests
1 parent 2a68033 commit 4eca424

File tree

701 files changed

+32426
-40
lines changed

Some content is hidden

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

701 files changed

+32426
-40
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ jobs:
5858
run: php data/bin/check_configuration.php
5959

6060
- name: Run Tests
61-
run: php data/bin/symfony symfony:test --trace
61+
run: php vendor/bin/phpunit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ lib/plugins/sfDoctrinePlugin/test/functional/fixtures/log/
77
/vendor
88
/composer.lock
99
.php-cs-fixer.cache
10+
.phpunit.result.cache
11+
phpunit.xml
12+
/tests/fixtures/symfony/log

.php-cs-fixer.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
->exclude('task/generator/skeleton/')
1111
->exclude('plugins/sfDoctrinePlugin/data/generator/')
1212
// Exclude generated files (single files)
13-
->notPath('unit/config/fixtures/sfDefineEnvironmentConfigHandler/prefix_result.php')
14-
->notPath('unit/config/fixtures/sfFilterConfigHandler/result.php')
13+
->notPath('fixtures/sfDefineEnvironmentConfigHandler/prefix_result.php')
14+
->notPath('fixtures/sfFilterConfigHandler/result.php')
1515
;
1616

1717
$config = new PhpCsFixer\Config();

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"swiftmailer/swiftmailer": "~5.2 || ^6.0"
99
},
1010
"require-dev": {
11-
"psr/log": "*"
11+
"ext-zlib": "*",
12+
"ext-apcu": "*",
13+
"psr/log": "*",
14+
"phpunit/phpunit": "^9.6"
1215
},
1316
"autoload": {
1417
"files": ["autoload.php"]
@@ -26,5 +29,9 @@
2629
"replace": {
2730
"lexpress/symfony1": "^1.5"
2831
},
32+
"scripts": {
33+
"test": "phpunit",
34+
"php-cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix"
35+
},
2936
"bin": ["data/bin/symfony"]
3037
}

lib/autoload/sfCoreAutoload.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ class sfCoreAutoload
301301
'sftesterresponse' => 'test/sfTesterResponse.class.php',
302302
'sftesteruser' => 'test/sfTesterUser.class.php',
303303
'sftesterviewcache' => 'test/sfTesterViewCache.class.php',
304+
'symfony1applicationtestcase' => 'test/Symfony1ApplicationTestCase.php',
305+
'sfinternalserverbasedfixturetesttrait' => 'test/sfInternalServerBasedFixtureTestTrait.php',
306+
'symfony1projecttestcase' => 'test/Symfony1ProjectTestCase.php',
307+
'testcasedrivenapplicationconfiguration' => 'test/TestCaseDrivenApplicationConfiguration.php',
308+
'testcasedrivenconfigurationinterface' => 'test/TestCaseDrivenConfigurationInterface.php',
309+
'testcasedrivenprojectconfiguration' => 'test/TestCaseDrivenProjectConfiguration.php',
304310
'sfbasicsecurityuser' => 'user/sfBasicSecurityUser.class.php',
305311
'sfsecurityuser' => 'user/sfSecurityUser.class.php',
306312
'sfuser' => 'user/sfUser.class.php',

lib/cache/sfAPCCache.class.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function initialize($options = array())
3232
{
3333
parent::initialize($options);
3434

35-
$this->enabled = function_exists('apc_store') && ini_get('apc.enabled');
35+
$this->enabled = function_exists('apcu_store') && apcu_enabled();
3636
}
3737

3838
/**
@@ -69,14 +69,16 @@ public function has($key)
6969
* @see sfCache
7070
*
7171
* @param mixed|null $lifetime
72+
*
73+
* @return bool|array
7274
*/
7375
public function set($key, $data, $lifetime = null)
7476
{
7577
if (!$this->enabled) {
7678
return true;
7779
}
7880

79-
return apc_store($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime));
81+
return apcu_store($this->getOption('prefix').$key, $data, $this->getLifetime($lifetime));
8082
}
8183

8284
/**
@@ -88,7 +90,7 @@ public function remove($key)
8890
return true;
8991
}
9092

91-
return apc_delete($this->getOption('prefix').$key);
93+
return apcu_delete($this->getOption('prefix').$key);
9294
}
9395

9496
/**
@@ -101,7 +103,7 @@ public function clean($mode = sfCache::ALL)
101103
}
102104

103105
if (sfCache::ALL === $mode) {
104-
return apc_clear_cache('user');
106+
return apcu_clear_cache();
105107
}
106108
}
107109

@@ -138,7 +140,7 @@ public function removePattern($pattern)
138140
return true;
139141
}
140142

141-
$infos = apc_cache_info('user');
143+
$infos = apcu_cache_info();
142144
if (!is_array($infos['cache_list'])) {
143145
return;
144146
}
@@ -147,7 +149,7 @@ public function removePattern($pattern)
147149

148150
foreach ($infos['cache_list'] as $info) {
149151
if (preg_match($regexp, $info['info'])) {
150-
apc_delete($info['info']);
152+
apcu_delete($info['info']);
151153
}
152154
}
153155
}
@@ -165,7 +167,7 @@ protected function getCacheInfo($key)
165167
return false;
166168
}
167169

168-
$infos = apc_cache_info('user');
170+
$infos = apcu_cache_info();
169171

170172
if (is_array($infos['cache_list'])) {
171173
foreach ($infos['cache_list'] as $info) {
@@ -181,7 +183,7 @@ protected function getCacheInfo($key)
181183
private function fetch($key, &$success)
182184
{
183185
$has = null;
184-
$value = apc_fetch($key, $has);
186+
$value = apcu_fetch($key, $has);
185187
// the second argument was added in APC 3.0.17. If it is still null we fall back to the value returned
186188
if (null !== $has) {
187189
$success = $has;

lib/cache/sfEAcceleratorCache.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
1515
*
1616
* @version SVN: $Id$
17+
*
18+
* @deprecated
1719
*/
1820
class sfEAcceleratorCache extends sfCache
1921
{

lib/cache/sfFileCache.class.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ public function get($key, $default = null)
6363
return $default;
6464
}
6565

66-
return $data[self::READ_DATA];
66+
$rawData = $data[self::READ_DATA];
67+
68+
if ('FaLSe' === $rawData) {
69+
$rawData = false;
70+
}
71+
72+
return $rawData;
6773
}
6874

6975
/**
@@ -87,6 +93,10 @@ public function set($key, $data, $lifetime = null)
8793
$this->clean(sfCache::OLD);
8894
}
8995

96+
if (false === $data) {
97+
$data = 'FaLSe';
98+
}
99+
90100
return $this->write($this->getFilePath($key), $data, time() + $this->getLifetime($lifetime));
91101
}
92102

lib/cache/sfSQLiteCache.class.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public function get($key, $default = null)
7272
$data = $this->dbh->singleQuery(sprintf("SELECT data FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time()));
7373
}
7474

75+
if ('FaLSe' === $data) {
76+
$data = false;
77+
}
78+
7579
return null === $data ? $default : $data;
7680
}
7781

@@ -81,7 +85,7 @@ public function get($key, $default = null)
8185
public function has($key)
8286
{
8387
if ($this->isSqLite3()) {
84-
return (int) $this->dbh->querySingle(sprintf("SELECT count(*) FROM cache WHERE key = '%s' AND timeout > %d", $this->dbh->escapeString($key), time()));
88+
return $this->dbh->querySingle(sprintf("SELECT count(*) FROM cache WHERE key = '%s' AND timeout > %d", $this->dbh->escapeString($key), time())) > 0;
8589
}
8690

8791
return (bool) $this->dbh->query(sprintf("SELECT key FROM cache WHERE key = '%s' AND timeout > %d", sqlite_escape_string($key), time()))->numRows();
@@ -98,6 +102,10 @@ public function set($key, $data, $lifetime = null)
98102
$this->clean(sfCache::OLD);
99103
}
100104

105+
if (false === $data) {
106+
$data = 'FaLSe';
107+
}
108+
101109
if ($this->isSqLite3()) {
102110
return $this->dbh->exec(sprintf("INSERT OR REPLACE INTO cache (key, data, timeout, last_modified) VALUES ('%s', '%s', %d, %d)", $this->dbh->escapeString($key), $this->dbh->escapeString($data), time() + $this->getLifetime($lifetime), time()));
103111
}

lib/cache/sfXCacheCache.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
1515
*
1616
* @version SVN: $Id$
17+
*
18+
* @deprecated
1719
*/
1820
class sfXCacheCache extends sfCache
1921
{

0 commit comments

Comments
 (0)