Conditions | 2 |
Paths | 2 |
Total Lines | 60 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 11 | ||
Bugs | 0 | Features | 5 |
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 |
||
26 | public function testMongoDbStore() { |
||
27 | try { |
||
28 | $this->setupMongoDb(); |
||
29 | } catch( MongoConnectionException $e ) { |
||
30 | $this->markTestSkipped( 'MongoDB is not running: ' . $e->getMessage() ); |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | $store = $this->getEntityStoreFromConfiguration(); |
||
35 | |||
36 | $this->assertEquals( |
||
37 | new ItemId( 'Q1' ), |
||
38 | $store->getItemLookup()->getItemForId( new ItemId( 'Q1' ) )->getId() |
||
39 | ); |
||
40 | |||
41 | $this->assertEquals( |
||
42 | new PropertyId( 'P1' ), |
||
43 | $store->getPropertyLookup()->getPropertyForId( new PropertyId( 'P1' ) )->getId() |
||
44 | ); |
||
45 | |||
46 | $results = $store->getEntityDocumentLookup()->getEntityDocumentsForIds( |
||
47 | [ new ItemId( 'Q1' ), new ItemId( 'Q1000' ) ] |
||
48 | ); |
||
49 | $this->assertEquals( 1, count( $results ) ); |
||
50 | $this->assertEquals( new ItemId( 'Q1' ), $results[0]->getId() ); |
||
51 | |||
52 | $this->assertEquals( |
||
53 | [ new ItemId( 'Q1' ) ], |
||
54 | $store->getItemIdForTermLookup()->getItemIdsForTerm( new Term( 'en', 'universe' ) ) |
||
55 | ); |
||
56 | |||
57 | $this->assertEquals( |
||
58 | [], |
||
59 | $store->getItemIdForTermLookup()->getItemIdsForTerm( new Term( 'pl', 'Kosmos' ) ) |
||
60 | ); |
||
61 | |||
62 | $this->assertEquals( |
||
63 | [ new PropertyId( 'P16' ) ], |
||
64 | $store->getPropertyIdForTermLookup()->getPropertyIdsForTerm( new Term( 'en', 'highway system' ) ) |
||
65 | ); |
||
66 | |||
67 | $this->assertEquals( |
||
68 | [ new PropertyId( 'P16' ) ], |
||
69 | $store->getPropertyIdForQueryLookup()->getPropertyIdsForQuery( |
||
70 | new AnyValue(), |
||
71 | new QueryOptions( 1, 0 ) |
||
72 | ) |
||
73 | ); |
||
74 | |||
75 | $this->assertEquals( |
||
76 | [ new ItemId( 'Q1' ) ], |
||
77 | $store->getItemIdForQueryLookup()->getItemIdsForQuery( |
||
78 | new SomeProperty( |
||
79 | new EntityIdValue( new PropertyId( 'P18' ) ), |
||
80 | new ValueDescription( new StringValue( 'Hubble ultra deep field.jpg' ) ) |
||
81 | ), |
||
82 | new QueryOptions( 10, 0 ) |
||
83 | ) |
||
84 | ); |
||
85 | } |
||
86 | |||
108 |