@@ -26,15 +26,15 @@ |
||
| 26 | 26 | public function testWhenNoConnection_storeEntityFingerprintThrowsException() { |
| 27 | 27 | $writer = TestEnvironment::newInstanceWithoutTables()->getFactory()->newTermStoreWriter(); |
| 28 | 28 | |
| 29 | - $this->setExpectedException( 'Queryr\TermStore\TermStoreException' ); |
|
| 30 | - $writer->storeEntityFingerprint( new ItemId( 'Q1' ), new Fingerprint() ); |
|
| 29 | + $this->setExpectedException('Queryr\TermStore\TermStoreException'); |
|
| 30 | + $writer->storeEntityFingerprint(new ItemId('Q1'), new Fingerprint()); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function testWhenNoConnection_dropTermsForIdThrowsException() { |
| 34 | 34 | $writer = TestEnvironment::newInstanceWithoutTables()->getFactory()->newTermStoreWriter(); |
| 35 | 35 | |
| 36 | - $this->setExpectedException( 'Queryr\TermStore\TermStoreException' ); |
|
| 37 | - $writer->dropTermsForId( new ItemId( 'Q1' ) ); |
|
| 36 | + $this->setExpectedException('Queryr\TermStore\TermStoreException'); |
|
| 37 | + $writer->dropTermsForId(new ItemId('Q1')); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | } |
@@ -22,22 +22,22 @@ |
||
| 22 | 22 | private $store; |
| 23 | 23 | |
| 24 | 24 | public function setUp() { |
| 25 | - $connection = DriverManager::getConnection( array( |
|
| 25 | + $connection = DriverManager::getConnection(array( |
|
| 26 | 26 | 'driver' => 'pdo_sqlite', |
| 27 | 27 | 'memory' => true, |
| 28 | - ) ); |
|
| 28 | + )); |
|
| 29 | 29 | |
| 30 | - $this->store = new TermStore( $connection, new TermStoreConfig( '' ) ); |
|
| 30 | + $this->store = new TermStore($connection, new TermStoreConfig('')); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function testInsertWhenStoreNotInstalledCausesTermStoreException() { |
| 34 | - $id = new ItemId( 'Q1337' ); |
|
| 34 | + $id = new ItemId('Q1337'); |
|
| 35 | 35 | |
| 36 | 36 | $fingerprint = new Fingerprint(); |
| 37 | - $fingerprint->setLabel( 'en', 'EN label' ); |
|
| 37 | + $fingerprint->setLabel('en', 'EN label'); |
|
| 38 | 38 | |
| 39 | - $this->setExpectedException( 'Queryr\TermStore\TermStoreException' ); |
|
| 40 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 39 | + $this->setExpectedException('Queryr\TermStore\TermStoreException'); |
|
| 40 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | } |
@@ -30,13 +30,13 @@ |
||
| 30 | 30 | private $factory; |
| 31 | 31 | |
| 32 | 32 | private function __construct() { |
| 33 | - $connection = DriverManager::getConnection( array( |
|
| 33 | + $connection = DriverManager::getConnection(array( |
|
| 34 | 34 | 'driver' => 'pdo_sqlite', |
| 35 | 35 | 'memory' => true, |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - $config = new TermStoreConfig( 'ts_' ); |
|
| 39 | - $this->factory = new TermStoreFactory( $connection, $config ); |
|
| 38 | + $config = new TermStoreConfig('ts_'); |
|
| 39 | + $this->factory = new TermStoreFactory($connection, $config); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function getFactory() { |
@@ -29,236 +29,236 @@ |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function testGivenNotMatchingArgs_getTermByIdAndLanguageReturnsNull() { |
| 32 | - $this->assertNull( $this->store->getLabelByIdAndLanguage( new ItemId( 'Q1337' ), 'en' ) ); |
|
| 32 | + $this->assertNull($this->store->getLabelByIdAndLanguage(new ItemId('Q1337'), 'en')); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function testStoreIdAndFingerprint() { |
| 36 | - $id = new ItemId( 'Q1337' ); |
|
| 36 | + $id = new ItemId('Q1337'); |
|
| 37 | 37 | |
| 38 | 38 | $fingerprint = new Fingerprint(); |
| 39 | - $fingerprint->setLabel( 'en', 'en label' ); |
|
| 40 | - $fingerprint->setLabel( 'de', 'de label' ); |
|
| 41 | - $fingerprint->setDescription( 'en', 'en description' ); |
|
| 42 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 39 | + $fingerprint->setLabel('en', 'en label'); |
|
| 40 | + $fingerprint->setLabel('de', 'de label'); |
|
| 41 | + $fingerprint->setDescription('en', 'en description'); |
|
| 42 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 43 | 43 | |
| 44 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 44 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 45 | 45 | |
| 46 | 46 | $this->assertSame( |
| 47 | 47 | 'en label', |
| 48 | - $this->store->getLabelByIdAndLanguage( $id, 'en' ) |
|
| 48 | + $this->store->getLabelByIdAndLanguage($id, 'en') |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | $this->assertSame( |
| 52 | 52 | 'de label', |
| 53 | - $this->store->getLabelByIdAndLanguage( $id, 'de' ) |
|
| 53 | + $this->store->getLabelByIdAndLanguage($id, 'de') |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | $this->assertSame( |
| 57 | 57 | [ 'first en alias', 'second en alias' ], |
| 58 | - $this->store->getAliasesByIdAndLanguage( $id, 'en' ) |
|
| 58 | + $this->store->getAliasesByIdAndLanguage($id, 'en') |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function testGetIdByLabelAndLanguage() { |
| 63 | - $id = new ItemId( 'Q1337' ); |
|
| 63 | + $id = new ItemId('Q1337'); |
|
| 64 | 64 | |
| 65 | 65 | $fingerprint = new Fingerprint(); |
| 66 | - $fingerprint->setLabel( 'en', 'en label' ); |
|
| 67 | - $fingerprint->setLabel( 'de', 'de label' ); |
|
| 66 | + $fingerprint->setLabel('en', 'en label'); |
|
| 67 | + $fingerprint->setLabel('de', 'de label'); |
|
| 68 | 68 | |
| 69 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 69 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 70 | 70 | |
| 71 | 71 | $this->assertSame( |
| 72 | 72 | 'Q1337', |
| 73 | - $this->store->getIdByLabel( 'en', 'en label' ) |
|
| 73 | + $this->store->getIdByLabel('en', 'en label') |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function testStoreFingerprintRemovesOldData() { |
| 78 | - $id = new ItemId( 'Q1337' ); |
|
| 78 | + $id = new ItemId('Q1337'); |
|
| 79 | 79 | |
| 80 | 80 | $fingerprint = new Fingerprint(); |
| 81 | - $fingerprint->setLabel( 'en', 'en label' ); |
|
| 82 | - $fingerprint->setLabel( 'de', 'de label' ); |
|
| 83 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 81 | + $fingerprint->setLabel('en', 'en label'); |
|
| 82 | + $fingerprint->setLabel('de', 'de label'); |
|
| 83 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 84 | 84 | |
| 85 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 85 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 86 | 86 | |
| 87 | 87 | $fingerprint = new Fingerprint(); |
| 88 | - $fingerprint->setLabel( 'de', 'new de label' ); |
|
| 88 | + $fingerprint->setLabel('de', 'new de label'); |
|
| 89 | 89 | |
| 90 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 90 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 91 | 91 | |
| 92 | 92 | $this->assertEquals( |
| 93 | 93 | 'new de label', |
| 94 | - $this->store->getLabelByIdAndLanguage( $id, 'de' ) |
|
| 94 | + $this->store->getLabelByIdAndLanguage($id, 'de') |
|
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - $this->assertNull( $this->store->getLabelByIdAndLanguage( $id, 'en' ) ); |
|
| 98 | - $this->assertEmpty( $this->store->getAliasesByIdAndLanguage( $id, 'en' ) ); |
|
| 97 | + $this->assertNull($this->store->getLabelByIdAndLanguage($id, 'en')); |
|
| 98 | + $this->assertEmpty($this->store->getAliasesByIdAndLanguage($id, 'en')); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function testGivenNonMatchingArgs_getAliasesReturnsEmptyArray() { |
| 102 | - $this->assertSame( [], $this->store->getAliasesByIdAndLanguage( new ItemId( 'Q1337' ), 'en' ) ); |
|
| 102 | + $this->assertSame([ ], $this->store->getAliasesByIdAndLanguage(new ItemId('Q1337'), 'en')); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function testGetIdByTextReturnsMatchBasedOnLabel() { |
| 106 | - $id = new ItemId( 'Q1337' ); |
|
| 106 | + $id = new ItemId('Q1337'); |
|
| 107 | 107 | |
| 108 | 108 | $fingerprint = new Fingerprint(); |
| 109 | - $fingerprint->setLabel( 'en', 'kittens' ); |
|
| 110 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 109 | + $fingerprint->setLabel('en', 'kittens'); |
|
| 110 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 111 | 111 | |
| 112 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 112 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 113 | 113 | |
| 114 | - $id = new ItemId( 'Q42' ); |
|
| 114 | + $id = new ItemId('Q42'); |
|
| 115 | 115 | |
| 116 | 116 | $fingerprint = new Fingerprint(); |
| 117 | - $fingerprint->setLabel( 'en', 'foobar' ); |
|
| 118 | - $fingerprint->setAliasGroup( 'en', [ 'kittens', 'first en alias' ] ); |
|
| 117 | + $fingerprint->setLabel('en', 'foobar'); |
|
| 118 | + $fingerprint->setAliasGroup('en', [ 'kittens', 'first en alias' ]); |
|
| 119 | 119 | |
| 120 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 120 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 121 | 121 | |
| 122 | 122 | $this->assertSame( |
| 123 | 123 | 'Q1337', |
| 124 | - $this->store->getIdByText( 'en', 'kittens' ) |
|
| 124 | + $this->store->getIdByText('en', 'kittens') |
|
| 125 | 125 | ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function testGetIdByTextReturnsAliasBasedMatchIfNoLabelsMatch() { |
| 129 | - $id = new ItemId( 'Q1337' ); |
|
| 129 | + $id = new ItemId('Q1337'); |
|
| 130 | 130 | |
| 131 | 131 | $fingerprint = new Fingerprint(); |
| 132 | - $fingerprint->setLabel( 'en', 'foobar' ); |
|
| 133 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 132 | + $fingerprint->setLabel('en', 'foobar'); |
|
| 133 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 134 | 134 | |
| 135 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 135 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 136 | 136 | |
| 137 | - $id = new ItemId( 'Q42' ); |
|
| 137 | + $id = new ItemId('Q42'); |
|
| 138 | 138 | |
| 139 | 139 | $fingerprint = new Fingerprint(); |
| 140 | - $fingerprint->setLabel( 'en', 'foobar' ); |
|
| 141 | - $fingerprint->setAliasGroup( 'en', [ 'kittens', 'first en alias' ] ); |
|
| 140 | + $fingerprint->setLabel('en', 'foobar'); |
|
| 141 | + $fingerprint->setAliasGroup('en', [ 'kittens', 'first en alias' ]); |
|
| 142 | 142 | |
| 143 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 143 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 144 | 144 | |
| 145 | 145 | $this->assertSame( |
| 146 | 146 | 'Q42', |
| 147 | - $this->store->getIdByText( 'en', 'kittens' ) |
|
| 147 | + $this->store->getIdByText('en', 'kittens') |
|
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public function testByLabelLookupIsCaseInsensitive() { |
| 152 | - $id = new ItemId( 'Q1337' ); |
|
| 152 | + $id = new ItemId('Q1337'); |
|
| 153 | 153 | |
| 154 | 154 | $fingerprint = new Fingerprint(); |
| 155 | - $fingerprint->setLabel( 'en', 'EN label' ); |
|
| 155 | + $fingerprint->setLabel('en', 'EN label'); |
|
| 156 | 156 | |
| 157 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 157 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 158 | 158 | |
| 159 | 159 | $this->assertSame( |
| 160 | 160 | 'Q1337', |
| 161 | - $this->store->getIdByLabel( 'en', 'en LABEL' ) |
|
| 161 | + $this->store->getIdByLabel('en', 'en LABEL') |
|
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function testGetItemIdByLabelReturnsNoPropertyIds() { |
| 166 | - $id = new PropertyId( 'P1337' ); |
|
| 166 | + $id = new PropertyId('P1337'); |
|
| 167 | 167 | |
| 168 | 168 | $fingerprint = new Fingerprint(); |
| 169 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 169 | + $fingerprint->setLabel('en', 'some label'); |
|
| 170 | 170 | |
| 171 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 171 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 172 | 172 | |
| 173 | - $this->assertNull( $this->store->getItemIdByLabel( 'en', 'some label' ) ); |
|
| 173 | + $this->assertNull($this->store->getItemIdByLabel('en', 'some label')); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function testGetPropertyIdByLabelReturnsNoItemIds() { |
| 177 | - $id = new ItemId( 'Q1337' ); |
|
| 177 | + $id = new ItemId('Q1337'); |
|
| 178 | 178 | |
| 179 | 179 | $fingerprint = new Fingerprint(); |
| 180 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 180 | + $fingerprint->setLabel('en', 'some label'); |
|
| 181 | 181 | |
| 182 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 182 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 183 | 183 | |
| 184 | - $this->assertNull( $this->store->getPropertyIdByLabel( 'en', 'some label' ) ); |
|
| 184 | + $this->assertNull($this->store->getPropertyIdByLabel('en', 'some label')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | public function testGetItemIdByLabelReturnsItemIds() { |
| 188 | - $id = new ItemId( 'Q1337' ); |
|
| 188 | + $id = new ItemId('Q1337'); |
|
| 189 | 189 | |
| 190 | 190 | $fingerprint = new Fingerprint(); |
| 191 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 191 | + $fingerprint->setLabel('en', 'some label'); |
|
| 192 | 192 | |
| 193 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 193 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 194 | 194 | |
| 195 | 195 | $this->assertSame( |
| 196 | 196 | 'Q1337', |
| 197 | - $this->store->getItemIdByLabel( 'en', 'some label' ) |
|
| 197 | + $this->store->getItemIdByLabel('en', 'some label') |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | public function testGetPropertyIdByLabelReturnsPropertyIds() { |
| 202 | - $id = new PropertyId( 'P1337' ); |
|
| 202 | + $id = new PropertyId('P1337'); |
|
| 203 | 203 | |
| 204 | 204 | $fingerprint = new Fingerprint(); |
| 205 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 205 | + $fingerprint->setLabel('en', 'some label'); |
|
| 206 | 206 | |
| 207 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 207 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 208 | 208 | |
| 209 | 209 | $this->assertSame( |
| 210 | 210 | 'P1337', |
| 211 | - $this->store->getPropertyIdByLabel( 'en', 'some label' ) |
|
| 211 | + $this->store->getPropertyIdByLabel('en', 'some label') |
|
| 212 | 212 | ); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | public function testGetItemIdByTextReturnsNoPropertyIds() { |
| 216 | - $id = new PropertyId( 'P1337' ); |
|
| 216 | + $id = new PropertyId('P1337'); |
|
| 217 | 217 | |
| 218 | 218 | $fingerprint = new Fingerprint(); |
| 219 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 219 | + $fingerprint->setLabel('en', 'some label'); |
|
| 220 | 220 | |
| 221 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 221 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 222 | 222 | |
| 223 | - $this->assertNull( $this->store->getItemIdByText( 'en', 'some label' ) ); |
|
| 223 | + $this->assertNull($this->store->getItemIdByText('en', 'some label')); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | public function testGetPropertyIdByTextReturnsNoItemIds() { |
| 227 | - $id = new ItemId( 'Q1337' ); |
|
| 227 | + $id = new ItemId('Q1337'); |
|
| 228 | 228 | |
| 229 | 229 | $fingerprint = new Fingerprint(); |
| 230 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 230 | + $fingerprint->setLabel('en', 'some label'); |
|
| 231 | 231 | |
| 232 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 232 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 233 | 233 | |
| 234 | - $this->assertNull( $this->store->getPropertyIdByText( 'en', 'some label' ) ); |
|
| 234 | + $this->assertNull($this->store->getPropertyIdByText('en', 'some label')); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | public function testGetItemIdByTextReturnsItemIds() { |
| 238 | - $id = new ItemId( 'Q1337' ); |
|
| 238 | + $id = new ItemId('Q1337'); |
|
| 239 | 239 | |
| 240 | 240 | $fingerprint = new Fingerprint(); |
| 241 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 241 | + $fingerprint->setLabel('en', 'some label'); |
|
| 242 | 242 | |
| 243 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 243 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 244 | 244 | |
| 245 | 245 | $this->assertSame( |
| 246 | 246 | 'Q1337', |
| 247 | - $this->store->getItemIdByText( 'en', 'some label' ) |
|
| 247 | + $this->store->getItemIdByText('en', 'some label') |
|
| 248 | 248 | ); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | public function testGetPropertyIdByTextReturnsPropertyIds() { |
| 252 | - $id = new PropertyId( 'P1337' ); |
|
| 252 | + $id = new PropertyId('P1337'); |
|
| 253 | 253 | |
| 254 | 254 | $fingerprint = new Fingerprint(); |
| 255 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 255 | + $fingerprint->setLabel('en', 'some label'); |
|
| 256 | 256 | |
| 257 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 257 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 258 | 258 | |
| 259 | 259 | $this->assertSame( |
| 260 | 260 | 'P1337', |
| 261 | - $this->store->getPropertyIdByText( 'en', 'some label' ) |
|
| 261 | + $this->store->getPropertyIdByText('en', 'some label') |
|
| 262 | 262 | ); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -26,25 +26,25 @@ |
||
| 26 | 26 | private $schemaManager; |
| 27 | 27 | |
| 28 | 28 | public function setUp() { |
| 29 | - $connection = DriverManager::getConnection( array( |
|
| 29 | + $connection = DriverManager::getConnection(array( |
|
| 30 | 30 | 'driver' => 'pdo_sqlite', |
| 31 | 31 | 'memory' => true, |
| 32 | - ) ); |
|
| 32 | + )); |
|
| 33 | 33 | |
| 34 | 34 | $this->schemaManager = $connection->getSchemaManager(); |
| 35 | - $this->storeInstaller = new TermStoreInstaller( $this->schemaManager, new TermStoreConfig( 'kittens_' ) ); |
|
| 35 | + $this->storeInstaller = new TermStoreInstaller($this->schemaManager, new TermStoreConfig('kittens_')); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function testInstallationAndRemoval() { |
| 39 | 39 | $this->storeInstaller->install(); |
| 40 | 40 | |
| 41 | - $this->assertTrue( $this->schemaManager->tablesExist( 'kittens_labels' ) ); |
|
| 42 | - $this->assertTrue( $this->schemaManager->tablesExist( 'kittens_aliases' ) ); |
|
| 41 | + $this->assertTrue($this->schemaManager->tablesExist('kittens_labels')); |
|
| 42 | + $this->assertTrue($this->schemaManager->tablesExist('kittens_aliases')); |
|
| 43 | 43 | |
| 44 | 44 | $this->storeInstaller->uninstall(); |
| 45 | 45 | |
| 46 | - $this->assertFalse( $this->schemaManager->tablesExist( 'kittens_labels' ) ); |
|
| 47 | - $this->assertFalse( $this->schemaManager->tablesExist( 'kittens_aliases' ) ); |
|
| 46 | + $this->assertFalse($this->schemaManager->tablesExist('kittens_labels')); |
|
| 47 | + $this->assertFalse($this->schemaManager->tablesExist('kittens_aliases')); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function testStoresPage() { |
@@ -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\\TermStore\\', __DIR__ . '/integration' ); |
|
| 16 | +$autoLoader->addPsr4('Tests\\Queryr\\TermStore\\', __DIR__.'/integration'); |
|
| 17 | 17 | |
| 18 | -unset( $autoLoader ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +unset($autoLoader); |
|
| 20 | 20 | \ No newline at end of file |
@@ -15,70 +15,70 @@ |
||
| 15 | 15 | private $connection; |
| 16 | 16 | private $tableName; |
| 17 | 17 | |
| 18 | - public function __construct( Connection $connection, $tableName ) { |
|
| 18 | + public function __construct(Connection $connection, $tableName) { |
|
| 19 | 19 | $this->connection = $connection; |
| 20 | 20 | $this->tableName = $tableName; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function selectOneField( $fieldName, array $conditions = [] ) { |
|
| 24 | - return $this->selectOne( [ $fieldName ], $conditions )[$fieldName]; |
|
| 23 | + public function selectOneField($fieldName, array $conditions = [ ]) { |
|
| 24 | + return $this->selectOne([ $fieldName ], $conditions)[ $fieldName ]; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function selectOne( array $fieldNames = null, array $conditions = [] ) { |
|
| 28 | - $statement = $this->executeSelect( $fieldNames, $conditions, 1 ); |
|
| 27 | + public function selectOne(array $fieldNames = null, array $conditions = [ ]) { |
|
| 28 | + $statement = $this->executeSelect($fieldNames, $conditions, 1); |
|
| 29 | 29 | |
| 30 | 30 | $result = $statement->fetch(); |
| 31 | 31 | return $result === false ? null : $result; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function select( array $fieldNames = null, array $conditions = [] ) { |
|
| 35 | - $statement = $this->executeSelect( $fieldNames, $conditions ); |
|
| 34 | + public function select(array $fieldNames = null, array $conditions = [ ]) { |
|
| 35 | + $statement = $this->executeSelect($fieldNames, $conditions); |
|
| 36 | 36 | return $statement->fetchAll(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function selectField( $fieldName, array $conditions = [] ) { |
|
| 39 | + public function selectField($fieldName, array $conditions = [ ]) { |
|
| 40 | 40 | return array_map( |
| 41 | - function( array $resultRow ) use ( $fieldName ) { |
|
| 42 | - return $resultRow[$fieldName]; |
|
| 41 | + function(array $resultRow) use ($fieldName) { |
|
| 42 | + return $resultRow[ $fieldName ]; |
|
| 43 | 43 | }, |
| 44 | - $this->select( [ $fieldName ], $conditions ) |
|
| 44 | + $this->select([ $fieldName ], $conditions) |
|
| 45 | 45 | ); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - private function executeSelect( array $fieldNames = null, array $conditions = [], $limit = null ) { |
|
| 49 | - $sql = $this->buildSelectSql( $fieldNames, $conditions, $limit ); |
|
| 48 | + private function executeSelect(array $fieldNames = null, array $conditions = [ ], $limit = null) { |
|
| 49 | + $sql = $this->buildSelectSql($fieldNames, $conditions, $limit); |
|
| 50 | 50 | |
| 51 | - $statement = $this->connection->prepare( $sql ); |
|
| 52 | - $statement->execute( array_values( $conditions ) ); |
|
| 51 | + $statement = $this->connection->prepare($sql); |
|
| 52 | + $statement->execute(array_values($conditions)); |
|
| 53 | 53 | |
| 54 | 54 | return $statement; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - private function buildSelectSql( array $fieldNames = null, array $conditions = [], $limit = null ) { |
|
| 58 | - $fieldSql = $this->getFieldSql( $fieldNames ); |
|
| 59 | - $conditionSql = $this->getConditionSql( $conditions ); |
|
| 57 | + private function buildSelectSql(array $fieldNames = null, array $conditions = [ ], $limit = null) { |
|
| 58 | + $fieldSql = $this->getFieldSql($fieldNames); |
|
| 59 | + $conditionSql = $this->getConditionSql($conditions); |
|
| 60 | 60 | |
| 61 | - $sql = 'SELECT ' . $fieldSql . ' FROM ' . $this->tableName . ' WHERE ' . $conditionSql; |
|
| 61 | + $sql = 'SELECT '.$fieldSql.' FROM '.$this->tableName.' WHERE '.$conditionSql; |
|
| 62 | 62 | |
| 63 | - if ( $limit !== null ) { |
|
| 64 | - $sql .= ' LIMIT ' . (int)$limit; |
|
| 63 | + if ($limit !== null) { |
|
| 64 | + $sql .= ' LIMIT '.(int)$limit; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $sql; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - private function getFieldSql( array $fields = null ) { |
|
| 71 | - return $fields === null || $fields === [] ? '*' : implode( ', ', (array)$fields ); |
|
| 70 | + private function getFieldSql(array $fields = null) { |
|
| 71 | + return $fields === null || $fields === [ ] ? '*' : implode(', ', (array)$fields); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - private function getConditionSql( array $conditions ) { |
|
| 75 | - $wherePredicates = []; |
|
| 74 | + private function getConditionSql(array $conditions) { |
|
| 75 | + $wherePredicates = [ ]; |
|
| 76 | 76 | |
| 77 | - foreach ( $conditions as $columnName => $columnValue ) { |
|
| 78 | - $wherePredicates[] = $columnName . ' = ?'; |
|
| 77 | + foreach ($conditions as $columnName => $columnValue) { |
|
| 78 | + $wherePredicates[ ] = $columnName.' = ?'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return implode( ' AND ', $wherePredicates ); |
|
| 81 | + return implode(' AND ', $wherePredicates); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @return string|null |
| 21 | 21 | * @throws TermStoreException |
| 22 | 22 | */ |
| 23 | - public function getIdByLabel( $labelLanguageCode, $labelText ); |
|
| 23 | + public function getIdByLabel($labelLanguageCode, $labelText); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Returns the first matching item id. Case insensitive. |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string|null |
| 32 | 32 | * @throws TermStoreException |
| 33 | 33 | */ |
| 34 | - public function getItemIdByLabel( $labelLanguageCode, $labelText ); |
|
| 34 | + public function getItemIdByLabel($labelLanguageCode, $labelText); |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Returns the first matching property id. Case insensitive. |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @return string|null |
| 43 | 43 | * @throws TermStoreException |
| 44 | 44 | */ |
| 45 | - public function getPropertyIdByLabel( $labelLanguageCode, $labelText ); |
|
| 45 | + public function getPropertyIdByLabel($labelLanguageCode, $labelText); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Returns the first matching entity id. Case insensitive. |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return string|null |
| 54 | 54 | * @throws TermStoreException |
| 55 | 55 | */ |
| 56 | - public function getIdByText( $languageCode, $termText ); |
|
| 56 | + public function getIdByText($languageCode, $termText); |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Returns the first matching item id. Case insensitive. |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @return string|null |
| 65 | 65 | * @throws TermStoreException |
| 66 | 66 | */ |
| 67 | - public function getItemIdByText( $languageCode, $termText ); |
|
| 67 | + public function getItemIdByText($languageCode, $termText); |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Returns the first matching property id. Case insensitive. |
@@ -75,6 +75,6 @@ discard block |
||
| 75 | 75 | * @return string|null |
| 76 | 76 | * @throws TermStoreException |
| 77 | 77 | */ |
| 78 | - public function getPropertyIdByText( $languageCode, $termText ); |
|
| 78 | + public function getPropertyIdByText($languageCode, $termText); |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -13,16 +13,16 @@ |
||
| 13 | 13 | |
| 14 | 14 | private $prefix; |
| 15 | 15 | |
| 16 | - public function __construct( $tablePrefix = '' ) { |
|
| 16 | + public function __construct($tablePrefix = '') { |
|
| 17 | 17 | $this->prefix = $tablePrefix; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function getLabelTableName() { |
| 21 | - return $this->prefix . 'labels'; |
|
| 21 | + return $this->prefix.'labels'; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function getAliasesTableName() { |
| 25 | - return $this->prefix . 'aliases'; |
|
| 25 | + return $this->prefix.'aliases'; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |