Informática Asociada ia doc & examples: templates Documentation Index Examples List


/iaLib/ia_examples/ia/Math/Combination_example.php


<?php $ia_example = [ 'title' => 'ia\Math\Combination', // fully qualified className 'summary' => '', // class summary 'full_example' => '', // full usage example, relative path from ia_examples, blank '' not shown. 'example_file' => 'code/ia/Math/Combination_example_code.php', // method by method example, blank '' not shown. ]; include( __DIR__ . '/../../template/ia_example_class.php');

/iaLib/ia_examples/code/ia/Math/Combination_example_code.php


use ia\Math\Combination; use ia\DocumentIt\DocumentIt; echo '<h3>Disclaimer: Auto generated file. Please help us setting parameters to useful values and extending the examples. </h3>'; try { echo '<ul class="usage">'; ///////// Combination::combinationsAll(['a' => '1', 'b' => '2', 'c' => 3]); ////////////////////////////////////////////////// echo <<< FUNCTIONDEF <li id='u_combinationsAll'><b>Combination::combinationsAll(<span class="type">array</span> \$set) <span>: \Generator</span></b> FUNCTIONDEF; echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\Combination", "combinationsAll")."</pre>"; echo "<ol class='usage'>"; /// display /// echo <<< DOCUMENT_EXAMPLE <li>echo "&lt;ul&gt;"; foreach(Combination::combinationsAll(['a' => '1', 'b' => '2', 'c' => 3]); as \$k => \$v) echo "&lt;li&gt;\$k := ". print_r(\$v, true)."&lt;/li&gt;"; echo "/&lt;ul&gt;"; DOCUMENT_EXAMPLE; /// run /// echo "<ul>"; foreach(Combination::combinationsAll(['a' => '1', 'b' => '2', 'c' => 3]) as $k => $v) echo "<li>$k := ". print_r($v, true)."</li>"; echo "</ul>"; echo '</ol>'; ///////// Combination::combinations(); ////////////////////////////////////////////////// echo <<< FUNCTIONDEF <li id='u_combinations'><b>Combination::combinations(<span class="type">array</span> \$set <span class="default">= []</span>, <span class="type">int</span> \$size <span class="default">= 0</span>) <span>: \Generator</span></b> FUNCTIONDEF; echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\Combination", "combinations")."</pre>"; echo "<ol class='usage'>"; /// display /// echo <<< DOCUMENT_EXAMPLE <li>echo "&lt;ul&gt;"; foreach(Combination::combinations(); as \$k => \$v) echo "&lt;li&gt;\$k := ". print_r(\$v, true)."&lt;/li&gt;"; echo "/&lt;ul&gt;"; DOCUMENT_EXAMPLE; /// run /// echo "<ul>"; foreach(Combination::combinations() as $k => $v) echo "<li>$k := ". print_r($v, true)."</li>"; echo "</ul>"; echo '</ol>'; ///////// Combination::combinationsAllCount(3); ////////////////////////////////////////////////// echo <<< FUNCTIONDEF <li id='u_combinationsAllCount'><b>Combination::combinationsAllCount(<span class="type">int</span> \$setLength) <span>: int</span></b> FUNCTIONDEF; echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\Combination", "combinationsAllCount")."</pre>"; echo "<ol class='usage'>"; /// display /// echo <<< DOCUMENT_EXAMPLE <li>Combination::combinationsAllCount(3); -&gt;&nbsp; DOCUMENT_EXAMPLE; /// run /// echo Combination::combinationsAllCount(3); echo '</ol>'; ///////// Combination::combinationsCount(3, 3); ////////////////////////////////////////////////// echo <<< FUNCTIONDEF <li id='u_combinationsCount'><b>Combination::combinationsCount(<span class="type">int</span> \$setLength, <span class="type">int</span> \$itemsNumber) <span>: int</span></b> FUNCTIONDEF; echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\Combination", "combinationsCount")."</pre>"; echo "<ol class='usage'>"; /// display /// echo <<< DOCUMENT_EXAMPLE <li>Combination::combinationsCount(3, 3); -&gt;&nbsp; DOCUMENT_EXAMPLE; /// run /// echo Combination::combinationsCount(3, 3); echo '</ol>'; /* PerfilExample adds new methods here */ echo '</ul>'; } catch(Exception $exception) { echo "<pre class='errorBlock'>$exception</pre>"; }

phpunit test file template


<?php use ia\Math\Combination; use PHPUnit\Framework\TestCase; class CombinationTest extends TestCase { /** * @dataProvider combinationsAll_Provider * */ public function test_combinationsAll($set , $expected) { $this->assertEquals($expected, Combination::combinationsAll($set) ); } function combinationsAll_Provider() { return [ 'test 1' => [ '', '' ], ]; } /** * @dataProvider combinations_Provider * */ public function test_combinations($set, $size , $expected) { $this->assertEquals($expected, Combination::combinations($set, $size) ); } function combinations_Provider() { return [ 'test 1' => [ '', '', '' ], ]; } /** * @dataProvider combinationsAllCount_Provider * */ public function test_combinationsAllCount($setLength , $expected) { $this->assertEquals($expected, Combination::combinationsAllCount($setLength) ); } function combinationsAllCount_Provider() { return [ 'test 1' => [ '', '' ], ]; } /** * @dataProvider combinationsCount_Provider * */ public function test_combinationsCount($setLength, $itemsNumber , $expected) { $this->assertEquals($expected, Combination::combinationsCount($setLength, $itemsNumber) ); } function combinationsCount_Provider() { return [ 'test 1' => [ '', '', '' ], ]; } }

ia Doc