Skip to content

Commit c01615d

Browse files
author
Mark Railton
committed
Merge branch 'exussum12-addTravisChecks'
2 parents 713523c + 9441391 commit c01615d

File tree

11 files changed

+276
-141
lines changed

11 files changed

+276
-141
lines changed

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
dist: trusty
3+
cache:
4+
directories:
5+
- $HOME/.composer/cache/files
6+
- $HOME/.cache/composer/files
7+
matrix:
8+
include:
9+
- php: 5.6
10+
fast_finish: true
11+
before_script:
12+
- composer global require squizlabs/php_codesniffer
13+
- composer global require phpunit/phpunit
14+
- composer global require jakub-onderka/php-parallel-lint
15+
- composer install
16+
- cp src/config.php.dist src/config.php
17+
script:
18+
- PATH=$HOME/.composer/vendor/bin:$PATH ./build.sh

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
parallel-lint --exclude vendor .
5+
6+
phpcs \
7+
--standard=tools/codesniffer/JoindInPSR2/ruleset.xml \
8+
--ignore=**/config.php,**/database.php,vendor,tools,tests/bootstrap.php \
9+
--extensions=php \
10+
--runtime-set ignore_warnings_on_exit true \
11+
-p \
12+
.
13+
14+
cd tests
15+
phpunit

scripts/password-migration.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$db = new PDO("mysql:host=localhost;dbname=joindin", "root", NULL);
3+
$db = new PDO("mysql:host=localhost;dbname=joindin", "root", null);
44

55
$update_sql = "update user set password = :password where ID = :id";
66
$update_stmt = $db->prepare($update_sql);
@@ -10,11 +10,10 @@
1010
$select_stmt->execute();
1111

1212
$count = 0;
13-
while($row = $select_stmt->fetch(PDO::FETCH_ASSOC)) {
13+
while ($row = $select_stmt->fetch(PDO::FETCH_ASSOC)) {
1414
$update_stmt->execute(array("password" => password_hash($row['password'], PASSWORD_DEFAULT),
1515
"id" => $row['ID']));
1616
$count++;
1717
}
1818

1919
echo $count . " rows processed\n";
20-

scripts/patchdb.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
// No options? Let's help out...
2020
if (!$options || count($options) == 0) {
21-
2221
echo <<<HELPTEXT
2322
2423
@@ -85,23 +84,24 @@
8584
}
8685

8786

88-
$baseMysqlCmd = "mysql -u{$options['u']} "
87+
$baseMysqlCmd = "mysql -u{$options['u']} "
8988
. ($options['p'] ? "-p{$options['p']} " : "")
9089
. "{$options['d']}";
9190

9291

9392
///////////////////////////////////////////////
9493
// Try getting the max patch_level so far
9594

96-
exec($baseMysqlCmd . ' -r '
95+
exec(
96+
$baseMysqlCmd . ' -r '
9797
. '-e "select max(patch_number) as num from `' . $options['d'] . '`.patch_history',
9898
$res
9999
);
100100

101101
$maxPatchNum = 0;
102102
if ($res && array_key_exists(1, $res) && $res[1] > 0) {
103103
$maxPatchNum = $res[1];
104-
} else if (is_array($res) && count($res) === 0) {
104+
} elseif (is_array($res) && count($res) === 0) {
105105
$maxPatchNum = false;
106106
}
107107

@@ -115,7 +115,6 @@
115115
// Initialise db
116116
//////////////////////////////////////////////
117117
if (array_key_exists('i', $options)) {
118-
119118
if (!file_exists($options['t'] . DIRECTORY_SEPARATOR . 'init_db.sql')) {
120119
echo "Couldn't find the init_db.sql file to initialise db";
121120
exit;
@@ -133,17 +132,15 @@
133132
/////////////////////////////////////////////
134133

135134
// First, look through the directory for patch123.sql files
136-
// and get all the {123} numbers, so we can run them all
135+
// and get all the {123} numbers, so we can run them all
137136
// in order.
138137
$matchedNums = array();
139138
if ($dh = opendir($options['t'])) {
140139
while (($file = readdir($dh)) !== false) {
141-
142140
preg_match("/patch([\d]+)\.sql/", $file, $matches);
143141
if ($matches && array_key_exists(1, $matches) && $matches[1] > $maxPatchNum) {
144142
$matchedNums[] = (int)$matches[1];
145143
}
146-
147144
}
148145
closedir($dh);
149146
}
@@ -160,10 +157,3 @@
160157
}
161158

162159
echo "\nAll done\n";
163-
164-
165-
166-
167-
168-
169-

tests/bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ public function __construct()
2525
// the constructor in mockPDO.
2626
}
2727
}
28+
29+
class_alias(mockPDO::class, 'JoindinTest\Inc\mockPDO');

tests/controllers/Event_hostsControllerTest.php renamed to tests/controllers/EventHostsControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Mockery as M;
66

7-
class Event_hostsControllerTest extends \PHPUnit_Framework_TestCase
7+
class EventHostsControllerTest extends \PHPUnit_Framework_TestCase
88
{
99
/**
1010
* @expectedException \Exception

tests/inc/RequestTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -940,24 +940,3 @@ public function testGettingConfigValues()
940940
$this->assertEquals('Foo', $request->getConfigValue('Bar', 'Foo'));
941941
}
942942
}
943-
944-
/**
945-
* Class to allow for mocking PDO to send to the OAuthModel
946-
*/
947-
class mockPDO extends \PDO
948-
{
949-
/**
950-
* Constructor that does nothing but helps us test with fake database
951-
* adapters
952-
*/
953-
public function __construct()
954-
{
955-
// We need to do this crap because PDO has final on the __sleep and
956-
// __wakeup methods. PDO requires a parameter in the constructor but we don't
957-
// want to create a real DB adapter. If you tell getMock to not call the
958-
// original constructor, it fakes stuff out by unserializing a fake
959-
// serialized string. This way, we've got a "PDO" object but we don't need
960-
// PHPUnit to fake it by unserializing a made-up string. We've neutered
961-
// the constructor in mockPDO.
962-
}
963-
}

tools/dbgen/generate.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
// define("COUNT_TALK_COMMENTS", 50);
1616

1717
// // Medium: enough for development purposes without stressing out your DB
18-
define("COUNT_USERS", 50);
19-
define("COUNT_EVENTS", 100);
20-
define("COUNT_EVENT_COMMENTS", 200);
21-
define("COUNT_TRACKS", 150);
22-
define("COUNT_TALKS", 500);
23-
define("COUNT_TALK_COMMENTS", 1000);
18+
define("COUNT_USERS", 50);
19+
define("COUNT_EVENTS", 100);
20+
define("COUNT_EVENT_COMMENTS", 200);
21+
define("COUNT_TRACKS", 150);
22+
define("COUNT_TALKS", 500);
23+
define("COUNT_TALK_COMMENTS", 1000);
2424

2525
// // Heavy: simulates current production values I think
2626
// define("COUNT_USERS", 200);
@@ -72,7 +72,7 @@
7272
define("COMMENT_IS_PRIVATE", 5);
7373

7474
// Percentage of talks that is claimed
75-
define("TALK_IS_CLAIMED",75);
75+
define("TALK_IS_CLAIMED", 75);
7676

7777
// Does the talk have multiple speakers
7878
define("TALK_HAS_MULTIPLE_SPEAKERS", 20);
@@ -102,5 +102,3 @@
102102
$gen = new DataGenerator(new Generator_Data());
103103
echo $gen->generate();
104104
exit;
105-
106-
?>

0 commit comments

Comments
 (0)