sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

Question: Convert Array of Objects into DataSet #189

Closed chucky2305 closed 6 years ago

chucky2305 commented 7 years ago

This is my current, not working code:

protected function getDataSet()
{

    $dataSet = new DefaultDataSet();

    if (!empty($this->aliceFixtures)) {
        $loader = $this->container->get('fidry_alice_data_fixtures.doctrine.persister_loader');
        $aliceFixtures = $loader->load($this->aliceFixtures);
    }

    // add some more datasets from csv
    // add some more datasets from yaml
    return $dataSet;
}

Yaml and csv work pretty good, but how can it be done with the result of $loader->load(); The Result of this method is pretty simple:

array(2) {
  [0]=>
  object(My\Entity\ScaleUser)#253 (4) {
    ["id":"MyBundleBundle\Entity\ScaleUser":private]=>
    int(1)
    ["name":"MyBundleBundle\Entity\ScaleUser":private]=>
    string(7) "Müller"
    ["prename":"MyBundleBundle\Entity\ScaleUser":private]=>
    string(6) "Markus"
    ["userrole":"MyBundleBundle\Entity\ScaleUser":private]=>
    int(1)
  }
  [1]=>
  object(MyBundleBundle\Entity\ScaleUser)#255 (4) {
    ["id":"MyBundleBundle\Entity\ScaleUser":private]=>
    int(2)
    ["name":"MyBundleBundle\Entity\ScaleUser":private]=>
    string(11) "Mühlendorf"
    ["prename":"MyBundleBundle\Entity\ScaleUser":private]=>
    string(8) "Stefanie"
    ["userrole":"MyBundleBundle\Entity\ScaleUser":private]=>
    int(1)
  }
}

So my question is: How can i convert this array of object in a way, to that i can uses it as DataSet?

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.