Created
August 1, 2013 09:28
-
-
Save adililhan/6129870 to your computer and use it in GitHub Desktop.
Symfony'nin dependency injection componentinin kullanımını göstermek amacıyla hazırlanmış örnek sınıfın, test sınıfı.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Tests of DependencyInjection.php | |
*/ | |
class ControllerTest extends PHPUnit_Framework_TestCase { | |
public function setUp() { | |
$this->obj = new Controller; | |
$mock = $this->getMock(('iCurrency'), array('getExchangeRate')); | |
$mock->expects($this->any()) | |
->method('getExchangeRate') | |
->will($this->returnValue(1.93)); | |
$mockOfiObject = $this->getMock(('iObject'), array('setInstance', 'getValue'), array($mock)); | |
$mockOfiObject->expects($this->any()) | |
->method('getValue') | |
->will($this->returnValue(1.93)); | |
$this->obj->setObject($mock, $mockOfiObject); | |
} | |
/** | |
* @dataProvider trueValuesProvider | |
*/ | |
public function testgetTLtoCurrencyTrueValues($expectedValue, $givenValue) { | |
$this->assertEquals($expectedValue, $this->obj->getTLtoCurrency($givenValue)); | |
} | |
public function trueValuesProvider() { | |
return array( | |
array(1.93, 1.00), | |
array(3.86, 2.00), | |
array(4.825, 2.50), | |
array(246.9821, 127.97)); | |
} | |
/** | |
* @expectedException InvalidArgumentException | |
* @dataProvider wrongValuesProvider | |
*/ | |
public function testgetTLtoCurrencyWrongValues($givenValue) { | |
$this->obj->getTLtoCurrency($givenValue); | |
} | |
public function wrongValuesProvider() { | |
return array( | |
array(120), | |
array('string'), | |
array(1,2), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment