Permalink
Browse files

[+]: namespaces / tests / composer ...

  • Loading branch information...
voku committed Nov 4, 2014
1 parent f1f6b63 commit 1c41ff6444eea8bca10ab7a888ebceb2f62c5a2c
Showing with 104 additions and 5 deletions.
  1. +65 −0 app/classes/Helper/CalculateTicketPrice.php
  2. +6 −0 composer.json
  3. +31 −0 test/classes/CalculateTicketPriceTest.php
  4. +2 −5 test/configuration.xml
@@ -0,0 +1,65 @@
<?php namespace MyApp\Helper;
/**
* Created by PhpStorm.
* User: menadwork-user
* Date: 04.11.2014
* Time: 01:32
*/
class CalculateTicketPrice {
protected $plan = array();
protected $price = 0;
public function __construct()
{
$this->plan[1] = 5;
$this->plan[2] = 10;
$this->plan[3] = 12.5;
$this->plan[4] = 17.5;
}
/**
* add ticket(s)
*
* @param int $planKey
* @param int $number
*/
public function add($planKey = 0, $number = 1) {
$this->price += ($this->plan[$planKey] * $number);
}
/**
* @return array
*/
public function getPlan()
{
return $this->plan;
}
/**
* @param array $plan
*/
public function setPlan($plan)
{
$this->plan = $plan;
}
/**
* @return int
*/
public function getPrice()
{
return $this->price;
}
/**
* @param int $price
*/
public function setPrice($price)
{
$this->price = $price;
}
}
View
@@ -20,5 +20,11 @@
},
"config": {
"preferred-install": "dist"
},
"autoload": {
"psr-4": {
"MyApp\\": ["app/classes/"]
}
}
}
@@ -0,0 +1,31 @@
<?php
use MyApp\Helper\CalculateTicketPrice;
/**
* Created by PhpStorm.
* User: menadwork-user
* Date: 04.11.2014
* Time: 01:40
*/
class CalculateTicketPriceTest extends PHPUnit_Framework_TestCase {
/**
* @var CalculateTicketPrice
*/
protected $calc;
public function __construct()
{
$this->calc = new CalculateTicketPrice();
}
public function testAdd()
{
$this->calc->add(1);
$this->calc->add(2);
$this->assertEquals(15, $this->calc->getPrice());
}
}
View
@@ -5,13 +5,10 @@ To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!-- see http://www.phpunit.de/wiki/Documentation -->
<!--phpunit bootstrap="/path/to/bootstrap.php"
<phpunit bootstrap="bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="true">
</phpunit-->
<phpunit colors="false"/>
</phpunit>

0 comments on commit 1c41ff6

Please sign in to comment.