Skip to content
This repository was archived by the owner on Nov 13, 2018. It is now read-only.

Commit 759e78a

Browse files
committed
Initial commit
0 parents  commit 759e78a

File tree

13 files changed

+403
-0
lines changed

13 files changed

+403
-0
lines changed

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_name: travis-ci
2+
coverage_clover: build/logs/clover.xml
3+
json_path: build/logs/coveralls-upload.json

.gitattributes

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://git-scm.com/book/en/Customizing-Git-Git-Attributes
2+
# https://help.github.com/articles/dealing-with-line-endings
3+
4+
5+
# Auto detect text files and perform LF normalization
6+
* text=auto
7+
8+
# Force the following filetypes to have unix eols, so Windows does not break them
9+
*.* text eol=lf
10+
11+
# Don't diff or textually merge source maps
12+
*.map binary
13+
14+
# Avoid unreadable diffs for generated text files, eg: *.min.js
15+
*.min.* binary
16+
17+
# Image files
18+
*.jpg binary
19+
*.jpeg binary
20+
*.png binary
21+
*.ico binary
22+
23+
24+
# Export ignores
25+
tests export-ignore
26+
27+
# https://github.com/github/linguist#using-gitattributes
28+
node_modules/ linguist-vendored=false

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# https://github.com/github/gitignore
2+
# https://www.gitignore.io/
3+
# http://git-scm.com/docs/gitignore
4+
5+
# phpstorm, webstorm
6+
.idea/
7+
8+
# sublime and other ide
9+
.project
10+
*.sublime-project
11+
*.sublime-workspace
12+
.brackets.json
13+
_notes/
14+
15+
# logs
16+
logs/
17+
*.log
18+
npm-debug.log*
19+
error_log
20+
21+
22+
# OS generated files
23+
[Tt]humbs.db
24+
ehthumbs.db
25+
*~
26+
.*~
27+
._*
28+
*.bak
29+
30+
# Recycle bin folder used by different os
31+
.Trash-*
32+
$RECYCLE.BIN/
33+
34+
35+
# Windows shortcuts
36+
*.lnk
37+
38+
39+
# Folder config file
40+
[Dd]esktop.ini
41+
*.DS_store
42+
.DS_store?
43+
44+
45+
# node packages
46+
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
47+
node_modules/
48+
49+
50+
# bower packages
51+
bower_components/
52+
53+
# svn folders
54+
.svn/
55+
56+
# composer
57+
vendor/
58+
composer.phar
59+
60+
# project
61+
phpunit.phar
62+
coveralls.phar
63+
build/

.travis.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Config file for https://travis-ci.org/
2+
# Validate this file here - http://lint.travis-ci.org/
3+
4+
# Tell Travis CI we are using PHP
5+
language: php
6+
7+
# The platforms you wants to test on
8+
os:
9+
- linux
10+
11+
# git configs
12+
git:
13+
depth: 1
14+
15+
# Define the php versions against we want to test our code
16+
php:
17+
- 5.6
18+
- 7.0
19+
- hhvm
20+
21+
matrix:
22+
fast_finish: true
23+
allow_failures:
24+
- php: 7.0
25+
- php: hhvm
26+
27+
# We don't want to run linux commands as super user
28+
sudo: false
29+
30+
# Note: Code coverage requires php Xdebug extension to enabled
31+
32+
# Composer package installation
33+
install:
34+
# Install composer packages, will also trigger dump-autoload
35+
- composer install --no-interaction
36+
# Install coveralls.phar
37+
- wget -c -nc --retry-connrefused --tries=0 https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
38+
- chmod +x coveralls.phar
39+
- php coveralls.phar --version
40+
41+
# Create a storage folder for Coverage report
42+
before_script:
43+
- mkdir -p build/logs
44+
- ls -al
45+
46+
# Testing the app (see phpunit.xml), generating Code Coverage report
47+
script:
48+
- phpunit --coverage-clover build/logs/clover.xml
49+
50+
51+
#after_script:
52+
53+
# Submit generated coverage report to Coveralls servers, see .coveralls.yml
54+
after_success:
55+
- travis_retry php coveralls.phar -v
56+
57+
#after_failure:
58+
59+
# Tell Travis CI to monitor only 'master' branch
60+
branches:
61+
only: master
62+
63+
# Configure email notifications
64+
notifications:
65+
email:
66+
on_success: never
67+
on_failure: always
68+
69+
# You can delete cache using travis-ci web interface
70+
cache:
71+
directories:
72+
- vendor
73+
- $HOME/.cache/composer
74+

LICENSE.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Ankur
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

app/Classes/Calculator.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Ankur;
4+
5+
class Calculator
6+
{
7+
8+
9+
/**
10+
* Add two numbers
11+
* @param $x
12+
* @param $y
13+
* @return mixed
14+
*/
15+
public function addTwo($x, $y)
16+
{
17+
return $x + $y;
18+
}
19+
20+
/**
21+
* Multiply two numbers
22+
* @param $x
23+
* @param $y
24+
* @return mixed
25+
*
26+
*/
27+
public function multiplyTwo($x, $y)
28+
{
29+
return $x * $y;
30+
}
31+
32+
/**
33+
* Subtract two numbers
34+
* @param $x
35+
* @param $y
36+
* @return mixed
37+
*
38+
*/
39+
public function subtractTwo($x, $y)
40+
{
41+
return $x - $y;
42+
}
43+
44+
/**
45+
* Divide two numbers
46+
* @param $x
47+
* @param $y
48+
* @return float
49+
*/
50+
public function divideTwo($x, $y)
51+
{
52+
//TODO Handle divide by zero
53+
return $x / $y;
54+
}
55+
56+
}

composer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "phpUnit-Testing-Travis-CI-and-Coveralls",
3+
"license": "MIT",
4+
"authors": [
5+
{
6+
"name": "ankurk91",
7+
"homepage": "https://ankurk91.github.io/"
8+
}
9+
],
10+
"require": {
11+
"php": ">=5.3.2"
12+
},
13+
"require-dev": {
14+
},
15+
"autoload": {
16+
"classmap": [
17+
"app/Classes"
18+
]
19+
},
20+
"config": {
21+
"preferred-install": "dist",
22+
"optimize-autoloader": true
23+
},
24+
"minimum-stability": "stable",
25+
"prefer-stable": true
26+
}

composer.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="true"
4+
colors="true"
5+
stopOnFailure="false"
6+
bootstrap="tests/bootstrap.php">
7+
8+
<filter>
9+
<whitelist>
10+
<directory>./app</directory>
11+
<exclude>
12+
<directory>./public</directory>
13+
<directory>./vendor</directory>
14+
<directory>./tests</directory>
15+
</exclude>
16+
</whitelist>
17+
</filter>
18+
19+
<testsuite name="CalculatorApp Test Suite">
20+
<directory suffix=".php">./tests</directory>
21+
</testsuite>
22+
23+
</phpunit>

public/index.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
require('../vendor/autoload.php');
4+
5+
use Ankur\Calculator;
6+
7+
$obj = new Calculator();
8+
9+
echo $obj->addTwo(2,3);
10+
echo "<br>";
11+
echo $obj->multiplyTwo(2,3);
12+
13+
?>
14+
This is just a sample page.
15+

0 commit comments

Comments
 (0)