-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
BUG FIX - Uncaught exception when accessing admin with none existent use... #2
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
dev/tests/integration/testsuite/Mage/Admin/Model/UserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Magento | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magentocommerce.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Magento to newer | ||
* versions in the future. If you wish to customize Magento for your | ||
* needs please refer to http://www.magentocommerce.com for more information. | ||
* | ||
* @category Magento | ||
* @package Magento_Admin | ||
* @subpackage integration_tests | ||
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Tests admin user model: | ||
* - general behaviour is tested | ||
* | ||
* @group module:Mage_Admin | ||
* @magentoDataFixture Mage/Admin/_files/user.php | ||
*/ | ||
class Mage_Admin_Model_UserTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Mage_Admin_Model_User | ||
*/ | ||
protected $_model; | ||
|
||
protected function setUp() | ||
{ | ||
$this->_model = new Mage_Admin_Model_User; | ||
} | ||
|
||
/** | ||
* Ensure that an exception is not thrown if the user does not exist | ||
*/ | ||
public function testloadByUsername() { | ||
$this->_model->loadByUsername('non_exiting_user'); | ||
$this->assertNull($this->_model->getId(), 'The admin user has an unexpected ID'); | ||
$this->_model->loadByUsername('adminuser'); | ||
$this->assertTrue(!is_null($this->_model->getId()), 'The admin user should have been loaded'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
dev/tests/integration/testsuite/Mage/Admin/_files/user.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Magento | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@magentocommerce.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Magento to newer | ||
* versions in the future. If you wish to customize Magento for your | ||
* needs please refer to http://www.magentocommerce.com for more information. | ||
* | ||
* @category Magento | ||
* @package Mage_Admin | ||
* @subpackage integration_tests | ||
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
$product = new Mage_Admin_Model_User(); | ||
$product->setFirstname('Admin') | ||
->setLastname('User') | ||
->setEmail('test@magento.com') | ||
->setUsername('adminuser') | ||
->setPassword('1234567890') | ||
->setIsActive(1) | ||
->save(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like to practice implementing an integration test for this method?
Supposedly dev/tests/integration/testsuite/Mage/Admin/Model/UserTest.php -- it doesn't exist yet. But implementing just loadByUsernameTest() would be enough.
I recommend using @magentoDataFixture to create a test admin account fixture. The fixture will be reverted automatically after test execution.