Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom attribute values #16

Open
svalaskevicius opened this issue Oct 8, 2014 · 3 comments
Open

Custom attribute values #16

svalaskevicius opened this issue Oct 8, 2014 · 3 comments

Comments

@svalaskevicius
Copy link

It would be good to be able to load the default values from yaml, but still pass some attribute values that override the ones from yml before saving - this allows easier integration with behat steps such as "I have a product with special price "8" pounds" or similar.

@joshporter
Copy link

Great suggestion @svalaskevicius

I imagine this to be an array_merge, to use it for override defaults. This seems to be a cleaner way to go.

Would you imagine this simply to be an array passed as an argument in the loadFixture() function? i.e:

$this->manager = new FixtureManager(new YamlProvider());
$this->manager->loadFixture('catalog/product', null, [
   'special_price' => '8'
]);

Another approach would be use the second argument in the loadFixture() function which would be a path to an override yaml file. Functionality at the moment will just use this custom file in it's entirety. So if attributes are missing, it will cause an error.

I think repurposing this file as a place to override defaults would achieve the functionality suggested.

Thoughts and ideas would be much appreciated :)

@svalaskevicius
Copy link
Author

I think the passed array should be fine and cover all the cases I imagined :)

@joshporter
Copy link

@svalaskevicius see what you think to that PR :)

Do you reckon argument order is a concern? Wouldn't know if the array override or custom yaml files would be used more.

Would make it that bit cleaner:

$this->productFixture = $this->manager->loadFixture('catalog/product', null, array(
            'name' => 'Overridden Product Name',
        ));

to

$this->productFixture = $this->manager->loadFixture('catalog/product', array(
            'name' => 'Overridden Product Name',
        ));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants