| Conditions | 1 |
| Paths | 1 |
| Total Lines | 69 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 56 | public function testRun() |
||
| 57 | { |
||
| 58 | $context = \TestHelperJobs::getContext(); |
||
| 59 | $aimeos = \TestHelperJobs::getAimeos(); |
||
| 60 | |||
| 61 | |||
| 62 | $mailStub = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\None' ) |
||
| 63 | ->disableOriginalConstructor() |
||
| 64 | ->getMock(); |
||
| 65 | |||
| 66 | $mailMsgStub = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\Message\\None' ) |
||
| 67 | ->disableOriginalConstructor() |
||
| 68 | ->disableOriginalClone() |
||
| 69 | ->getMock(); |
||
| 70 | |||
| 71 | $mailStub->expects( $this->once() ) |
||
| 72 | ->method( 'createMessage' ) |
||
| 73 | ->will( $this->returnValue( $mailMsgStub ) ); |
||
| 74 | |||
| 75 | $mailStub->expects( $this->once() )->method( 'send' ); |
||
| 76 | |||
| 77 | $context->setMail( $mailStub ); |
||
| 78 | |||
| 79 | |||
| 80 | $orderAddressItem = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ) |
||
| 81 | ->getSubManager( 'base' )->getSubManager( 'address' )->createItem(); |
||
| 82 | |||
| 83 | |||
| 84 | $name = 'ControllerJobsEmailPaymentDefaultRun'; |
||
| 85 | $context->getConfig()->set( 'mshop/order/manager/name', $name ); |
||
| 86 | |||
| 87 | $orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
||
| 88 | ->setMethods( array( 'searchItems', 'getSubManager' ) ) |
||
| 89 | ->setConstructorArgs( array( $context ) ) |
||
| 90 | ->getMock(); |
||
| 91 | |||
| 92 | $orderStatusManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Status\\Standard' ) |
||
| 93 | ->setMethods( array( 'saveItem' ) ) |
||
| 94 | ->setConstructorArgs( array( $context ) ) |
||
| 95 | ->getMock(); |
||
| 96 | |||
| 97 | $orderBaseManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Base\\Standard' ) |
||
| 98 | ->setMethods( array( 'load' ) ) |
||
| 99 | ->setConstructorArgs( array( $context ) ) |
||
| 100 | ->getMock(); |
||
| 101 | |||
| 102 | \Aimeos\MShop\Order\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Order\\Manager\\' . $name, $orderManagerStub ); |
||
| 103 | |||
| 104 | |||
| 105 | $orderItem = new \Aimeos\MShop\Order\Item\Standard( array( 'ctime' => '2000-01-01 00:00:00' ) ); |
||
| 106 | $orderBaseItem = $orderBaseManagerStub->createItem(); |
||
| 107 | $orderBaseItem->setAddress( $orderAddressItem ); |
||
| 108 | |||
| 109 | |||
| 110 | $orderManagerStub->expects( $this->exactly( 2 ) )->method( 'getSubManager' ) |
||
| 111 | ->will( $this->onConsecutiveCalls( $orderStatusManagerStub, $orderBaseManagerStub ) ); |
||
| 112 | |||
| 113 | $orderManagerStub->expects( $this->exactly( 4 ) )->method( 'searchItems' ) |
||
| 114 | ->will( $this->onConsecutiveCalls( array( $orderItem ), array(), array(), array() ) ); |
||
| 115 | |||
| 116 | $orderBaseManagerStub->expects( $this->once() )->method( 'load' ) |
||
| 117 | ->will( $this->returnValue( $orderBaseItem ) ); |
||
| 118 | |||
| 119 | $orderStatusManagerStub->expects( $this->once() )->method( 'saveItem' ); |
||
| 120 | |||
| 121 | |||
| 122 | $object = new \Aimeos\Controller\Jobs\Order\Email\Payment\Standard( $context, $aimeos ); |
||
| 123 | $object->run(); |
||
| 124 | } |
||
| 125 | |||
| 164 |