Skip to content

Commit df60793

Browse files
committed
Adding composer.json, phpunit, and test cases
1 parent fb2aabb commit df60793

12 files changed

+682
-51
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
Icon?
2929
ehthumbs.db
3030
Thumbs.db
31+
app/Vendor/*

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,15 @@ To change your source code in the running container you need to [oc rsh](https:/
101101

102102
After you [oc rsh](https://docs.openshift.org/latest/cli_reference/basic_cli_operations.html#troubleshooting-and-debugging-cli-operations) into the running container, your current directory is set to `/opt/app-root/src`, where the source code is located.
103103

104+
###Source repository layout
105+
106+
You do not need to change anything in your existing PHP project's repository.
107+
However, if these files exist they will affect the behavior of the build process:
108+
109+
* **composer.json**
110+
111+
List of dependencies to be installed with `composer`. The format is documented
112+
[here](https://getcomposer.org/doc/04-schema.md).
113+
104114
###License
105115
This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to [CC0](http://creativecommons.org/publicdomain/zero/1.0/).

app/Config/core.php

+24-22
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,31 @@
3131
);
3232

3333
// This function gets called by openshift_secure and passes an array
34-
function make_secure_key($args) {
35-
$hash = $args['hash'];
36-
$key = $args['variable'];
37-
$original = $args['original'];
38-
39-
$chars = '0123456789';
40-
if ($key != 'Security.cipherSeed') {
41-
$chars .= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
42-
$chars .= '!@#$%^&*()';
43-
$chars .= '-_ []{}<>~`+=,.;:/?|';
34+
if (!function_exists('make_secure_key')) {
35+
function make_secure_key($args) {
36+
$hash = $args['hash'];
37+
$key = $args['variable'];
38+
$original = $args['original'];
39+
40+
$chars = '0123456789';
41+
if ($key != 'Security.cipherSeed') {
42+
$chars .= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
43+
$chars .= '!@#$%^&*()';
44+
$chars .= '-_ []{}<>~`+=,.;:/?|';
45+
}
46+
47+
// Convert the hash to an int to seed the RNG
48+
srand(hexdec(substr($hash,0,8)));
49+
// Create a random string the same length as the default
50+
$val = '';
51+
for($i = 1; $i <= strlen($original); $i++){
52+
$val .= substr( $chars, rand(0,strlen($chars))-1, 1);
53+
}
54+
// Reset the RNG
55+
srand();
56+
// Set the value
57+
return $val;
4458
}
45-
46-
// Convert the hash to an int to seed the RNG
47-
srand(hexdec(substr($hash,0,8)));
48-
// Create a random string the same length as the default
49-
$val = '';
50-
for($i = 1; $i <= strlen($original); $i++){
51-
$val .= substr( $chars, rand(0,strlen($chars))-1, 1);
52-
}
53-
// Reset the RNG
54-
srand();
55-
// Set the value
56-
return $val;
5759
}
5860

5961
// Generate OpenShift secure keys (or return defaults if not on OpenShift)

app/Test/Case/AllTestsTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
class AllTestsTest extends CakeTestSuite {
4+
public static function suite() {
5+
$suite = new CakeTestSuite('All tests');
6+
$suite->addTestDirectoryRecursive(TESTS . 'Case');
7+
return $suite;
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
App::uses('PagesController', 'Controller');
3+
App::uses('Home', 'View');
4+
5+
class PagesControllerTest extends ControllerTestCase {
6+
public function setUp() {
7+
parent::setUp();
8+
$PagesController = new PagesController();
9+
$HomeView = new View($PagesController);
10+
}
11+
12+
public function testHomePageContents() {
13+
$result = $this->testAction('/',
14+
array('method' => 'get', 'return' => 'contents')
15+
);
16+
17+
$this->assertContains('Welcome to your CakePHP application on OpenShift',$result);
18+
}
19+
}

composer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "cakephp/cakephp",
3+
"description": "The CakePHP framework",
4+
"type": "library",
5+
"keywords": ["framework"],
6+
"homepage": "http://cakephp.org",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "CakePHP Community",
11+
"homepage": "https://github.com/cakephp/cakephp/graphs/contributors"
12+
}
13+
],
14+
"support": {
15+
"issues": "https://github.com/cakephp/cakephp/issues",
16+
"forum": "http://stackoverflow.com/tags/cakephp",
17+
"irc": "irc://irc.freenode.org/cakephp",
18+
"source": "https://github.com/cakephp/cakephp"
19+
},
20+
"require": {
21+
"php": ">=5.3.0"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "3.7.38",
25+
"cakephp/cakephp-codesniffer": "^1.0.0"
26+
},
27+
"config": {
28+
"vendor-dir": "app/Vendor"
29+
},
30+
"bin": [
31+
"lib/Cake/Console/cake"
32+
]
33+
}

0 commit comments

Comments
 (0)