Skip to content

Commit 50518a3

Browse files
committed
Merge pull request bcit-ci#3468 from dbernar1/test-5.2
Added support for running unit tests on PHP 5.2
2 parents 942a1d8 + d24652d commit 50518a3

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: php
22

33
php:
4+
- 5.2
45
- 5.3.3
56
- 5.4
67
- 5.5
@@ -19,7 +20,7 @@ env:
1920
sudo: false
2021

2122
before_script:
22-
- composer install --dev --no-progress
23+
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear channel-discover pear.bovigo.org && pear install bovigo/vfsStream-beta; else composer install --dev --no-progress; fi"
2324
- sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi"
2425
- sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi"
2526
- sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi"
@@ -34,6 +35,10 @@ matrix:
3435
env: DB=pgsql
3536
- php: hhvm
3637
env: DB=pdo/pgsql
38+
- php: 5.2
39+
env: DB=sqlite
40+
- php: 5.2
41+
env: DB=pdo/sqlite
3742

3843
branches:
3944
only:

tests/codeigniter/core/Output_test.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
class Output_test extends CI_TestCase {
44

55
public $output;
6-
protected $_output_data = <<<HTML
7-
<html>
8-
<head>
9-
<title>Basic HTML</title>
10-
</head>
11-
<body>
12-
Test
13-
</body>
14-
</html>
15-
HTML;
6+
protected $_output_data = '';
167

178
public function set_up()
189
{
10+
$this->_output_data =<<<HTML
11+
<html>
12+
<head>
13+
<title>Basic HTML</title>
14+
</head>
15+
<body>
16+
Test
17+
</body>
18+
</html>
19+
HTML;
1920
$this->ci_set_config('charset', 'UTF-8');
2021
$output = $this->ci_core_class('output');
2122
$this->output = new $output();
@@ -59,4 +60,4 @@ public function test_get_header()
5960
);
6061
}
6162

62-
}
63+
}

tests/mocks/database/schema/skeleton.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Mock_Database_Schema_Skeleton {
2222
*/
2323
public static function init($driver)
2424
{
25-
if (empty(static::$db) && empty(static::$forge))
25+
if (empty(self::$db) && empty(self::$forge))
2626
{
2727
$config = Mock_Database_DB::config($driver);
2828
$connection = new Mock_Database_DB($config);
@@ -34,12 +34,12 @@ public static function init($driver)
3434
$loader->dbforge();
3535
$forge = CI_TestCase::instance()->ci_instance_var('dbforge');
3636

37-
static::$db = $db;
38-
static::$forge = $forge;
39-
static::$driver = $driver;
37+
self::$db = $db;
38+
self::$forge = $forge;
39+
self::$driver = $driver;
4040
}
4141

42-
return static::$db;
42+
return self::$db;
4343
}
4444

4545
/**
@@ -50,7 +50,7 @@ public static function init($driver)
5050
public static function create_tables()
5151
{
5252
// User Table
53-
static::$forge->add_field(array(
53+
self::$forge->add_field(array(
5454
'id' => array(
5555
'type' => 'INTEGER',
5656
'constraint' => 3
@@ -68,11 +68,11 @@ public static function create_tables()
6868
'constraint' => 40
6969
)
7070
));
71-
static::$forge->add_key('id', TRUE);
72-
static::$forge->create_table('user', TRUE);
71+
self::$forge->add_key('id', TRUE);
72+
self::$forge->create_table('user', TRUE);
7373

7474
// Job Table
75-
static::$forge->add_field(array(
75+
self::$forge->add_field(array(
7676
'id' => array(
7777
'type' => 'INTEGER',
7878
'constraint' => 3
@@ -85,11 +85,11 @@ public static function create_tables()
8585
'type' => 'TEXT'
8686
)
8787
));
88-
static::$forge->add_key('id', TRUE);
89-
static::$forge->create_table('job', TRUE);
88+
self::$forge->add_key('id', TRUE);
89+
self::$forge->create_table('job', TRUE);
9090

9191
// Misc Table
92-
static::$forge->add_field(array(
92+
self::$forge->add_field(array(
9393
'id' => array(
9494
'type' => 'INTEGER',
9595
'constraint' => 3
@@ -102,8 +102,8 @@ public static function create_tables()
102102
'type' => 'TEXT'
103103
)
104104
));
105-
static::$forge->add_key('id', TRUE);
106-
static::$forge->create_table('misc', TRUE);
105+
self::$forge->add_key('id', TRUE);
106+
self::$forge->create_table('misc', TRUE);
107107
}
108108

109109
/**
@@ -136,13 +136,13 @@ public static function create_data()
136136

137137
foreach ($data as $table => $dummy_data)
138138
{
139-
static::$db->truncate($table);
139+
self::$db->truncate($table);
140140

141141
foreach ($dummy_data as $single_dummy_data)
142142
{
143-
static::$db->insert($table, $single_dummy_data);
143+
self::$db->insert($table, $single_dummy_data);
144144
}
145145
}
146146
}
147147

148-
}
148+
}

0 commit comments

Comments
 (0)