@@ -40,12 +40,64 @@ public function ParsesIso()
4040 }
4141
4242 /**
43- * @test
4443 * @expectedException \Money\InvalidArgumentException
4544 * @expectedExceptionMessage Can't create currency pair from ISO string '1.2500', format of string is invalid
4645 */
4746 public function ParsesIsoWithException ()
4847 {
4948 CurrencyPair::createFromIso ('1.2500 ' );
5049 }
50+
51+ /**
52+ * @expectedException \Money\InvalidArgumentException
53+ * @expectedExceptionMessage Ratio must be numeric
54+ * @dataProvider dataProviderNonNumericRatio
55+ */
56+ public function testConstructorWithNonNumericRatio ($ nonNumericRatio )
57+ {
58+ new CurrencyPair (new Currency ('EUR ' ), new Currency ('USD ' ), $ nonNumericRatio );
59+ }
60+
61+ public function testGetRatio ()
62+ {
63+ $ ratio = 1.2500 ;
64+ $ pair = new CurrencyPair (new Currency ('EUR ' ), new Currency ('USD ' ), $ ratio );
65+
66+ $ this ->assertEquals ($ ratio , $ pair ->getRatio ());
67+ }
68+
69+ public function testGetBaseCurrency ()
70+ {
71+ $ pair = new CurrencyPair (new Currency ('EUR ' ), new Currency ('USD ' ), 1.2500 );
72+
73+ $ this ->assertEquals (new Currency ('EUR ' ), $ pair ->getBaseCurrency ());
74+ }
75+
76+ public function testGetCounterCurrency ()
77+ {
78+ $ pair = new CurrencyPair (new Currency ('EUR ' ), new Currency ('USD ' ), 1.2500 );
79+
80+ $ this ->assertEquals (new Currency ('USD ' ), $ pair ->getCounterCurrency ());
81+ }
82+
83+ /**
84+ * @expectedException \Money\InvalidArgumentException
85+ * @expectedExceptionMessage The Money has the wrong currency
86+ */
87+ public function testConvertWithInvalidCurrency ()
88+ {
89+ $ money = new Money (100 , new Currency ('JPY ' ));
90+ $ pair = new CurrencyPair (new Currency ('EUR ' ), new Currency ('USD ' ), 1.2500 );
91+
92+ $ pair ->convert ($ money );
93+ }
94+
95+ public function dataProviderNonNumericRatio ()
96+ {
97+ return array (
98+ array ('NonNumericRatio ' ),
99+ array ('16AlsoIncorrect ' ),
100+ array ('10.00ThisIsToo ' )
101+ );
102+ }
51103}
0 commit comments