@@ -1295,6 +1295,35 @@ public function testExceptionAttributeLimit()
12951295 $ this ->assertEquals (1 ,1 );
12961296 }
12971297
1298+ /**
1299+ * @depends testExceptionAttributeLimit
1300+ */
1301+ public function testCheckAttributeCountLimit ()
1302+ {
1303+ if (static ::getAdapterName () === 'mariadb ' || static ::getAdapterName () === 'mysql ' ) {
1304+ $ collection = static ::getDatabase ()->getCollection ('attributeLimit ' );
1305+
1306+ // create same attribute in testExceptionAttributeLimit
1307+ $ attribute = new Document ([
1308+ '$id ' => 'breaking ' ,
1309+ 'type ' => Database::VAR_INTEGER ,
1310+ 'size ' => 0 ,
1311+ 'required ' => true ,
1312+ 'default ' => null ,
1313+ 'signed ' => true ,
1314+ 'array ' => false ,
1315+ 'filters ' => [],
1316+ ]);
1317+
1318+ $ this ->expectException (LimitException::class);
1319+ $ this ->assertEquals (false , static ::getDatabase ()->checkAttribute ($ collection , $ attribute ));
1320+ }
1321+
1322+ // Default assertion for other adapters
1323+ $ this ->assertEquals (1 ,1 );
1324+
1325+ }
1326+
12981327 /**
12991328 * Using phpunit dataProviders to check that all these combinations of types/sizes throw exceptions
13001329 * https://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers
@@ -1393,6 +1422,35 @@ public function testExceptionWidthLimit($key, $stringSize, $stringCount, $intCou
13931422 $ this ->assertEquals (1 ,1 );
13941423 }
13951424
1425+ /**
1426+ * @dataProvider rowWidthExceedsMaximum
1427+ * @depends testExceptionWidthLimit
1428+ */
1429+ public function testCheckAttributeWidthLimit ($ key , $ stringSize , $ stringCount , $ intCount , $ floatCount , $ boolCount )
1430+ {
1431+ if (static ::getAdapterRowLimit () > 0 ) {
1432+ $ collection = static ::getDatabase ()->getCollection ("widthLimit {$ key }" );
1433+
1434+ // create same attribute in testExceptionWidthLimit
1435+ $ attribute = new Document ([
1436+ '$id ' => 'breaking ' ,
1437+ 'type ' => Database::VAR_STRING ,
1438+ 'size ' => 100 ,
1439+ 'required ' => true ,
1440+ 'default ' => null ,
1441+ 'signed ' => true ,
1442+ 'array ' => false ,
1443+ 'filters ' => [],
1444+ ]);
1445+
1446+ $ this ->expectException (LimitException::class);
1447+ $ this ->assertEquals (false , static ::getDatabase ()->checkAttribute ($ collection , $ attribute ));
1448+ }
1449+
1450+ // Default assertion for other adapters
1451+ $ this ->assertEquals (1 ,1 );
1452+ }
1453+
13961454 public function testExceptionIndexLimit ()
13971455 {
13981456 static ::getDatabase ()->createCollection ('indexLimit ' );
0 commit comments