Conditions | 2 |
Paths | 2 |
Total Lines | 60 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
77 | public function testSaveUpdateDeleteItem() |
||
78 | { |
||
79 | $search = $this->object->createSearch(); |
||
80 | $search->setSlice(0, 1); |
||
81 | $items = $this->object->searchItems( $search ); |
||
82 | |||
83 | if( ( $item = reset( $items ) ) === false ) { |
||
84 | throw new \RuntimeException( 'No item found' ); |
||
85 | } |
||
86 | |||
87 | $item->setId( null ); |
||
88 | $item->setDomain( 'unittest' ); |
||
89 | $resultSaved = $this->object->saveItem( $item ); |
||
90 | $itemSaved = $this->object->getItem( $item->getId() ); |
||
91 | |||
92 | $itemExp = clone $itemSaved; |
||
93 | $itemExp->setDomain( 'unittest2' ); |
||
94 | $resultUpd = $this->object->saveItem( $itemExp ); |
||
95 | $itemUpd = $this->object->getItem( $itemExp->getId() ); |
||
96 | |||
97 | $this->object->deleteItem( $itemSaved->getId() ); |
||
98 | |||
99 | |||
100 | $this->assertTrue( $item->getId() !== null ); |
||
101 | $this->assertEquals( $item->getId(), $itemSaved->getId() ); |
||
102 | $this->assertEquals( $item->getSiteId(), $itemSaved->getSiteId() ); |
||
103 | $this->assertEquals( $item->getParentId(), $itemSaved->getParentId() ); |
||
104 | $this->assertEquals( $item->getType(), $itemSaved->getType() ); |
||
105 | $this->assertEquals( $item->getRefId(), $itemSaved->getRefId() ); |
||
106 | $this->assertEquals( $item->getDomain(), $itemSaved->getDomain() ); |
||
107 | $this->assertEquals( $item->getDateStart(), $itemSaved->getDateStart() ); |
||
108 | $this->assertEquals( $item->getDateEnd(), $itemSaved->getDateEnd() ); |
||
109 | $this->assertEquals( $item->getPosition(), $itemSaved->getPosition() ); |
||
110 | $this->assertEquals( $this->editor, $itemSaved->getEditor() ); |
||
111 | $this->assertStringStartsWith(date('Y-m-d', time()), $itemSaved->getTimeCreated()); |
||
112 | $this->assertStringStartsWith(date('Y-m-d', time()), $itemSaved->getTimeModified()); |
||
113 | |||
114 | $this->assertEquals( $this->editor, $itemSaved->getEditor() ); |
||
115 | $this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeCreated() ); |
||
116 | $this->assertRegExp('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeModified() ); |
||
117 | |||
118 | $this->assertEquals( $itemExp->getId(), $itemUpd->getId() ); |
||
119 | $this->assertEquals( $itemExp->getSiteId(), $itemUpd->getSiteId() ); |
||
120 | $this->assertEquals( $itemExp->getParentId(), $itemUpd->getParentId() ); |
||
121 | $this->assertEquals( $itemExp->getType(), $itemUpd->getType() ); |
||
122 | $this->assertEquals( $itemExp->getRefId(), $itemUpd->getRefId() ); |
||
123 | $this->assertEquals( $itemExp->getDomain(), $itemUpd->getDomain() ); |
||
124 | $this->assertEquals( $itemExp->getDateStart(), $itemUpd->getDateStart() ); |
||
125 | $this->assertEquals( $itemExp->getDateEnd(), $itemUpd->getDateEnd() ); |
||
126 | $this->assertEquals( $itemExp->getPosition(), $itemUpd->getPosition() ); |
||
127 | |||
128 | $this->assertEquals( $this->editor, $itemUpd->getEditor() ); |
||
129 | $this->assertEquals( $itemExp->getTimeCreated(), $itemUpd->getTimeCreated() ); |
||
130 | $this->assertRegExp( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemUpd->getTimeModified() ); |
||
131 | |||
132 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultSaved ); |
||
133 | $this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultUpd ); |
||
134 | |||
135 | $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
||
136 | $this->object->getItem( $itemSaved->getId() ); |
||
137 | } |
||
205 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths