@@ -37,300 +37,300 @@ |
||
| 37 | 37 | $this->createItemRowField(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - private function createStore( $doDbInstall = false ) { |
|
| 40 | + private function createStore($doDbInstall = false) { |
|
| 41 | 41 | $connection = TestFixtureFactory::newInstance()->newConnection(); |
| 42 | 42 | $config = new EntityStoreConfig(); |
| 43 | 43 | |
| 44 | - if ( $doDbInstall ) { |
|
| 45 | - $installer = new EntityStoreInstaller( $connection->getSchemaManager(), $config ); |
|
| 44 | + if ($doDbInstall) { |
|
| 45 | + $installer = new EntityStoreInstaller($connection->getSchemaManager(), $config); |
|
| 46 | 46 | $installer->install(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $this->store = ( new EntityStoreFactory( $connection, $config ) )->newItemStore(); |
|
| 49 | + $this->store = (new EntityStoreFactory($connection, $config))->newItemStore(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | private function createItemRowField() { |
| 53 | - $this->itemRow = ( new ItemRow() ) |
|
| 54 | - ->setPageTitle( 'Item:Q1337' ) |
|
| 55 | - ->setRevisionId( '424242' ) |
|
| 56 | - ->setItemType( 1 ) |
|
| 57 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 58 | - ->setEnglishLabel( 'kittens' ) |
|
| 59 | - ->setEnglishWikipediaTitle( 'cats' ) |
|
| 60 | - ->setItemJson( 'json be here' ) |
|
| 61 | - ->setNumericItemId( self::ITEM_ID ); |
|
| 53 | + $this->itemRow = (new ItemRow()) |
|
| 54 | + ->setPageTitle('Item:Q1337') |
|
| 55 | + ->setRevisionId('424242') |
|
| 56 | + ->setItemType(1) |
|
| 57 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 58 | + ->setEnglishLabel('kittens') |
|
| 59 | + ->setEnglishWikipediaTitle('cats') |
|
| 60 | + ->setItemJson('json be here') |
|
| 61 | + ->setNumericItemId(self::ITEM_ID); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function testCanStoreAndRetrieveItemPage() { |
| 65 | - $this->createStore( self::AND_INSTALL ); |
|
| 65 | + $this->createStore(self::AND_INSTALL); |
|
| 66 | 66 | |
| 67 | - $this->store->storeItemRow( $this->itemRow ); |
|
| 67 | + $this->store->storeItemRow($this->itemRow); |
|
| 68 | 68 | |
| 69 | - $newItemRow = $this->store->getItemRowByNumericItemId( self::ITEM_ID ); |
|
| 69 | + $newItemRow = $this->store->getItemRowByNumericItemId(self::ITEM_ID); |
|
| 70 | 70 | |
| 71 | - $this->assertInstanceOf( 'Queryr\EntityStore\Data\ItemRow', $newItemRow ); |
|
| 71 | + $this->assertInstanceOf('Queryr\EntityStore\Data\ItemRow', $newItemRow); |
|
| 72 | 72 | |
| 73 | - $this->assertSame( $this->itemRow->getNumericItemId(), $newItemRow->getNumericItemId() ); |
|
| 74 | - $this->assertSame( $this->itemRow->getItemJson(), $newItemRow->getItemJson() ); |
|
| 75 | - $this->assertSame( $this->itemRow->getPageTitle(), $newItemRow->getPageTitle() ); |
|
| 76 | - $this->assertSame( $this->itemRow->getRevisionId(), $newItemRow->getRevisionId() ); |
|
| 77 | - $this->assertSame( $this->itemRow->getRevisionTime(), $newItemRow->getRevisionTime() ); |
|
| 78 | - $this->assertSame( $this->itemRow->getItemType(), $newItemRow->getItemType() ); |
|
| 79 | - $this->assertSame( $this->itemRow->getEnglishLabel(), $newItemRow->getEnglishLabel() ); |
|
| 80 | - $this->assertSame( $this->itemRow->getEnglishWikipediaTitle(), $newItemRow->getEnglishWikipediaTitle() ); |
|
| 73 | + $this->assertSame($this->itemRow->getNumericItemId(), $newItemRow->getNumericItemId()); |
|
| 74 | + $this->assertSame($this->itemRow->getItemJson(), $newItemRow->getItemJson()); |
|
| 75 | + $this->assertSame($this->itemRow->getPageTitle(), $newItemRow->getPageTitle()); |
|
| 76 | + $this->assertSame($this->itemRow->getRevisionId(), $newItemRow->getRevisionId()); |
|
| 77 | + $this->assertSame($this->itemRow->getRevisionTime(), $newItemRow->getRevisionTime()); |
|
| 78 | + $this->assertSame($this->itemRow->getItemType(), $newItemRow->getItemType()); |
|
| 79 | + $this->assertSame($this->itemRow->getEnglishLabel(), $newItemRow->getEnglishLabel()); |
|
| 80 | + $this->assertSame($this->itemRow->getEnglishWikipediaTitle(), $newItemRow->getEnglishWikipediaTitle()); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function testGivenNotKnownId_getItemRowByNumericItemIdReturnsNull() { |
| 84 | - $this->createStore( self::AND_INSTALL ); |
|
| 85 | - $this->assertNull( $this->store->getItemRowByNumericItemId( '32202' ) ); |
|
| 84 | + $this->createStore(self::AND_INSTALL); |
|
| 85 | + $this->assertNull($this->store->getItemRowByNumericItemId('32202')); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function testWhenStoreNotInitialized_storeItemRowThrowsException() { |
| 89 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 90 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 91 | - $this->store->storeItemRow( $this->itemRow ); |
|
| 89 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 90 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 91 | + $this->store->storeItemRow($this->itemRow); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public function testWhenStoreNotInitialized_getItemRowByNumericItemIdThrowsException() { |
| 95 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 96 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 97 | - $this->store->getItemRowByNumericItemId( 1 ); |
|
| 95 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 96 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 97 | + $this->store->getItemRowByNumericItemId(1); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function testWhenStoreNotInitialized_getItemInfoThrowsException() { |
| 101 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 102 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 103 | - $this->store->getItemInfo( 10, 0 ); |
|
| 101 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 102 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 103 | + $this->store->getItemInfo(10, 0); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function testWhenStoreNotInitialized_getItemTypesThrowsException() { |
| 107 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 108 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 107 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 108 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 109 | 109 | $this->store->getItemTypes(); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function testWhenNoItemsInStore_getItemTypesReturnsEmptyArray() { |
| 113 | - $this->createStore( self::AND_INSTALL ); |
|
| 114 | - $this->assertSame( [], $this->store->getItemTypes() ); |
|
| 113 | + $this->createStore(self::AND_INSTALL); |
|
| 114 | + $this->assertSame([], $this->store->getItemTypes()); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | private function insertFiveItems() { |
| 118 | 118 | $this->store->storeItemRow( |
| 119 | - ( new ItemRow() ) |
|
| 120 | - ->setPageTitle( 'Item:Q1000' ) |
|
| 121 | - ->setRevisionId( '123456' ) |
|
| 122 | - ->setItemType( 5 ) |
|
| 123 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 124 | - ->setEnglishLabel( 'kittens' ) |
|
| 125 | - ->setItemJson( 'json be here' ) |
|
| 126 | - ->setNumericItemId( 1000 ) |
|
| 119 | + (new ItemRow()) |
|
| 120 | + ->setPageTitle('Item:Q1000') |
|
| 121 | + ->setRevisionId('123456') |
|
| 122 | + ->setItemType(5) |
|
| 123 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 124 | + ->setEnglishLabel('kittens') |
|
| 125 | + ->setItemJson('json be here') |
|
| 126 | + ->setNumericItemId(1000) |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | $this->store->storeItemRow( |
| 130 | - ( new ItemRow() ) |
|
| 131 | - ->setPageTitle( 'Item:Q2000' ) |
|
| 132 | - ->setRevisionId( '234567' ) |
|
| 133 | - ->setItemType( 5 ) |
|
| 134 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 135 | - ->setEnglishLabel( 'cats' ) |
|
| 136 | - ->setItemJson( 'json be here' ) |
|
| 137 | - ->setNumericItemId( 2000 ) |
|
| 130 | + (new ItemRow()) |
|
| 131 | + ->setPageTitle('Item:Q2000') |
|
| 132 | + ->setRevisionId('234567') |
|
| 133 | + ->setItemType(5) |
|
| 134 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 135 | + ->setEnglishLabel('cats') |
|
| 136 | + ->setItemJson('json be here') |
|
| 137 | + ->setNumericItemId(2000) |
|
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | 140 | $this->store->storeItemRow( |
| 141 | - ( new ItemRow() ) |
|
| 142 | - ->setPageTitle( 'Item:Q3000' ) |
|
| 143 | - ->setRevisionId( '345678' ) |
|
| 144 | - ->setItemType( 1 ) |
|
| 145 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 146 | - ->setEnglishLabel( 'more cats' ) |
|
| 147 | - ->setItemJson( 'json be here' ) |
|
| 148 | - ->setNumericItemId( 3000 ) |
|
| 141 | + (new ItemRow()) |
|
| 142 | + ->setPageTitle('Item:Q3000') |
|
| 143 | + ->setRevisionId('345678') |
|
| 144 | + ->setItemType(1) |
|
| 145 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 146 | + ->setEnglishLabel('more cats') |
|
| 147 | + ->setItemJson('json be here') |
|
| 148 | + ->setNumericItemId(3000) |
|
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | 151 | $this->store->storeItemRow( |
| 152 | - ( new ItemRow() ) |
|
| 153 | - ->setPageTitle( 'Item:Q4000' ) |
|
| 154 | - ->setRevisionId( '456789' ) |
|
| 155 | - ->setItemType( null ) |
|
| 156 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 157 | - ->setEnglishLabel( 'more kittens' ) |
|
| 158 | - ->setItemJson( 'json be here' ) |
|
| 159 | - ->setNumericItemId( 4000 ) |
|
| 152 | + (new ItemRow()) |
|
| 153 | + ->setPageTitle('Item:Q4000') |
|
| 154 | + ->setRevisionId('456789') |
|
| 155 | + ->setItemType(null) |
|
| 156 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 157 | + ->setEnglishLabel('more kittens') |
|
| 158 | + ->setItemJson('json be here') |
|
| 159 | + ->setNumericItemId(4000) |
|
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | $this->store->storeItemRow( |
| 163 | - ( new ItemRow() ) |
|
| 164 | - ->setPageTitle( 'Item:Q5000' ) |
|
| 165 | - ->setRevisionId( '567890' ) |
|
| 166 | - ->setItemType( 3 ) |
|
| 167 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 168 | - ->setEnglishLabel( 'all kittens' ) |
|
| 169 | - ->setItemJson( 'json be here' ) |
|
| 170 | - ->setNumericItemId( 5000 ) |
|
| 163 | + (new ItemRow()) |
|
| 164 | + ->setPageTitle('Item:Q5000') |
|
| 165 | + ->setRevisionId('567890') |
|
| 166 | + ->setItemType(3) |
|
| 167 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 168 | + ->setEnglishLabel('all kittens') |
|
| 169 | + ->setItemJson('json be here') |
|
| 170 | + ->setNumericItemId(5000) |
|
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function testGetItemTypesReturnsDistinctNonNullTypes() { |
| 175 | - $this->createStore( self::AND_INSTALL ); |
|
| 175 | + $this->createStore(self::AND_INSTALL); |
|
| 176 | 176 | $this->insertFiveItems(); |
| 177 | 177 | |
| 178 | - $this->assertSame( [ 1, 3, 5 ], $this->store->getItemTypes() ); |
|
| 178 | + $this->assertSame([1, 3, 5], $this->store->getItemTypes()); |
|
| 179 | 179 | |
| 180 | - $this->assertSame( [ 1 ], $this->store->getItemTypes( 1, 0 ) ); |
|
| 181 | - $this->assertSame( [ 3, 5 ], $this->store->getItemTypes( 10, 1 ) ); |
|
| 180 | + $this->assertSame([1], $this->store->getItemTypes(1, 0)); |
|
| 181 | + $this->assertSame([3, 5], $this->store->getItemTypes(10, 1)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | public function testGivenNullTypeFilter_getItemInfoReturnsAllItems() { |
| 185 | - $this->createStore( self::AND_INSTALL ); |
|
| 185 | + $this->createStore(self::AND_INSTALL); |
|
| 186 | 186 | $this->insertFiveItems(); |
| 187 | 187 | |
| 188 | - $this->assertCount( 5, $this->store->getItemInfo( 10, 0, null ) ); |
|
| 188 | + $this->assertCount(5, $this->store->getItemInfo(10, 0, null)); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | public function testGivenMatchingTypeFilter_getItemInfoReturnsOnlyMatchingItems() { |
| 192 | - $this->createStore( self::AND_INSTALL ); |
|
| 192 | + $this->createStore(self::AND_INSTALL); |
|
| 193 | 193 | $this->insertFiveItems(); |
| 194 | 194 | |
| 195 | - $itemInfo = $this->store->getItemInfo( 10, 0, 5 ); |
|
| 195 | + $itemInfo = $this->store->getItemInfo(10, 0, 5); |
|
| 196 | 196 | |
| 197 | - $this->assertCount( 2, $itemInfo ); |
|
| 198 | - $this->assertSame( 1000, $itemInfo[0]->getNumericItemId() ); |
|
| 199 | - $this->assertSame( 2000, $itemInfo[1]->getNumericItemId() ); |
|
| 197 | + $this->assertCount(2, $itemInfo); |
|
| 198 | + $this->assertSame(1000, $itemInfo[0]->getNumericItemId()); |
|
| 199 | + $this->assertSame(2000, $itemInfo[1]->getNumericItemId()); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function testGivenNonMatchingTypeFilter_getItemInfoReturnsEmptyArray() { |
| 203 | - $this->createStore( self::AND_INSTALL ); |
|
| 203 | + $this->createStore(self::AND_INSTALL); |
|
| 204 | 204 | $this->insertFiveItems(); |
| 205 | 205 | |
| 206 | - $this->assertSame( [], $this->store->getItemInfo( 10, 0, 1337 ) ); |
|
| 206 | + $this->assertSame([], $this->store->getItemInfo(10, 0, 1337)); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function testInsertingExistingItemOverridesTheOriginalOne() { |
| 210 | - $this->createStore( self::AND_INSTALL ); |
|
| 210 | + $this->createStore(self::AND_INSTALL); |
|
| 211 | 211 | |
| 212 | 212 | $this->store->storeItemRow( |
| 213 | - ( new ItemRow() ) |
|
| 214 | - ->setPageTitle( 'Item:Q1000' ) |
|
| 215 | - ->setRevisionId( '123456' ) |
|
| 216 | - ->setItemType( 5 ) |
|
| 217 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 218 | - ->setEnglishLabel( 'kittens' ) |
|
| 219 | - ->setItemJson( 'json be here' ) |
|
| 220 | - ->setNumericItemId( 1000 ) |
|
| 213 | + (new ItemRow()) |
|
| 214 | + ->setPageTitle('Item:Q1000') |
|
| 215 | + ->setRevisionId('123456') |
|
| 216 | + ->setItemType(5) |
|
| 217 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 218 | + ->setEnglishLabel('kittens') |
|
| 219 | + ->setItemJson('json be here') |
|
| 220 | + ->setNumericItemId(1000) |
|
| 221 | 221 | ); |
| 222 | 222 | |
| 223 | 223 | $this->store->storeItemRow( |
| 224 | - ( new ItemRow() ) |
|
| 225 | - ->setPageTitle( 'Item:Q1000' ) |
|
| 226 | - ->setRevisionId( '123456789' ) |
|
| 227 | - ->setItemType( 4 ) |
|
| 228 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 229 | - ->setEnglishLabel( 'cats' ) |
|
| 230 | - ->setItemJson( 'json be here' ) |
|
| 231 | - ->setNumericItemId( 1000 ) |
|
| 224 | + (new ItemRow()) |
|
| 225 | + ->setPageTitle('Item:Q1000') |
|
| 226 | + ->setRevisionId('123456789') |
|
| 227 | + ->setItemType(4) |
|
| 228 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 229 | + ->setEnglishLabel('cats') |
|
| 230 | + ->setItemJson('json be here') |
|
| 231 | + ->setNumericItemId(1000) |
|
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | - $infoSets = $this->store->getItemInfo( 10, 0 ); |
|
| 235 | - $this->assertCount( 1, $infoSets ); |
|
| 236 | - $this->assertSame( 4, $infoSets[0]->getItemType() ); |
|
| 234 | + $infoSets = $this->store->getItemInfo(10, 0); |
|
| 235 | + $this->assertCount(1, $infoSets); |
|
| 236 | + $this->assertSame(4, $infoSets[0]->getItemType()); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public function testWhenStoreNotInitialized_deleteItemByIdThrowsException() { |
| 240 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 241 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 242 | - $this->store->deleteItemById( new ItemId( 'Q1' ) ); |
|
| 240 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 241 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 242 | + $this->store->deleteItemById(new ItemId('Q1')); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public function testGivenNonExistingId_deleteItemByIdDoesNotDeleteItems() { |
| 246 | - $this->createStore( self::AND_INSTALL ); |
|
| 246 | + $this->createStore(self::AND_INSTALL); |
|
| 247 | 247 | |
| 248 | 248 | $this->store->storeItemRow( |
| 249 | - ( new ItemRow() ) |
|
| 250 | - ->setPageTitle( 'Item:Q1000' ) |
|
| 251 | - ->setRevisionId( '123456' ) |
|
| 252 | - ->setItemType( 5 ) |
|
| 253 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 254 | - ->setEnglishLabel( 'kittens' ) |
|
| 255 | - ->setItemJson( 'json be here' ) |
|
| 256 | - ->setNumericItemId( 1000 ) |
|
| 249 | + (new ItemRow()) |
|
| 250 | + ->setPageTitle('Item:Q1000') |
|
| 251 | + ->setRevisionId('123456') |
|
| 252 | + ->setItemType(5) |
|
| 253 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 254 | + ->setEnglishLabel('kittens') |
|
| 255 | + ->setItemJson('json be here') |
|
| 256 | + ->setNumericItemId(1000) |
|
| 257 | 257 | ); |
| 258 | 258 | |
| 259 | - $this->store->deleteItemById( new ItemId( 'Q1001' ) ); |
|
| 259 | + $this->store->deleteItemById(new ItemId('Q1001')); |
|
| 260 | 260 | |
| 261 | - $this->assertCount( 1, $this->store->getItemInfo( 10, 0 ) ); |
|
| 261 | + $this->assertCount(1, $this->store->getItemInfo(10, 0)); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | public function testGivenExistingId_deleteItemByIdDeletesItem() { |
| 265 | - $this->createStore( self::AND_INSTALL ); |
|
| 265 | + $this->createStore(self::AND_INSTALL); |
|
| 266 | 266 | |
| 267 | 267 | $this->store->storeItemRow( |
| 268 | - ( new ItemRow() ) |
|
| 269 | - ->setPageTitle( 'Item:Q1000' ) |
|
| 270 | - ->setRevisionId( '123456' ) |
|
| 271 | - ->setItemType( 5 ) |
|
| 272 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 273 | - ->setEnglishLabel( 'kittens' ) |
|
| 274 | - ->setItemJson( 'json be here' ) |
|
| 275 | - ->setNumericItemId( 1000 ) |
|
| 268 | + (new ItemRow()) |
|
| 269 | + ->setPageTitle('Item:Q1000') |
|
| 270 | + ->setRevisionId('123456') |
|
| 271 | + ->setItemType(5) |
|
| 272 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 273 | + ->setEnglishLabel('kittens') |
|
| 274 | + ->setItemJson('json be here') |
|
| 275 | + ->setNumericItemId(1000) |
|
| 276 | 276 | ); |
| 277 | 277 | |
| 278 | - $this->store->deleteItemById( new ItemId( 'Q1000' ) ); |
|
| 278 | + $this->store->deleteItemById(new ItemId('Q1000')); |
|
| 279 | 279 | |
| 280 | - $this->assertCount( 0, $this->store->getItemInfo( 10, 0 ) ); |
|
| 280 | + $this->assertCount(0, $this->store->getItemInfo(10, 0)); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | public function testGivenNotExistingPage_getIdForEnWikiPageReturnsNull() { |
| 284 | - $this->createStore( self::AND_INSTALL ); |
|
| 284 | + $this->createStore(self::AND_INSTALL); |
|
| 285 | 285 | |
| 286 | - $this->assertNull( $this->store->getIdForEnWikiPage( 'kittens' ) ); |
|
| 286 | + $this->assertNull($this->store->getIdForEnWikiPage('kittens')); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | public function testWhenStoreNotInitialized_getIdForEnWikiPageThrowsException() { |
| 290 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 291 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 292 | - $this->assertNull( $this->store->getIdForEnWikiPage( 'kittens' ) ); |
|
| 290 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 291 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 292 | + $this->assertNull($this->store->getIdForEnWikiPage('kittens')); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | public function testGivenExistingPage_getIdForEnWikiPageReturnsPage() { |
| 296 | - $this->createStore( self::AND_INSTALL ); |
|
| 296 | + $this->createStore(self::AND_INSTALL); |
|
| 297 | 297 | |
| 298 | 298 | $this->store->storeItemRow( |
| 299 | - ( new ItemRow() ) |
|
| 300 | - ->setPageTitle( 'Item:Q55555' ) |
|
| 301 | - ->setRevisionId( '55555555' ) |
|
| 302 | - ->setItemType( 5 ) |
|
| 303 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 304 | - ->setEnglishWikipediaTitle( 'cats' ) |
|
| 305 | - ->setItemJson( 'json be here' ) |
|
| 306 | - ->setNumericItemId( 55555 ) |
|
| 299 | + (new ItemRow()) |
|
| 300 | + ->setPageTitle('Item:Q55555') |
|
| 301 | + ->setRevisionId('55555555') |
|
| 302 | + ->setItemType(5) |
|
| 303 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 304 | + ->setEnglishWikipediaTitle('cats') |
|
| 305 | + ->setItemJson('json be here') |
|
| 306 | + ->setNumericItemId(55555) |
|
| 307 | 307 | ); |
| 308 | 308 | |
| 309 | 309 | $this->store->storeItemRow( |
| 310 | - ( new ItemRow() ) |
|
| 311 | - ->setPageTitle( 'Item:Q1000' ) |
|
| 312 | - ->setRevisionId( '123456' ) |
|
| 313 | - ->setItemType( 1 ) |
|
| 314 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 315 | - ->setEnglishWikipediaTitle( 'kittens' ) |
|
| 316 | - ->setItemJson( 'json be here' ) |
|
| 317 | - ->setNumericItemId( 1000 ) |
|
| 310 | + (new ItemRow()) |
|
| 311 | + ->setPageTitle('Item:Q1000') |
|
| 312 | + ->setRevisionId('123456') |
|
| 313 | + ->setItemType(1) |
|
| 314 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 315 | + ->setEnglishWikipediaTitle('kittens') |
|
| 316 | + ->setItemJson('json be here') |
|
| 317 | + ->setNumericItemId(1000) |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | $this->store->storeItemRow( |
| 321 | - ( new ItemRow() ) |
|
| 322 | - ->setPageTitle( 'Item:Q999999' ) |
|
| 323 | - ->setRevisionId( '9999999' ) |
|
| 324 | - ->setItemType( 9 ) |
|
| 325 | - ->setRevisionTime( '2014-02-27T11:40:12Z' ) |
|
| 326 | - ->setEnglishWikipediaTitle( 'fluff' ) |
|
| 327 | - ->setItemJson( 'json be here' ) |
|
| 328 | - ->setNumericItemId( 999999 ) |
|
| 321 | + (new ItemRow()) |
|
| 322 | + ->setPageTitle('Item:Q999999') |
|
| 323 | + ->setRevisionId('9999999') |
|
| 324 | + ->setItemType(9) |
|
| 325 | + ->setRevisionTime('2014-02-27T11:40:12Z') |
|
| 326 | + ->setEnglishWikipediaTitle('fluff') |
|
| 327 | + ->setItemJson('json be here') |
|
| 328 | + ->setNumericItemId(999999) |
|
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | 331 | $this->assertEquals( |
| 332 | - new ItemId( 'Q1000' ), |
|
| 333 | - $this->store->getIdForEnWikiPage( 'kittens' ) |
|
| 332 | + new ItemId('Q1000'), |
|
| 333 | + $this->store->getIdForEnWikiPage('kittens') |
|
| 334 | 334 | ); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | $connection = TestFixtureFactory::newInstance()->newConnection(); |
| 23 | 23 | $config = new EntityStoreConfig(); |
| 24 | 24 | |
| 25 | - $this->factory = new EntityStoreFactory( $connection, $config ); |
|
| 25 | + $this->factory = new EntityStoreFactory($connection, $config); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function testPropertyTypeLookupThrowsExceptionWhenStoreNotInstalled() { |
| 29 | - $this->setExpectedException( 'Queryr\EntityStore\PropertyTypeLookupException' ); |
|
| 30 | - $this->factory->newPropertyTypeLookup()->getTypeOfProperty( new PropertyId( 'P2' ) ); |
|
| 29 | + $this->setExpectedException('Queryr\EntityStore\PropertyTypeLookupException'); |
|
| 30 | + $this->factory->newPropertyTypeLookup()->getTypeOfProperty(new PropertyId('P2')); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | } |
@@ -45,38 +45,38 @@ discard block |
||
| 45 | 45 | $connection = TestFixtureFactory::newInstance()->newConnection(); |
| 46 | 46 | $config = new EntityStoreConfig(); |
| 47 | 47 | |
| 48 | - $installer = new EntityStoreInstaller( $connection->getSchemaManager(), $config ); |
|
| 48 | + $installer = new EntityStoreInstaller($connection->getSchemaManager(), $config); |
|
| 49 | 49 | $installer->install(); |
| 50 | 50 | |
| 51 | - $this->store = ( new EntityStoreFactory( $connection, $config ) )->newEntityStore(); |
|
| 51 | + $this->store = (new EntityStoreFactory($connection, $config))->newEntityStore(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function insertItemRows() { |
| 55 | - foreach ( [ 1, 10, 2, 9, 8, 7, 3, 4, 6, 5 ] as $integer ) { |
|
| 56 | - $row = ( new ItemRow() ) |
|
| 57 | - ->setItemJson( 'json be here ' . $integer ) |
|
| 58 | - ->setEnglishLabel( 'item ' . $integer ) |
|
| 59 | - ->setItemType( $integer + 1 ) |
|
| 60 | - ->setRevisionTime( '2014-02-27T11:40:' . $integer . 'Z' ) |
|
| 61 | - ->setRevisionId( '424242' . $integer ) |
|
| 62 | - ->setNumericItemId( $integer ) |
|
| 63 | - ->setPageTitle( 'Item:Q' . $integer ); |
|
| 55 | + foreach ([1, 10, 2, 9, 8, 7, 3, 4, 6, 5] as $integer) { |
|
| 56 | + $row = (new ItemRow()) |
|
| 57 | + ->setItemJson('json be here '.$integer) |
|
| 58 | + ->setEnglishLabel('item '.$integer) |
|
| 59 | + ->setItemType($integer + 1) |
|
| 60 | + ->setRevisionTime('2014-02-27T11:40:'.$integer.'Z') |
|
| 61 | + ->setRevisionId('424242'.$integer) |
|
| 62 | + ->setNumericItemId($integer) |
|
| 63 | + ->setPageTitle('Item:Q'.$integer); |
|
| 64 | 64 | |
| 65 | 65 | $this->itemInfos[$integer] = $row->getItemInfo(); |
| 66 | 66 | |
| 67 | - $this->store->storeItemRow( $row ); |
|
| 67 | + $this->store->storeItemRow($row); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - sort( $this->itemInfos ); |
|
| 70 | + sort($this->itemInfos); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | private function insertPropertyRows() { |
| 74 | - foreach ( [ 101, 110, 102, 109, 108, 107, 103, 104, 106, 105 ] as $integer ) { |
|
| 74 | + foreach ([101, 110, 102, 109, 108, 107, 103, 104, 106, 105] as $integer) { |
|
| 75 | 75 | $info = new PropertyInfo( |
| 76 | 76 | $integer, |
| 77 | - 'Property:P' . $integer, |
|
| 78 | - '424242' . $integer, |
|
| 79 | - $integer . '4-02-27T11:40:12Z', |
|
| 77 | + 'Property:P'.$integer, |
|
| 78 | + '424242'.$integer, |
|
| 79 | + $integer.'4-02-27T11:40:12Z', |
|
| 80 | 80 | 'string' |
| 81 | 81 | ); |
| 82 | 82 | |
@@ -84,103 +84,103 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $this->store->storePropertyRow( |
| 86 | 86 | new PropertyRow( |
| 87 | - 'json be here ' . $integer, |
|
| 87 | + 'json be here '.$integer, |
|
| 88 | 88 | $info |
| 89 | 89 | ) |
| 90 | 90 | ); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - sort( $this->propertyInfos ); |
|
| 93 | + sort($this->propertyInfos); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function testGivenLimitBiggerThanSet_getPropertyInfoReturnsAllRows() { |
| 97 | - $propertyInfoSets = $this->store->getPropertyInfo( 100, 0 ); |
|
| 97 | + $propertyInfoSets = $this->store->getPropertyInfo(100, 0); |
|
| 98 | 98 | |
| 99 | - $this->assertIsPropertyInfoArray( $propertyInfoSets ); |
|
| 99 | + $this->assertIsPropertyInfoArray($propertyInfoSets); |
|
| 100 | 100 | $this->assertEquals( |
| 101 | - array_values( $this->propertyInfos ), |
|
| 101 | + array_values($this->propertyInfos), |
|
| 102 | 102 | $propertyInfoSets |
| 103 | 103 | ); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function testGivenLimitSmallerThanSet_getPropertyInfoReturnsLimitedRows() { |
| 107 | - $propertyInfoSets = $this->store->getPropertyInfo( 5, 0 ); |
|
| 107 | + $propertyInfoSets = $this->store->getPropertyInfo(5, 0); |
|
| 108 | 108 | |
| 109 | - $this->assertIsPropertyInfoArray( $propertyInfoSets ); |
|
| 109 | + $this->assertIsPropertyInfoArray($propertyInfoSets); |
|
| 110 | 110 | $this->assertEquals( |
| 111 | - array_values( array_slice( $this->propertyInfos, 0, 5 ) ), |
|
| 111 | + array_values(array_slice($this->propertyInfos, 0, 5)), |
|
| 112 | 112 | $propertyInfoSets |
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public function testGivenOffsetSmallerThanSet_getPropertyInfoReturnsPagedRows() { |
| 117 | - $propertyInfoSets = $this->store->getPropertyInfo( 5, 7 ); |
|
| 117 | + $propertyInfoSets = $this->store->getPropertyInfo(5, 7); |
|
| 118 | 118 | |
| 119 | - $this->assertIsPropertyInfoArray( $propertyInfoSets ); |
|
| 119 | + $this->assertIsPropertyInfoArray($propertyInfoSets); |
|
| 120 | 120 | $this->assertEquals( |
| 121 | - array_values( array_slice( $this->propertyInfos, 7, 5 ) ), |
|
| 121 | + array_values(array_slice($this->propertyInfos, 7, 5)), |
|
| 122 | 122 | $propertyInfoSets |
| 123 | 123 | ); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | public function testGivenOffsetBiggerThanSet_getPropertyInfoReturnsEmptyArray() { |
| 127 | - $propertyInfoSets = $this->store->getPropertyInfo( 5, 20 ); |
|
| 127 | + $propertyInfoSets = $this->store->getPropertyInfo(5, 20); |
|
| 128 | 128 | |
| 129 | - $this->assertIsPropertyInfoArray( $propertyInfoSets ); |
|
| 129 | + $this->assertIsPropertyInfoArray($propertyInfoSets); |
|
| 130 | 130 | $this->assertEquals( |
| 131 | 131 | [], |
| 132 | 132 | $propertyInfoSets |
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - private function assertIsPropertyInfoArray( $info ) { |
|
| 137 | - $this->assertInternalType( 'array', $info ); |
|
| 138 | - $this->assertContainsOnlyInstancesOf( 'Queryr\EntityStore\Data\PropertyInfo', $info ); |
|
| 136 | + private function assertIsPropertyInfoArray($info) { |
|
| 137 | + $this->assertInternalType('array', $info); |
|
| 138 | + $this->assertContainsOnlyInstancesOf('Queryr\EntityStore\Data\PropertyInfo', $info); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public function testGivenLimitBiggerThanSet_getItemInfoReturnsAllRows() { |
| 142 | - $itemInfoSets = $this->store->getItemInfo( 100, 0 ); |
|
| 142 | + $itemInfoSets = $this->store->getItemInfo(100, 0); |
|
| 143 | 143 | |
| 144 | - $this->assertIsItemInfoArray( $itemInfoSets ); |
|
| 144 | + $this->assertIsItemInfoArray($itemInfoSets); |
|
| 145 | 145 | $this->assertEquals( |
| 146 | - array_values( $this->itemInfos ), |
|
| 146 | + array_values($this->itemInfos), |
|
| 147 | 147 | $itemInfoSets |
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public function testGivenLimitSmallerThanSet_getItemInfoReturnsLimitedRows() { |
| 152 | - $itemInfoSets = $this->store->getItemInfo( 5, 0 ); |
|
| 152 | + $itemInfoSets = $this->store->getItemInfo(5, 0); |
|
| 153 | 153 | |
| 154 | - $this->assertIsItemInfoArray( $itemInfoSets ); |
|
| 154 | + $this->assertIsItemInfoArray($itemInfoSets); |
|
| 155 | 155 | $this->assertEquals( |
| 156 | - array_values( array_slice( $this->itemInfos, 0, 5 ) ), |
|
| 156 | + array_values(array_slice($this->itemInfos, 0, 5)), |
|
| 157 | 157 | $itemInfoSets |
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function testGivenOffsetSmallerThanSet_getItemInfoReturnsPagedRows() { |
| 162 | - $itemInfoSets = $this->store->getItemInfo( 5, 7 ); |
|
| 162 | + $itemInfoSets = $this->store->getItemInfo(5, 7); |
|
| 163 | 163 | |
| 164 | - $this->assertIsItemInfoArray( $itemInfoSets ); |
|
| 164 | + $this->assertIsItemInfoArray($itemInfoSets); |
|
| 165 | 165 | $this->assertEquals( |
| 166 | - array_values( array_slice( $this->itemInfos, 7, 5 ) ), |
|
| 166 | + array_values(array_slice($this->itemInfos, 7, 5)), |
|
| 167 | 167 | $itemInfoSets |
| 168 | 168 | ); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | public function testGivenOffsetBiggerThanSet_getItemInfoReturnsEmptyArray() { |
| 172 | - $itemInfoSets = $this->store->getItemInfo( 5, 20 ); |
|
| 172 | + $itemInfoSets = $this->store->getItemInfo(5, 20); |
|
| 173 | 173 | |
| 174 | - $this->assertIsItemInfoArray( $itemInfoSets ); |
|
| 174 | + $this->assertIsItemInfoArray($itemInfoSets); |
|
| 175 | 175 | $this->assertEquals( |
| 176 | 176 | [], |
| 177 | 177 | $itemInfoSets |
| 178 | 178 | ); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - private function assertIsItemInfoArray( $info ) { |
|
| 182 | - $this->assertInternalType( 'array', $info ); |
|
| 183 | - $this->assertContainsOnlyInstancesOf( 'Queryr\EntityStore\Data\ItemInfo', $info ); |
|
| 181 | + private function assertIsItemInfoArray($info) { |
|
| 182 | + $this->assertInternalType('array', $info); |
|
| 183 | + $this->assertContainsOnlyInstancesOf('Queryr\EntityStore\Data\ItemInfo', $info); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | $this->createPropertyRowField(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - private function createStore( $doDbInstall = false ) { |
|
| 41 | + private function createStore($doDbInstall = false) { |
|
| 42 | 42 | $connection = TestFixtureFactory::newInstance()->newConnection(); |
| 43 | 43 | $config = new EntityStoreConfig(); |
| 44 | 44 | |
| 45 | - if ( $doDbInstall ) { |
|
| 46 | - $installer = new EntityStoreInstaller( $connection->getSchemaManager(), $config ); |
|
| 45 | + if ($doDbInstall) { |
|
| 46 | + $installer = new EntityStoreInstaller($connection->getSchemaManager(), $config); |
|
| 47 | 47 | $installer->install(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $this->store = ( new EntityStoreFactory( $connection, $config ) )->newPropertyStore(); |
|
| 50 | + $this->store = (new EntityStoreFactory($connection, $config))->newPropertyStore(); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | private function createPropertyRowField() { |
@@ -64,49 +64,49 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function testCanStoreAndRetrievePropertyPage() { |
| 67 | - $this->createStore( self::AND_INSTALL ); |
|
| 67 | + $this->createStore(self::AND_INSTALL); |
|
| 68 | 68 | |
| 69 | - $this->store->storePropertyRow( $this->propertyRow ); |
|
| 69 | + $this->store->storePropertyRow($this->propertyRow); |
|
| 70 | 70 | |
| 71 | - $newPropertyRow = $this->store->getPropertyRowByNumericPropertyId( self::PROPERTY_ID ); |
|
| 71 | + $newPropertyRow = $this->store->getPropertyRowByNumericPropertyId(self::PROPERTY_ID); |
|
| 72 | 72 | |
| 73 | - $this->assertInstanceOf( 'Queryr\EntityStore\Data\PropertyRow', $newPropertyRow ); |
|
| 73 | + $this->assertInstanceOf('Queryr\EntityStore\Data\PropertyRow', $newPropertyRow); |
|
| 74 | 74 | |
| 75 | - $this->assertSame( $this->propertyRow->getNumericPropertyId(), $newPropertyRow->getNumericPropertyId() ); |
|
| 76 | - $this->assertSame( $this->propertyRow->getPropertyJson(), $newPropertyRow->getPropertyJson() ); |
|
| 77 | - $this->assertSame( $this->propertyRow->getPageTitle(), $newPropertyRow->getPageTitle() ); |
|
| 78 | - $this->assertSame( $this->propertyRow->getRevisionId(), $newPropertyRow->getRevisionId() ); |
|
| 79 | - $this->assertSame( $this->propertyRow->getRevisionTime(), $newPropertyRow->getRevisionTime() ); |
|
| 80 | - $this->assertSame( $this->propertyRow->getPropertyType(), $newPropertyRow->getPropertyType() ); |
|
| 75 | + $this->assertSame($this->propertyRow->getNumericPropertyId(), $newPropertyRow->getNumericPropertyId()); |
|
| 76 | + $this->assertSame($this->propertyRow->getPropertyJson(), $newPropertyRow->getPropertyJson()); |
|
| 77 | + $this->assertSame($this->propertyRow->getPageTitle(), $newPropertyRow->getPageTitle()); |
|
| 78 | + $this->assertSame($this->propertyRow->getRevisionId(), $newPropertyRow->getRevisionId()); |
|
| 79 | + $this->assertSame($this->propertyRow->getRevisionTime(), $newPropertyRow->getRevisionTime()); |
|
| 80 | + $this->assertSame($this->propertyRow->getPropertyType(), $newPropertyRow->getPropertyType()); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function testGivenNotKnownId_getPropertyRowByNumericPropertyIdReturnsNull() { |
| 84 | - $this->createStore( self::AND_INSTALL ); |
|
| 85 | - $this->assertNull( $this->store->getPropertyRowByNumericPropertyId( '32202' ) ); |
|
| 84 | + $this->createStore(self::AND_INSTALL); |
|
| 85 | + $this->assertNull($this->store->getPropertyRowByNumericPropertyId('32202')); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function testWhenStoreNotInitialized_storePropertyRowThrowsException() { |
| 89 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 90 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 91 | - $this->store->storePropertyRow( $this->propertyRow ); |
|
| 89 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 90 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 91 | + $this->store->storePropertyRow($this->propertyRow); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public function testWhenStoreNotInitialized_getPropertyRowByNumericPropertyIdThrowsException() { |
| 95 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 96 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 97 | - $this->store->getPropertyRowByNumericPropertyId( 1 ); |
|
| 95 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 96 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 97 | + $this->store->getPropertyRowByNumericPropertyId(1); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function testWhenStoreNotInitialized_getPropertyInfoThrowsException() { |
| 101 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 102 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 103 | - $this->store->getPropertyInfo( 10, 0 ); |
|
| 101 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 102 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 103 | + $this->store->getPropertyInfo(10, 0); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function testInsertingExistingPropertyOverridesTheOriginalOne() { |
| 107 | - $this->createStore( self::AND_INSTALL ); |
|
| 107 | + $this->createStore(self::AND_INSTALL); |
|
| 108 | 108 | |
| 109 | - $this->store->storePropertyRow( new PropertyRow( |
|
| 109 | + $this->store->storePropertyRow(new PropertyRow( |
|
| 110 | 110 | 'json be here', |
| 111 | 111 | new PropertyInfo( |
| 112 | 112 | 42, |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | '2014-02-27T11:40:12Z', |
| 116 | 116 | 'string' |
| 117 | 117 | ) |
| 118 | - ) ); |
|
| 118 | + )); |
|
| 119 | 119 | |
| 120 | - $this->store->storePropertyRow( new PropertyRow( |
|
| 120 | + $this->store->storePropertyRow(new PropertyRow( |
|
| 121 | 121 | 'json be here', |
| 122 | 122 | new PropertyInfo( |
| 123 | 123 | 42, |
@@ -126,23 +126,23 @@ discard block |
||
| 126 | 126 | '2014-02-27T11:40:12Z', |
| 127 | 127 | 'kittens' |
| 128 | 128 | ) |
| 129 | - ) ); |
|
| 129 | + )); |
|
| 130 | 130 | |
| 131 | - $infoSets = $this->store->getPropertyInfo( 10, 0 ); |
|
| 132 | - $this->assertCount( 1, $infoSets ); |
|
| 133 | - $this->assertSame( 'kittens', $infoSets[0]->getPropertyType() ); |
|
| 131 | + $infoSets = $this->store->getPropertyInfo(10, 0); |
|
| 132 | + $this->assertCount(1, $infoSets); |
|
| 133 | + $this->assertSame('kittens', $infoSets[0]->getPropertyType()); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function testWhenStoreNotInitialized_deleteItemByIdThrowsException() { |
| 137 | - $this->createStore( self::WITHOUT_INSTALLING ); |
|
| 138 | - $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
|
| 139 | - $this->store->deletePropertyById( new PropertyId( 'P1' ) ); |
|
| 137 | + $this->createStore(self::WITHOUT_INSTALLING); |
|
| 138 | + $this->setExpectedException('Queryr\EntityStore\EntityStoreException'); |
|
| 139 | + $this->store->deletePropertyById(new PropertyId('P1')); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function testGivenNonExistingId_deleteItemByIdDoesNotDeleteItems() { |
| 143 | - $this->createStore( self::AND_INSTALL ); |
|
| 143 | + $this->createStore(self::AND_INSTALL); |
|
| 144 | 144 | |
| 145 | - $this->store->storePropertyRow( new PropertyRow( |
|
| 145 | + $this->store->storePropertyRow(new PropertyRow( |
|
| 146 | 146 | 'json be here', |
| 147 | 147 | new PropertyInfo( |
| 148 | 148 | 42, |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | '2014-02-27T11:40:12Z', |
| 152 | 152 | 'string' |
| 153 | 153 | ) |
| 154 | - ) ); |
|
| 154 | + )); |
|
| 155 | 155 | |
| 156 | - $this->store->deletePropertyById( new PropertyId( 'P43' ) ); |
|
| 156 | + $this->store->deletePropertyById(new PropertyId('P43')); |
|
| 157 | 157 | |
| 158 | - $this->assertCount( 1, $this->store->getPropertyInfo( 10, 0 ) ); |
|
| 158 | + $this->assertCount(1, $this->store->getPropertyInfo(10, 0)); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function testGivenExistingId_deleteItemByIdDeletesItem() { |
| 162 | - $this->createStore( self::AND_INSTALL ); |
|
| 162 | + $this->createStore(self::AND_INSTALL); |
|
| 163 | 163 | |
| 164 | - $this->store->storePropertyRow( new PropertyRow( |
|
| 164 | + $this->store->storePropertyRow(new PropertyRow( |
|
| 165 | 165 | 'json be here', |
| 166 | 166 | new PropertyInfo( |
| 167 | 167 | 42, |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | '2014-02-27T11:40:12Z', |
| 171 | 171 | 'string' |
| 172 | 172 | ) |
| 173 | - ) ); |
|
| 173 | + )); |
|
| 174 | 174 | |
| 175 | - $this->store->deletePropertyById( new PropertyId( 'P42' ) ); |
|
| 175 | + $this->store->deletePropertyById(new PropertyId('P42')); |
|
| 176 | 176 | |
| 177 | - $this->assertCount( 0, $this->store->getPropertyInfo( 10, 0 ) ); |
|
| 177 | + $this->assertCount(0, $this->store->getPropertyInfo(10, 0)); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | } |
@@ -20,33 +20,33 @@ |
||
| 20 | 20 | const INSTANCEOF_PROP_ID = 31; |
| 21 | 21 | |
| 22 | 22 | public function testGivenEmptyItem_nullIsReturned() { |
| 23 | - $this->assertNull( ( new InstanceOfTypeExtractor() )->getTypeOfItem( new Item() ) ); |
|
| 23 | + $this->assertNull((new InstanceOfTypeExtractor())->getTypeOfItem(new Item())); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function testGivenBerlin_then515isReturned() { |
| 27 | 27 | $this->assertSame( |
| 28 | 28 | 515, |
| 29 | - ( new InstanceOfTypeExtractor() )->getTypeOfItem( ( new Berlin() )->newItem() ) |
|
| 29 | + (new InstanceOfTypeExtractor())->getTypeOfItem((new Berlin())->newItem()) |
|
| 30 | 30 | ); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function testGivenItemWithNoValueType_nullIsReturned() { |
| 34 | 34 | $item = new Item(); |
| 35 | 35 | |
| 36 | - $item->getStatements()->addNewStatement( new PropertyNoValueSnak( self::INSTANCEOF_PROP_ID ) ); |
|
| 36 | + $item->getStatements()->addNewStatement(new PropertyNoValueSnak(self::INSTANCEOF_PROP_ID)); |
|
| 37 | 37 | |
| 38 | - $this->assertNull( ( new InstanceOfTypeExtractor() )->getTypeOfItem( $item ) ); |
|
| 38 | + $this->assertNull((new InstanceOfTypeExtractor())->getTypeOfItem($item)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function testGivenItemWithNonIdType_nullIsReturned() { |
| 42 | 42 | $item = new Item(); |
| 43 | 43 | |
| 44 | - $item->getStatements()->addNewStatement( new PropertyValueSnak( |
|
| 44 | + $item->getStatements()->addNewStatement(new PropertyValueSnak( |
|
| 45 | 45 | self::INSTANCEOF_PROP_ID, |
| 46 | - new StringValue( 'not an id' ) |
|
| 47 | - ) ); |
|
| 46 | + new StringValue('not an id') |
|
| 47 | + )); |
|
| 48 | 48 | |
| 49 | - $this->assertNull( ( new InstanceOfTypeExtractor() )->getTypeOfItem( $item ) ); |
|
| 49 | + $this->assertNull((new InstanceOfTypeExtractor())->getTypeOfItem($item)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -16,77 +16,77 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function testNewRowForBerlin() { |
| 18 | 18 | $itemRow = $this->newFactory()->newFromItemAndPageInfo( |
| 19 | - ( new Berlin() )->newItem(), |
|
| 19 | + (new Berlin())->newItem(), |
|
| 20 | 20 | $this->newPageInfo() |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - $this->assertSame( 'kittens', $itemRow->getPageTitle() ); |
|
| 24 | - $this->assertSame( '0000', $itemRow->getRevisionTime() ); |
|
| 25 | - $this->assertSame( 9001, $itemRow->getRevisionId() ); |
|
| 23 | + $this->assertSame('kittens', $itemRow->getPageTitle()); |
|
| 24 | + $this->assertSame('0000', $itemRow->getRevisionTime()); |
|
| 25 | + $this->assertSame(9001, $itemRow->getRevisionId()); |
|
| 26 | 26 | |
| 27 | - $this->assertSame( 64, $itemRow->getNumericItemId() ); |
|
| 28 | - $this->assertSame( 'Berlin', $itemRow->getEnglishLabel() ); |
|
| 29 | - $this->assertSame( 'Berlin', $itemRow->getEnglishWikipediaTitle() ); |
|
| 30 | - $this->assertSame( '["the","serialization"]', $itemRow->getItemJson() ); |
|
| 31 | - $this->assertSame( 42, $itemRow->getItemType() ); |
|
| 27 | + $this->assertSame(64, $itemRow->getNumericItemId()); |
|
| 28 | + $this->assertSame('Berlin', $itemRow->getEnglishLabel()); |
|
| 29 | + $this->assertSame('Berlin', $itemRow->getEnglishWikipediaTitle()); |
|
| 30 | + $this->assertSame('["the","serialization"]', $itemRow->getItemJson()); |
|
| 31 | + $this->assertSame(42, $itemRow->getItemType()); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function testNewRowForItemWithoutEnglishLabel() { |
| 35 | - $item = ( new Berlin() )->newItem(); |
|
| 36 | - $item->getFingerprint()->removeLabel( 'en' ); |
|
| 35 | + $item = (new Berlin())->newItem(); |
|
| 36 | + $item->getFingerprint()->removeLabel('en'); |
|
| 37 | 37 | |
| 38 | 38 | $itemRow = $this->newFactory()->newFromItemAndPageInfo( |
| 39 | 39 | $item, |
| 40 | 40 | $this->newPageInfo() |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | - $this->assertNull( $itemRow->getEnglishLabel() ); |
|
| 43 | + $this->assertNull($itemRow->getEnglishLabel()); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function testNewRowForItemWithoutType() { |
| 47 | 47 | $factory = new ItemRowFactory( |
| 48 | 48 | $this->newStubItemSerializer(), |
| 49 | - $this->newStubTypeExtractor( null ) |
|
| 49 | + $this->newStubTypeExtractor(null) |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | $itemRow = $factory->newFromItemAndPageInfo( |
| 53 | - ( new Berlin() )->newItem(), |
|
| 53 | + (new Berlin())->newItem(), |
|
| 54 | 54 | $this->newPageInfo() |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - $this->assertNull( $itemRow->getItemType() ); |
|
| 57 | + $this->assertNull($itemRow->getItemType()); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | private function newFactory() { |
| 61 | 61 | return new ItemRowFactory( |
| 62 | 62 | $this->newStubItemSerializer(), |
| 63 | - $this->newStubTypeExtractor( 42 ) |
|
| 63 | + $this->newStubTypeExtractor(42) |
|
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | private function newPageInfo() { |
| 68 | - return ( new EntityPageInfo() ) |
|
| 69 | - ->setPageTitle( 'kittens' ) |
|
| 70 | - ->setRevisionTime( '0000' ) |
|
| 71 | - ->setRevisionId( '9001' ); |
|
| 68 | + return (new EntityPageInfo()) |
|
| 69 | + ->setPageTitle('kittens') |
|
| 70 | + ->setRevisionTime('0000') |
|
| 71 | + ->setRevisionId('9001'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | private function newStubItemSerializer() { |
| 75 | - $serializer = $this->getMock( 'Serializers\Serializer' ); |
|
| 75 | + $serializer = $this->getMock('Serializers\Serializer'); |
|
| 76 | 76 | |
| 77 | - $serializer->expects( $this->any() ) |
|
| 78 | - ->method( 'serialize' ) |
|
| 79 | - ->will( $this->returnValue( [ 'the', 'serialization' ] ) ); |
|
| 77 | + $serializer->expects($this->any()) |
|
| 78 | + ->method('serialize') |
|
| 79 | + ->will($this->returnValue(['the', 'serialization'])); |
|
| 80 | 80 | |
| 81 | 81 | return $serializer; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - private function newStubTypeExtractor( $returnValue ) { |
|
| 85 | - $extractor = $this->getMock( 'Queryr\EntityStore\ItemTypeExtractor' ); |
|
| 84 | + private function newStubTypeExtractor($returnValue) { |
|
| 85 | + $extractor = $this->getMock('Queryr\EntityStore\ItemTypeExtractor'); |
|
| 86 | 86 | |
| 87 | - $extractor->expects( $this->any() ) |
|
| 88 | - ->method( 'getTypeOfItem' ) |
|
| 89 | - ->will( $this->returnValue( $returnValue ) ); |
|
| 87 | + $extractor->expects($this->any()) |
|
| 88 | + ->method('getTypeOfItem') |
|
| 89 | + ->will($this->returnValue($returnValue)); |
|
| 90 | 90 | |
| 91 | 91 | return $extractor; |
| 92 | 92 | } |
@@ -11,10 +11,10 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public function newConnection() { |
| 14 | - return DriverManager::getConnection( array( |
|
| 14 | + return DriverManager::getConnection(array( |
|
| 15 | 15 | 'driver' => 'pdo_sqlite', |
| 16 | 16 | 'memory' => true, |
| 17 | - ) ); |
|
| 17 | + )); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | } |
| 21 | 21 | \ No newline at end of file |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( PHP_SAPI !== 'cli' ) { |
|
| 4 | - die( 'Not an entry point' ); |
|
| 3 | +if (PHP_SAPI !== 'cli') { |
|
| 4 | + die('Not an entry point'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -error_reporting( E_ALL | E_STRICT ); |
|
| 8 | -ini_set( 'display_errors', 1 ); |
|
| 7 | +error_reporting(E_ALL | E_STRICT); |
|
| 8 | +ini_set('display_errors', 1); |
|
| 9 | 9 | |
| 10 | -if ( !is_readable( __DIR__ . '/../vendor/autoload.php' ) ) { |
|
| 11 | - die( 'You need to install this package with Composer before you can run the tests' ); |
|
| 10 | +if (!is_readable(__DIR__.'/../vendor/autoload.php')) { |
|
| 11 | + die('You need to install this package with Composer before you can run the tests'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -$autoLoader = require __DIR__ . '/../vendor/autoload.php'; |
|
| 14 | +$autoLoader = require __DIR__.'/../vendor/autoload.php'; |
|
| 15 | 15 | |
| 16 | -$autoLoader->addPsr4( 'Tests\\Queryr\\EntityStore\\Fixtures\\', 'tests/fixtures/' ); |
|
| 16 | +$autoLoader->addPsr4('Tests\\Queryr\\EntityStore\\Fixtures\\', 'tests/fixtures/'); |
|
| 17 | 17 | |
| 18 | -unset( $autoLoader ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +unset($autoLoader); |
|
| 20 | 20 | \ No newline at end of file |