Skip to content

Commit

Permalink
Merge branch 'release/release-1.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ctasca committed Jan 27, 2016
2 parents 17baf5d + 9f72968 commit 4deeb51
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
20 changes: 20 additions & 0 deletions examples/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ public function iSetupAnOauthConsumerFixture()
$this->_buildOauthConsumerFixture();
}


/**
* @Given I setup an admin fixture with role ids
*/
public function iSetupAnAdminFixtureWithRoleIds()
{
$this->_buildAdminWithRoleIdsFixture();
}

/**
*
* @throws Exception
Expand Down Expand Up @@ -297,6 +306,17 @@ protected function _buildAdminFixture()
);
}

/**
*
* @throws Exception
*/
protected function _buildAdminWithRoleIdsFixture()
{
FixtureBuilder::build(
FixtureBuilder::ADMIN_FIXTURE_TYPE, new FixturesLocator(), 'admin-with-role-ids.yml', '@AfterSuite'
);
}

/**
*
* @throws Exception
Expand Down
1 change: 1 addition & 0 deletions examples/features/fixtures.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Feature: Magento Fixtures
And I setup an api user fixture
And I setup a grouped product fixture
And I setup an admin fixture
And I setup an admin fixture with role ids
And I setup an oauth consumer fixture
13 changes: 11 additions & 2 deletions examples/features/fixtures/Data/Providers/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class Admin implements Provider
{
public function getUsername()
{
return 'testadmin';
$random = substr(md5(rand()), 0, 7);

return 'admin' . $random;
}

public function getFirstname()
Expand All @@ -31,11 +33,18 @@ public function getLastname()

public function getEmail()
{
return '[email protected]';
$random = substr(md5(rand()), 0, 7);

return 'admin' . $random . '@fixture.com';
}

public function getPassword()
{
return '123123pass';
}

public function getRoleIds()
{
return [1];
}
}
10 changes: 10 additions & 0 deletions examples/features/fixtures/yaml/admin-with-role-ids.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fixture:
model: admin/user
data_provider: 'Data\Providers\Admin'
attributes:
username: '{{getUsername}}'
firstname: '{{getFirstname}}'
lastname: '{{getLastname}}'
email: '{{getEmail}}'
password: '{{getPassword}}'
role_ids: '{{getRoleIds}}'
14 changes: 13 additions & 1 deletion magefix/src/Magefix/Fixture/Builder/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ class Admin extends AbstractBuilder
*/
public function build()
{
return $this->_build();
$fixtureId = $this->_build();
$this->_assignRoleIds();
return $fixtureId;
}

protected function _assignRoleIds()
{
if (isset($this->_data['fixture']['attributes']['roles_ids'])) {
$adminUser = $this->_getMageModel();
$adminUser->setRoleIds($this->_data['fixture']['attributes']['roles_ids'])
->setRoleUserId($adminUser->getId())
->saveRelations();
}
}
}

0 comments on commit 4deeb51

Please sign in to comment.