1: <?php
2: /*************************************************************************************/
3: /* */
4: /* Thelia */
5: /* */
6: /* Copyright (c) OpenStudio */
7: /* email : info@thelia.net */
8: /* web : http://www.thelia.net */
9: /* */
10: /* This program is free software; you can redistribute it and/or modify */
11: /* it under the terms of the GNU General Public License as published by */
12: /* the Free Software Foundation; either version 3 of the License */
13: /* */
14: /* This program is distributed in the hope that it will be useful, */
15: /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
16: /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
17: /* GNU General Public License for more details. */
18: /* */
19: /* You should have received a copy of the GNU General Public License */
20: /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
21: /* */
22: /*************************************************************************************/
23:
24: namespace Thelia\Tpex\Tests;
25:
26: use Thelia\Tpex\Tpex;
27:
28: class TpexTest extends \PHPUnit_Framework_TestCase
29: {
30: /**
31: * @param Thelia\Tpex\Tpex $tpex
32: * @param \ReflectionMethod $addProperty
33: * @dataProvider providerAddProperty
34: */
35: public function testAddProperty($tpex, $addProperty)
36: {
37:
38: $addProperty->invoke($tpex, "loop", "foo", "bar");
39:
40: $loop = \PHPUnit_Framework_Assert::readAttribute($tpex, "loop");
41:
42: $this->assertArrayHasKey("foo", $loop);
43: $this->assertEquals("bar", $loop["foo"]);
44: }
45:
46: /**
47: *
48: * @param Thelia\Tpex\Tpex $tpex
49: * @param \ReflectionMethod $addProperty
50: * @dataProvider providerAddProperty
51: * @expectedException \InvalidArgumentException
52: * @expectedExceptionMessage foo loop name already exists for bar class name
53: */
54: public function testAddPropertyAlreadyExisting($tpex, $addProperty)
55: {
56: $addProperty->invoke($tpex, "loop", "foo", "bar");
57: $addProperty->invoke($tpex, "loop", "foo", "bar");
58: }
59:
60: /**
61: *
62: * @param Thelia\Tpex\Tpex $tpex
63: * @param \ReflectionMethod $addProperty
64: * @dataProvider providerAddProperty
65: * @expectedException \InvalidArgumentException
66: * @expectedExceptionMessage fu property does not exists in Tpex class
67: */
68: public function testAddPropertyUnexistingProperty($tpex, $addProperty)
69: {
70: $addProperty->invoke($tpex, "fu", "foo", "bar");
71: }
72:
73: public function providerAddProperty()
74: {
75: $tpex = new Tpex();
76:
77: $addProperty = new \ReflectionMethod("Thelia\Tpex\Tpex", "addProperty");
78: $addProperty->setAccessible(true);
79:
80: return array(
81: array($tpex, $addProperty)
82: );
83: }
84: }