Note that there are some explanatory texts on larger screens.

plurals
  1. PORe-using datasets in PHPUnit
    primarykey
    data
    text
    <p>I have a user object with property 1, property 2, and property 3. I have a separate function to edit each property. Therefore, I'll need to test each edit property function. So I'll create 3 different expected datasets for the tests of successful property edits. However, what if I end up adding a 4th property down the line? Won't this force me to now add this property/value to all of the other datasets? Should I just create 1 template dataset file, and then extract the data from the file and use a php array dataset? This way, if I add a new property, I won't have to modify all of the previous datasets?</p> <p>Concrete example:</p> <p>Let's say I want to test that my edit email function works properly, and only changes the email. My setup fixture would be:</p> <p>setup-fixture.xml:</p> <pre><code>&lt;dataset&gt; &lt;table name="users"&gt; &lt;column&gt;id&lt;/column&gt; &lt;column&gt;email&lt;/column&gt; &lt;column&gt;password&lt;/column&gt; &lt;row&gt; &lt;value&gt;1&lt;/value&gt; &lt;value&gt;user1@email.com&lt;/value&gt; &lt;value&gt;password&lt;/value&gt; &lt;/row&gt; &lt;/table&gt; &lt;/dataset&gt; </code></pre> <p>And my expected dataset would be:</p> <p>edit-email-expected-dataset.xml:</p> <pre><code>&lt;dataset&gt; &lt;table name="users"&gt; &lt;column&gt;id&lt;/column&gt; &lt;column&gt;email&lt;/column&gt; &lt;column&gt;password&lt;/column&gt; &lt;row&gt; &lt;value&gt;1&lt;/value&gt; &lt;value&gt;user1-changed-his-email@email.com&lt;/value&gt; &lt;value&gt;password&lt;/value&gt; &lt;/row&gt; &lt;/table&gt; &lt;/dataset&gt; </code></pre> <p>However, if I later added another property called "notes" to this user object, my setup fixture would now be: new-setup-fixture.xml:</p> <pre><code>&lt;dataset&gt; &lt;table name="users"&gt; &lt;column&gt;id&lt;/column&gt; &lt;column&gt;email&lt;/column&gt; &lt;column&gt;password&lt;/column&gt; &lt;column&gt;notes&lt;/column&gt; &lt;row&gt; &lt;value&gt;1&lt;/value&gt; &lt;value&gt;user1@email.com&lt;/value&gt; &lt;value&gt;password&lt;/value&gt; &lt;value&gt;notes&lt;/value&gt; &lt;/row&gt; &lt;/table&gt; &lt;/dataset&gt; </code></pre> <p>Therefore, I would also have to amend my expected dataset file in the edit e-mail function test to include this new "notes" property.</p> <p>edit-email-expected-dataset.xml:</p> <pre><code>&lt;dataset&gt; &lt;table name="users"&gt; &lt;column&gt;id&lt;/column&gt; &lt;column&gt;email&lt;/column&gt; &lt;column&gt;password&lt;/column&gt; &lt;column&gt;notes&lt;/column&gt; &lt;row&gt; &lt;value&gt;1&lt;/value&gt; &lt;value&gt;user1-changed-his-email@email.com&lt;/value&gt; &lt;value&gt;password&lt;/value&gt; &lt;value&gt;notes&lt;/value&gt; &lt;/row&gt; &lt;/table&gt; &lt;/dataset&gt; </code></pre> <p>My question is, how do I avoid having to edit all my expected datasets everytime I add an extra field?</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. 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