Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As described in the PHPUnit documentation on <a href="http://www.phpunit.de/manual/3.6/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers" rel="noreferrer">Data Providers</a>:</p> <blockquote> <p>A data provider method must be <code>public</code> and either return an array of arrays or an object that implements the <code>Iterator</code> interface and yields an array for each iteration step. For each array that is part of the collection the test method will be called with the contents of the array as its arguments.</p> </blockquote> <p>Based on your <code>Test.php</code> source code, it seems you want something like this:</p> <pre><code> /** * test_add_client * @dataProvider add_client_provider */ public function test_add_client($data) { $company_id = 0; $id = $this-&gt;_m-&gt;add_client($company_id, $data); $this-&gt;assertEquals(true, is_int($id)); } public function add_client_provider() { $result = new PHPUnit_Extensions_Database_DataSet_YamlDataSet( dirname(__FILE__)."/../fixtures/Clients.yml"); // Return the Clients data $clients = array(); $tbl = $result-&gt;getTable('Clients'); for ($i = 0; $i &lt; $tbl-&gt;getRowCount(); $i++) { $clients[] = $tbl-&gt;getRow($i); } return $clients; } </code></pre> <p>Seems PHPUnit should provide a function to turn a dataset table directly in to an array of arrays, but I didn't see anything after a quick glance.</p> <p>The <code>phpunit.xml</code> file is irrelevant, and can be removed from your question, as far as I can tell.</p> <p>You also don't need the <code>try/catch</code> block in the PHPUnit test method - PHPUnit will take care of that for you.</p> <p>Note that your <code>$company_id</code> wasn't defined, so I just set it to 0. Your method arguments &amp; YAML data above don't seem to match up fully above either, but that should be easy to fix.</p> <p>By passing an array in to the test function, which gets passed immediately to the <code>add_client</code> method, your code is a bit more DRY as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload