Attribute validations added to assert methods #859

Merged
merged 3 commits into from Mar 14, 2013

Conversation

Projects
None yet
3 participants
Contributor

destructivecreator commented Mar 13, 2013

  • Added additional validation of attribute name in assertions using class/object attributes
  • Added new Test in Tests/Framework/AssertTest.php to cover attribute validation

Validating class/object attribute against regex:

if(!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
        }

Result:

PHPUnit_Framework_Exception: Argument #2 (No Value) of PHPUnit_Framework_Assert::readAttribute() must be a valid attribute name

destructivecreator added some commits Mar 13, 2013

@destructivecreator destructivecreator Changes made for issue #855:
- Added additional validation of attribute name in assertions using class/object attributes
- Added new Test in Tests/Framework/AssertTest.php to cover attribute validation
8d44664
@destructivecreator destructivecreator Fixing a typo when reporting invalid attribute name 0ad7c41
@destructivecreator destructivecreator Changin 'valid name of attrubute with valid attribute name' 5684d75

whatthejeff merged commit 8a2f0c6 into sebastianbergmann:master Mar 14, 2013

1 check passed

default The Travis build passed
Details

@whatthejeff whatthejeff added a commit that referenced this pull request Mar 14, 2013

@whatthejeff whatthejeff Added the changelog entry for #859 90bf298
Collaborator

whatthejeff commented Mar 14, 2013

Thanks, @Agop!

Collaborator

edorian commented Mar 18, 2013

awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment