2121 */
2222class RecordExistsTest extends \PHPUnit_Framework_TestCase
2323{
24+ public function setUp ()
25+ {
26+ if (! class_exists (Adapter::class)) {
27+ $ this ->markTestSkipped (
28+ 'Skipping zend-db-related tests until that component is updated '
29+ . 'to zend-servicemanager/zend-eventmanager v3 '
30+ );
31+ }
32+ }
33+
2434 /**
2535 * Return a Mock object for a Db result with rows
2636 *
@@ -102,9 +112,11 @@ protected function getMockNoResult()
102112 */
103113 public function testBasicFindsRecord ()
104114 {
105- $ validator = new RecordExists (['table ' => 'users ' ,
106- 'field ' => 'field1 ' ,
107- 'adapter ' => $ this ->getMockHasResult ()]);
115+ $ validator = new RecordExists ([
116+ 'table ' => 'users ' ,
117+ 'field ' => 'field1 ' ,
118+ 'adapter ' => $ this ->getMockHasResult ()
119+ ]);
108120 $ this ->assertTrue ($ validator ->isValid ('value1 ' ));
109121 }
110122
@@ -197,8 +209,10 @@ public function testExcludeConstructor()
197209 public function testThrowsExceptionWithNoAdapter ()
198210 {
199211 $ validator = new RecordExists ('users ' , 'field1 ' , 'id != 1 ' );
200- $ this ->setExpectedException ('Zend\Validator\Exception\RuntimeException ' ,
201- 'No database adapter present ' );
212+ $ this ->setExpectedException (
213+ 'Zend\Validator\Exception\RuntimeException ' ,
214+ 'No database adapter present '
215+ );
202216 $ validator ->isValid ('nosuchvalue ' );
203217 }
204218
@@ -209,8 +223,10 @@ public function testThrowsExceptionWithNoAdapter()
209223 */
210224 public function testWithSchema ()
211225 {
212- $ validator = new RecordExists (['table ' => 'users ' , 'schema ' => 'my ' ],
213- 'field1 ' , null , $ this ->getMockHasResult ());
226+ $ validator = new RecordExists ([
227+ 'table ' => 'users ' ,
228+ 'schema ' => 'my '
229+ ], 'field1 ' , null , $ this ->getMockHasResult ());
214230 $ this ->assertTrue ($ validator ->isValid ('value1 ' ));
215231 }
216232
@@ -221,8 +237,10 @@ public function testWithSchema()
221237 */
222238 public function testWithSchemaNoResult ()
223239 {
224- $ validator = new RecordExists (['table ' => 'users ' , 'schema ' => 'my ' ],
225- 'field1 ' , null , $ this ->getMockNoResult ());
240+ $ validator = new RecordExists ([
241+ 'table ' => 'users ' ,
242+ 'schema ' => 'my '
243+ ], 'field1 ' , null , $ this ->getMockNoResult ());
226244 $ this ->assertFalse ($ validator ->isValid ('value1 ' ));
227245 }
228246
@@ -232,8 +250,10 @@ public function testWithSchemaNoResult()
232250 */
233251 public function testSelectAcknowledgesTableAndSchema ()
234252 {
235- $ validator = new RecordExists (['table ' => 'users ' , 'schema ' => 'my ' ],
236- 'field1 ' , null , $ this ->getMockHasResult ());
253+ $ validator = new RecordExists ([
254+ 'table ' => 'users ' ,
255+ 'schema ' => 'my '
256+ ], 'field1 ' , null , $ this ->getMockHasResult ());
237257 $ table = $ validator ->getSelect ()->getRawState ('table ' );
238258 $ this ->assertInstanceOf ('Zend\Db\Sql\TableIdentifier ' , $ table );
239259 $ this ->assertEquals (['users ' , 'my ' ], $ table ->getTableAndSchema ());
@@ -242,8 +262,11 @@ public function testSelectAcknowledgesTableAndSchema()
242262 public function testEqualsMessageTemplates ()
243263 {
244264 $ validator = new RecordExists ('users ' , 'field1 ' );
245- $ this ->assertAttributeEquals ($ validator ->getOption ('messageTemplates ' ),
246- 'messageTemplates ' , $ validator );
265+ $ this ->assertAttributeEquals (
266+ $ validator ->getOption ('messageTemplates ' ),
267+ 'messageTemplates ' ,
268+ $ validator
269+ );
247270 }
248271
249272 /**
0 commit comments