|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * phpDocumentor |
| 4 | + * |
| 5 | + * PHP Version 5.3 |
| 6 | + * |
| 7 | + * @copyright 2010-2013 Mike van Riel / Naenius (http://www.naenius.com) |
| 8 | + * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 9 | + * @link http://phpdoc.org |
| 10 | + */ |
| 11 | + |
| 12 | +namespace phpDocumentor\Descriptor; |
| 13 | + |
| 14 | +class CreateArgumentTest extends BaseComponentTestCase |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @dataProvider switchBetweenStrategies |
| 18 | + */ |
| 19 | + public function testArgumentCanHaveName($projectDescriptor, $filename) |
| 20 | + { |
| 21 | + $this->projectDescriptor = $projectDescriptor; |
| 22 | + $this->filename = $filename; |
| 23 | + |
| 24 | + $method = $this->getMethodWithName('\Luigi\Pizza\PizzaComponentFactory', 'calculatePrice'); |
| 25 | + |
| 26 | + $firstArgument = current($method->getArguments()->getAll()); |
| 27 | + $this->assertSame('$additionalPrices', $firstArgument->getName()); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @dataProvider switchBetweenStrategies |
| 32 | + */ |
| 33 | + public function testArgumentCanHaveDescription($projectDescriptor, $filename) |
| 34 | + { |
| 35 | + $this->projectDescriptor = $projectDescriptor; |
| 36 | + $this->filename = $filename; |
| 37 | + |
| 38 | + $method = $this->getMethodWithName('\Luigi\Pizza\PizzaComponentFactory', 'calculatePrice'); |
| 39 | + |
| 40 | + $firstArgument = current($method->getArguments()->getAll()); |
| 41 | + $this->assertSame('Additional costs may be passed', $firstArgument->getDescription()); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @dataProvider switchBetweenStrategies |
| 46 | + */ |
| 47 | + public function testArgumentCanHaveType($projectDescriptor, $filename) |
| 48 | + { |
| 49 | + $this->markTestIncomplete(); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @dataProvider switchBetweenStrategies |
| 54 | + */ |
| 55 | + public function testArgumentCanHaveDefault($projectDescriptor, $filename) |
| 56 | + { |
| 57 | + $this->projectDescriptor = $projectDescriptor; |
| 58 | + $this->filename = $filename; |
| 59 | + |
| 60 | + $methodWithArgWithDefault = $this->getMethodWithName('\Luigi\Pizza', 'setSize'); |
| 61 | + $firstArgument = current($methodWithArgWithDefault->getArguments()->getAll()); |
| 62 | + $this->assertSame('\Luigi\Pizza\SIZE_20CM', $firstArgument->getDefault()); |
| 63 | + |
| 64 | + $methodWithArgWithoutDefault = $this->getMethodWithName('\Luigi\Pizza\PizzaComponentFactory', 'calculatePrice'); |
| 65 | + $firstArgument = current($methodWithArgWithoutDefault->getArguments()->getAll()); |
| 66 | + $this->assertNull($firstArgument->getDefault()); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @dataProvider switchBetweenStrategies |
| 71 | + */ |
| 72 | + public function testArgumentCanBeVariadic($projectDescriptor, $filename) |
| 73 | + { |
| 74 | + $this->projectDescriptor = $projectDescriptor; |
| 75 | + $this->filename = $filename; |
| 76 | + |
| 77 | + $methodWithVariadic = $this->getMethodWithName('\Luigi\Pizza\PizzaComponentFactory', 'calculatePrice'); |
| 78 | + $firstArgument = current($methodWithVariadic->getArguments()->getAll()); |
| 79 | + $this->assertTrue($firstArgument->isVariadic()); |
| 80 | + |
| 81 | + $methodWithoutVariadic = $this->getMethodWithName('\Luigi\Pizza', 'setSize'); |
| 82 | + $firstArgument = current($methodWithoutVariadic->getArguments()->getAll()); |
| 83 | + $this->assertFalse($firstArgument->isVariadic()); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * @dataProvider switchBetweenStrategies |
| 88 | + */ |
| 89 | + public function testArgumentCanBeByReference($projectDescriptor, $filename) |
| 90 | + { |
| 91 | + $this->projectDescriptor = $projectDescriptor; |
| 92 | + $this->filename = $filename; |
| 93 | + |
| 94 | + $methodWithArgByRef = $this->getMethodWithName('\Luigi\Pizza', 'setSize'); |
| 95 | + $firstArgument = current($methodWithArgByRef->getArguments()->getAll()); |
| 96 | + $this->assertTrue($firstArgument->isByReference()); |
| 97 | + |
| 98 | + $methodWithArgNotByRef = $this->getMethodWithName('\Luigi\Pizza\PizzaComponentFactory', 'calculatePrice'); |
| 99 | + $firstArgument = current($methodWithArgNotByRef->getArguments()->getAll()); |
| 100 | + $this->assertFalse($firstArgument->isByReference()); |
| 101 | + } |
| 102 | +} |
0 commit comments