This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Tests\Queryr\EntityStore; |
||
4 | |||
5 | use Queryr\EntityStore\Data\PropertyInfo; |
||
6 | use Queryr\EntityStore\Data\PropertyRow; |
||
7 | use Queryr\EntityStore\EntityStoreConfig; |
||
8 | use Queryr\EntityStore\EntityStoreFactory; |
||
9 | use Queryr\EntityStore\EntityStoreInstaller; |
||
10 | use Queryr\EntityStore\PropertyStore; |
||
11 | use Tests\Queryr\EntityStore\Fixtures\TestFixtureFactory; |
||
12 | use Wikibase\DataModel\Entity\PropertyId; |
||
13 | |||
14 | /** |
||
15 | * @covers Queryr\EntityStore\PropertyStore |
||
16 | * |
||
17 | * @licence GNU GPL v2+ |
||
18 | * @author Jeroen De Dauw < [email protected] > |
||
19 | */ |
||
20 | class PropertyStoreTest extends \PHPUnit_Framework_TestCase { |
||
21 | |||
22 | const PROPERTY_ID = '42'; |
||
23 | |||
24 | const AND_INSTALL = true; |
||
25 | const WITHOUT_INSTALLING = false; |
||
26 | |||
27 | /** |
||
28 | * @var PropertyStore |
||
29 | */ |
||
30 | private $store; |
||
31 | |||
32 | /** |
||
33 | * @var PropertyRow |
||
34 | */ |
||
35 | private $propertyRow; |
||
36 | |||
37 | public function setUp() { |
||
38 | $this->createPropertyRowField(); |
||
39 | } |
||
40 | |||
41 | private function createStore( $doDbInstall = false ) { |
||
42 | $connection = TestFixtureFactory::newInstance()->newConnection(); |
||
43 | $config = new EntityStoreConfig(); |
||
44 | |||
45 | if ( $doDbInstall ) { |
||
46 | $installer = new EntityStoreInstaller( $connection->getSchemaManager(), $config ); |
||
47 | $installer->install(); |
||
48 | } |
||
49 | |||
50 | $this->store = ( new EntityStoreFactory( $connection, $config ) )->newPropertyStore(); |
||
51 | } |
||
52 | |||
53 | private function createPropertyRowField() { |
||
54 | $this->propertyRow = new PropertyRow( |
||
55 | 'json be here', |
||
56 | new PropertyInfo( |
||
57 | self::PROPERTY_ID, |
||
58 | 'Property:P42', |
||
59 | '424242', |
||
60 | '2014-02-27T11:40:12Z', |
||
61 | 'string' |
||
62 | ) |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | public function testCanStoreAndRetrievePropertyPage() { |
||
67 | $this->createStore( self::AND_INSTALL ); |
||
68 | |||
69 | $this->store->storePropertyRow( $this->propertyRow ); |
||
70 | |||
71 | $newPropertyRow = $this->store->getPropertyRowByNumericPropertyId( self::PROPERTY_ID ); |
||
72 | |||
73 | $this->assertInstanceOf( 'Queryr\EntityStore\Data\PropertyRow', $newPropertyRow ); |
||
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() ); |
||
81 | } |
||
82 | |||
83 | public function testGivenNotKnownId_getPropertyRowByNumericPropertyIdReturnsNull() { |
||
84 | $this->createStore( self::AND_INSTALL ); |
||
85 | $this->assertNull( $this->store->getPropertyRowByNumericPropertyId( '32202' ) ); |
||
86 | } |
||
87 | |||
88 | public function testWhenStoreNotInitialized_storePropertyRowThrowsException() { |
||
89 | $this->createStore( self::WITHOUT_INSTALLING ); |
||
90 | $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
||
0 ignored issues
–
show
|
|||
91 | $this->store->storePropertyRow( $this->propertyRow ); |
||
92 | } |
||
93 | |||
94 | public function testWhenStoreNotInitialized_getPropertyRowByNumericPropertyIdThrowsException() { |
||
95 | $this->createStore( self::WITHOUT_INSTALLING ); |
||
96 | $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
||
0 ignored issues
–
show
The method
PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
97 | $this->store->getPropertyRowByNumericPropertyId( 1 ); |
||
98 | } |
||
99 | |||
100 | public function testWhenStoreNotInitialized_getPropertyInfoThrowsException() { |
||
101 | $this->createStore( self::WITHOUT_INSTALLING ); |
||
102 | $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
||
0 ignored issues
–
show
The method
PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
103 | $this->store->getPropertyInfo( 10, 0 ); |
||
104 | } |
||
105 | |||
106 | public function testInsertingExistingPropertyOverridesTheOriginalOne() { |
||
107 | $this->createStore( self::AND_INSTALL ); |
||
108 | |||
109 | $this->store->storePropertyRow( new PropertyRow( |
||
110 | 'json be here', |
||
111 | new PropertyInfo( |
||
112 | 42, |
||
113 | 'Property:P42', |
||
114 | '424242', |
||
115 | '2014-02-27T11:40:12Z', |
||
116 | 'string' |
||
117 | ) |
||
118 | ) ); |
||
119 | |||
120 | $this->store->storePropertyRow( new PropertyRow( |
||
121 | 'json be here', |
||
122 | new PropertyInfo( |
||
123 | 42, |
||
124 | 'Property:P42', |
||
125 | '2445325', |
||
126 | '2014-02-27T11:40:12Z', |
||
127 | 'kittens' |
||
128 | ) |
||
129 | ) ); |
||
130 | |||
131 | $infoSets = $this->store->getPropertyInfo( 10, 0 ); |
||
132 | $this->assertCount( 1, $infoSets ); |
||
133 | $this->assertSame( 'kittens', $infoSets[0]->getPropertyType() ); |
||
134 | } |
||
135 | |||
136 | public function testWhenStoreNotInitialized_deleteItemByIdThrowsException() { |
||
137 | $this->createStore( self::WITHOUT_INSTALLING ); |
||
138 | $this->setExpectedException( 'Queryr\EntityStore\EntityStoreException' ); |
||
0 ignored issues
–
show
The method
PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
139 | $this->store->deletePropertyById( new PropertyId( 'P1' ) ); |
||
140 | } |
||
141 | |||
142 | public function testGivenNonExistingId_deleteItemByIdDoesNotDeleteItems() { |
||
143 | $this->createStore( self::AND_INSTALL ); |
||
144 | |||
145 | $this->store->storePropertyRow( new PropertyRow( |
||
146 | 'json be here', |
||
147 | new PropertyInfo( |
||
148 | 42, |
||
149 | 'Property:P42', |
||
150 | '424242', |
||
151 | '2014-02-27T11:40:12Z', |
||
152 | 'string' |
||
153 | ) |
||
154 | ) ); |
||
155 | |||
156 | $this->store->deletePropertyById( new PropertyId( 'P43' ) ); |
||
157 | |||
158 | $this->assertCount( 1, $this->store->getPropertyInfo( 10, 0 ) ); |
||
159 | } |
||
160 | |||
161 | public function testGivenExistingId_deleteItemByIdDeletesItem() { |
||
162 | $this->createStore( self::AND_INSTALL ); |
||
163 | |||
164 | $this->store->storePropertyRow( new PropertyRow( |
||
165 | 'json be here', |
||
166 | new PropertyInfo( |
||
167 | 42, |
||
168 | 'Property:P42', |
||
169 | '424242', |
||
170 | '2014-02-27T11:40:12Z', |
||
171 | 'string' |
||
172 | ) |
||
173 | ) ); |
||
174 | |||
175 | $this->store->deletePropertyById( new PropertyId( 'P42' ) ); |
||
176 | |||
177 | $this->assertCount( 0, $this->store->getPropertyInfo( 10, 0 ) ); |
||
178 | } |
||
179 | |||
180 | } |
||
181 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.