Skip to content

Commit aa3e118

Browse files
committed
Fix running on PHP 8 with SQLite
1 parent 4bed527 commit aa3e118

165 files changed

Lines changed: 5733 additions & 4974 deletions

File tree

Some content is hidden

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

.github/workflows/main.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Run all tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test_mysql:
7+
runs-on: ubuntu-24.04
8+
services:
9+
mysql:
10+
image: mysql:8.0
11+
env:
12+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
13+
MYSQL_DATABASE: madmodel_test
14+
ports:
15+
- 3306:3306
16+
options: >-
17+
--health-cmd="mysqladmin ping"
18+
--health-interval=10s
19+
--health-timeout=5s
20+
--health-retries=3
21+
steps:
22+
- uses: actions/checkout@v6
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y php-mysql
27+
wget -q https://phar.phpunit.de/phpunit-11.phar -O phpunit
28+
chmod +x phpunit
29+
sudo mv phpunit /usr/local/bin/phpunit
30+
- name: Configure database
31+
run: |
32+
sed -i "s/host:.*/host: 127.0.0.1/" config/database.yml
33+
sed -i "s/username:.*/username: root/" config/database.yml
34+
- name: Load test schema
35+
run: |
36+
mysql -h 127.0.0.1 -u root madmodel_test < db/tests/madmodel_test_mysql.sql
37+
- name: Run tests
38+
run: php ./script/task test
39+
40+
test_sqlite:
41+
runs-on: ubuntu-24.04
42+
steps:
43+
- uses: actions/checkout@v6
44+
- name: Install dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y php-sqlite3
48+
wget -q https://phar.phpunit.de/phpunit-11.phar -O phpunit
49+
chmod +x phpunit
50+
sudo mv phpunit /usr/local/bin/phpunit
51+
- name: Run tests
52+
run: php ./script/task test MAD_ENV=test_sqlite

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ test/tmp/**/*
44
.DS_Store
55
nbproject/
66
doc/build/*
7+
db/tests/madmodel_test.sqlite3

CHANGES.txt

Lines changed: 0 additions & 39 deletions
This file was deleted.

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The purpose of this fork is only to update the framework as needed by 6502.org.
88

99
The framework based around the Model-View-Controller pattern
1010
and modeled after Ruby on Rails 1.2. It is compatible with PHP
11-
version 5.1.4 and later.
11+
version 5.4 and later.
1212

1313
Repository Layout
1414
-----------------
@@ -72,10 +72,19 @@ to shrink in this way.
7272
Running Tests
7373
-------------
7474

75-
The repository has the same layout as an application. The framework tests
76-
are run the same way as an application's tests would be. Change to the
77-
`test/` directory and run `phpunit AllTests`.
75+
The tests require MySQL and PHPUnit. On Ubuntu:
7876

79-
Before you can run the tests, you need to create a database and configure
80-
the connection in `database.yml`. You also need to build the tests database
81-
using the file `db/tests/madmodel_test.sql`.
77+
sudo apt install mysql-server phpunit
78+
79+
Create the test database and grant access:
80+
81+
sudo mysql -e "CREATE DATABASE madmodel_test"
82+
sudo mysql -e "GRANT ALL ON madmodel_test.* TO ''@'localhost'"
83+
84+
Load the test schema:
85+
86+
mysql madmodel_test < db/tests/madmodel_test.sql
87+
88+
Run the tests:
89+
90+
./script/task test

Rakefile

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
class Admin_UsersController extends ApplicationController
4+
{
5+
// filters and common variables
6+
protected function _initialize()
7+
{
8+
}
9+
10+
public function index()
11+
{
12+
$this->head('ok');
13+
}
14+
}

app/helpers/Admin/UsersHelper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
class Admin_UsersHelper extends ApplicationHelper
4+
{
5+
}

app/views/UnitTest/testAssertTag.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<title>Maintainable - Login</title>
66
<link type="text/css" rel="Stylesheet" href="/~ddevries2/bsf19/web/css/screen.css">
7-
<script type="text/javaScript" src="/~ddevries2/bsf19/web/javascript/login.js">
7+
<script type="text/javaScript" src="/~ddevries2/bsf19/web/javascript/login.js"></script>
88
</head>
99
<body id="login">
1010

config/boot.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if (! defined('MAD_ENV')) {
66
define('MAD_ENV', isset($_SERVER['MAD_ENV']) ? $_SERVER['MAD_ENV'] : 'development');
77
}
8-
ini_set('date.timezone', 'US/Pacific');
8+
ini_set('date.timezone', 'America/Los_Angeles');
99

1010
// include paths
1111
set_include_path(implode(PATH_SEPARATOR, array(
@@ -29,13 +29,12 @@
2929
error_reporting(0);
3030
} else {
3131
ini_set('display_errors', 1);
32-
error_reporting(E_ALL | E_STRICT);
32+
error_reporting(E_ALL);
3333
}
3434

3535
// initialize the default loger. writers and filters are specified in the environment files.
3636
$GLOBALS['MAD_DEFAULT_LOGGER'] = new Horde_Log_Logger();
37-
$writer = new Horde_Log_Handler_Stream(MAD_ROOT.DIRECTORY_SEPARATOR.'log'.
38-
DIRECTORY_SEPARATOR.MAD_ENV.'.log');
37+
$writer = new Horde_Log_Handler_Stream(MAD_ROOT.'/log/'.MAD_ENV.'.log', 'a+');
3938
$GLOBALS['MAD_DEFAULT_LOGGER']->addHandler($writer);
4039

4140
// priority filters

config/database.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@ development:
22
database: madmodel
33
adapter: pdo_mysql
44
host: localhost
5-
username: root
5+
username:
66
password:
77

88
test:
99
database: madmodel_test
1010
adapter: pdo_mysql
1111
host: localhost
12-
username: root
12+
username:
1313
password:
1414

15+
test_sqlite:
16+
adapter: pdo_sqlite
17+
database: db/tests/madmodel_test.sqlite3
18+
1519
production:
1620
database: madmodel
1721
adapter: pdo_mysql
1822
host: localhost
19-
username: root
23+
username:
2024
password:

0 commit comments

Comments
 (0)