| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 52 | 
| Code Lines | 38 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| 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 | ||
| 47 | public function testSaveUpdateDeleteItem() | ||
| 48 | 	{ | ||
| 49 | $search = $this->object->createSearch(); | ||
| 50 | $search->setConditions( $search->compare( '==', 'customer.property.editor', $this->editor ) ); | ||
| 51 | $results = $this->object->searchItems( $search ); | ||
| 52 | |||
| 53 | 		if( ( $item = reset( $results ) ) === false ) { | ||
| 54 | throw new \RuntimeException( 'No property item found' ); | ||
| 55 | } | ||
| 56 | |||
| 57 | $item->setId( null ); | ||
| 58 | $item->setLanguageId( 'en' ); | ||
| 59 | $resultSaved = $this->object->saveItem( $item ); | ||
| 60 | $itemSaved = $this->object->getItem( $item->getId() ); | ||
| 61 | |||
| 62 | $itemExp = clone $itemSaved; | ||
| 63 | $itemExp->setValue( 'unittest' ); | ||
| 64 | $resultUpd = $this->object->saveItem( $itemExp ); | ||
| 65 | $itemUpd = $this->object->getItem( $itemExp->getId() ); | ||
| 66 | |||
| 67 | $this->object->deleteItem( $itemSaved->getId() ); | ||
| 68 | |||
| 69 | $context = \TestHelper::getContext(); | ||
| 70 | |||
| 71 | $this->assertTrue( $item->getId() !== null ); | ||
| 72 | $this->assertEquals( $item->getId(), $itemSaved->getId() ); | ||
| 73 | $this->assertEquals( $item->getParentId(), $itemSaved->getParentId() ); | ||
| 74 | $this->assertEquals( $item->getSiteId(), $itemSaved->getSiteId() ); | ||
| 75 | $this->assertEquals( $item->getType(), $itemSaved->getType() ); | ||
| 76 | $this->assertEquals( $item->getLanguageId(), $itemSaved->getLanguageId() ); | ||
| 77 | $this->assertEquals( $item->getValue(), $itemSaved->getValue() ); | ||
| 78 | |||
| 79 | $this->assertEquals( $context->getEditor(), $itemSaved->getEditor() ); | ||
| 80 | 		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeCreated() ); | ||
| 81 | 		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeModified() ); | ||
| 82 | |||
| 83 | $this->assertEquals( $itemExp->getId(), $itemUpd->getId() ); | ||
| 84 | $this->assertEquals( $itemExp->getParentId(), $itemUpd->getParentId() ); | ||
| 85 | $this->assertEquals( $itemExp->getSiteId(), $itemUpd->getSiteId() ); | ||
| 86 | $this->assertEquals( $itemExp->getType(), $itemUpd->getType() ); | ||
| 87 | $this->assertEquals( $itemExp->getLanguageId(), $itemUpd->getLanguageId() ); | ||
| 88 | $this->assertEquals( $itemExp->getValue(), $itemUpd->getValue() ); | ||
| 89 | |||
| 90 | $this->assertEquals( $context->getEditor(), $itemUpd->getEditor() ); | ||
| 91 | $this->assertEquals( $itemExp->getTimeCreated(), $itemUpd->getTimeCreated() ); | ||
| 92 | 		$this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemUpd->getTimeModified() ); | ||
| 93 | |||
| 94 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultSaved ); | ||
| 95 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultUpd ); | ||
| 96 | |||
| 97 | $this->expectException( '\\Aimeos\\MShop\\Exception' ); | ||
| 98 | $this->object->getItem( $itemSaved->getId() ); | ||
| 99 | } | ||
| 173 |