| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 34 | protected function setUp() |
||
| 35 | { |
||
| 36 | $this->securityFacade = $this->getMockBuilder('Oro\Bundle\SecurityBundle\SecurityFacade') |
||
| 37 | ->disableOriginalConstructor() |
||
| 38 | ->getMock(); |
||
| 39 | |||
| 40 | $this->aclVoter = $this->getMockBuilder('Oro\Bundle\SecurityBundle\Acl\Voter\AclVoter') |
||
| 41 | ->disableOriginalConstructor() |
||
| 42 | ->getMock(); |
||
| 43 | |||
| 44 | $this->treeProvider = $this->getMockBuilder('Oro\Bundle\SecurityBundle\Owner\OwnerTreeProvider') |
||
| 45 | ->setMethods([ |
||
| 46 | 'getTree', |
||
| 47 | 'getUserBusinessUnitIds', |
||
| 48 | 'getUserSubordinateBusinessUnitIds', |
||
| 49 | 'getAllBusinessUnitIds', |
||
| 50 | 'getOrganizationBusinessUnitIds' |
||
| 51 | ]) |
||
| 52 | ->disableOriginalConstructor() |
||
| 53 | ->getMock(); |
||
| 54 | |||
| 55 | $this->observer = $this->getMockBuilder('Oro\Bundle\SecurityBundle\Acl\Domain\OneShotIsGrantedObserver') |
||
| 56 | ->disableOriginalConstructor() |
||
| 57 | ->getMock(); |
||
| 58 | |||
| 59 | $this->user = $this->getMockBuilder('Oro\Bundle\UserBundle\Entity\User') |
||
| 60 | ->setMethods(['getId']) |
||
| 61 | ->disableOriginalConstructor() |
||
| 62 | ->getMock(); |
||
| 63 | |||
| 64 | $this->organization = $this->getMockBuilder('Oro\Bundle\OrganizationBundle\Entity\Organization') |
||
| 65 | ->setMethods(['getId']) |
||
| 66 | ->disableOriginalConstructor() |
||
| 67 | ->getMock(); |
||
| 68 | |||
| 69 | $this->securityFacade->expects($this->any()) |
||
| 70 | ->method('getLoggedUser') |
||
| 71 | ->will($this->returnValue($this->user)); |
||
| 72 | |||
| 73 | $this->securityFacade->expects($this->any()) |
||
| 74 | ->method('getOrganization') |
||
| 75 | ->will($this->returnValue($this->organization)); |
||
| 76 | |||
| 77 | $this->provider = $this->getMockBuilder('Oro\Bundle\OrganizationBundle\Provider\BusinessUnitAclProvider') |
||
| 78 | ->setMethods(['getAccessLevel']) |
||
| 79 | ->setConstructorArgs([ |
||
| 80 | $this->securityFacade, |
||
| 81 | $this->aclVoter, |
||
| 82 | $this->treeProvider |
||
| 83 | ]) |
||
| 84 | ->getMock(); |
||
| 85 | } |
||
| 86 | |||
| 167 |