Best AspectMock code snippet using Anything.valid
RemembermeTest.php
Source:RemembermeTest.php
...10 * Default user id, used as credential information to check11 */12 protected $userid = 1;13 14 protected $validToken = "78b1e6d775cec5260001af137a79dbd5";15 16 protected $validPersistentToken = "0e0530c1430da76495955eb06eb99d95";17 protected $invalidToken = "7ae7c7caa0c7b880cb247bb281d527de";18 protected $cookie;19 20 protected $storage;21 22 function setUp() {23 $this->storage = $this->getMock("Birke\Rememberme\Storage\StorageInterface");24 $this->rememberme = new Birke\Rememberme\Authenticator($this->storage);25 26 $this->cookie = $this->getMock("\\Birke\\Rememberme\\Cookie", array("setcookie"));27 $this->rememberme->setCookie($this->cookie);28 29 $_COOKIE = array();30 }31 /* Basic cases */32 33 public function testReturnFalseIfNoCookieExists()34 {35 $this->assertFalse($this->rememberme->login());36 }37 public function testReturnFalseIfCookieIsInvalid()38 {39 $_COOKIE = array($this->rememberme->getCookieName() => "DUMMY");40 $this->assertFalse($this->rememberme->login());41 $_COOKIE = array($this->rememberme->getCookieName() => $this->userid."|a");42 $this->assertFalse($this->rememberme->login());43 }44 45 public function testLoginTriesToFindTripletWithValuesFromCookie() {46 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(47 $this->userid, $this->validToken, $this->validPersistentToken));48 $this->storage->expects($this->once())49 ->method("findTriplet")50 ->with($this->equalTo($this->userid), $this->equalTo($this->validToken), $this->equalTo($this->validPersistentToken));51 $this->rememberme->login();52 }53 /* Success cases */54 public function testReturnTrueIfTripletIsFound() {55 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(56 $this->userid, $this->validToken, $this->validPersistentToken));57 58 $this->storage->expects($this->once())59 ->method("findTriplet")60 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));61 $this->assertEquals($this->userid, $this->rememberme->login());62 }63 public function testStoreNewTripletInCookieIfTripletIsFound() {64 $oldcookieValue = implode("|", array(65 $this->userid, $this->validToken, $this->validPersistentToken));66 $_COOKIE[$this->rememberme->getCookieName()] = $oldcookieValue;67 $this->storage->expects($this->once())68 ->method("findTriplet")69 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));70 $this->cookie->expects($this->once())71 ->method("setcookie")72 ->with(73 $this->anything(),74 $this->logicalAnd(75 $this->matchesRegularExpression('/^'.$this->userid.'\|[a-f0-9]{32,}\|'.$this->validPersistentToken.'$/'),76 $this->logicalNot($this->equalTo($oldcookieValue))77 )78 );79 $this->rememberme->login();80 }81 public function testReplaceTripletInStorageIfTripletIsFound() {82 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(83 $this->userid, $this->validToken, $this->validPersistentToken));84 $this->storage->expects($this->once())85 ->method("findTriplet")86 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));87 $this->storage->expects($this->once())88 ->method("replaceTriplet")89 ->with(90 $this->equalTo($this->userid),91 $this->logicalAnd(92 $this->matchesRegularExpression('/^[a-f0-9]{32,}$/'),93 $this->logicalNot($this->equalTo($this->validToken))94 ),95 $this->equalTo($this->validPersistentToken)96 );97 $this->rememberme->login();98 }99 public function testCookieContainsUserIDAndHexTokensIfTripletIsFound()100 {101 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(102 $this->userid, $this->validToken, $this->validPersistentToken));103 $this->storage->expects($this->once())104 ->method("findTriplet")105 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));106 $this->cookie->expects($this->once())107 ->method("setcookie")108 ->with($this->anything(),109 $this->matchesRegularExpression('/^'.$this->userid.'\|[a-f0-9]{32,}\|[a-f0-9]{32,}$/')110 );111 $this->rememberme->login();112 }113 public function testCookieContainsNewTokenIfTripletIsFound()114 {115 $oldcookieValue = implode("|", array(116 $this->userid, $this->validToken, $this->validPersistentToken));117 $_COOKIE[$this->rememberme->getCookieName()] = $oldcookieValue;118 $this->storage->expects($this->once())119 ->method("findTriplet")120 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));121 $this->cookie->expects($this->once())122 ->method("setcookie")123 ->with($this->anything(),124 $this->logicalAnd(125 $this->matchesRegularExpression('/^'.$this->userid.'\|[a-f0-9]{32,}\|'.$this->validPersistentToken.'$/'),126 $this->logicalNot($this->equalTo($oldcookieValue))127 )128 );129 $this->rememberme->login();130 }131 public function testCookieExpiryIsInTheFutureIfTripletIsFound()132 {133 $oldcookieValue = implode("|", array(134 $this->userid, $this->validToken, $this->validPersistentToken));135 $_COOKIE[$this->rememberme->getCookieName()] = $oldcookieValue;136 $now = time();137 $this->storage->expects($this->once())138 ->method("findTriplet")139 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));140 $this->cookie->expects($this->once())141 ->method("setcookie")142 ->with($this->anything(), $this->anything(), $this->greaterThan($now));143 $this->rememberme->login();144 }145 /* Failure Cases */146 public function testFalseIfTripletIsNotFound() {147 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(148 $this->userid, $this->validToken, $this->validPersistentToken));149 $this->storage->expects($this->once())150 ->method("findTriplet")151 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_NOT_FOUND));152 $this->assertFalse($this->rememberme->login());153 }154 public function testFalseIfTripletIsInvalid() {155 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(156 $this->userid, $this->invalidToken, $this->validPersistentToken));157 $this->storage->expects($this->once())158 ->method("findTriplet")159 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_INVALID));160 $this->assertFalse($this->rememberme->login());161 }162 public function testCookieIsExpiredIfTripletIsInvalid() {163 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(164 $this->userid, $this->invalidToken, $this->validPersistentToken));165 $now = time();166 $this->storage->expects($this->once())167 ->method("findTriplet")168 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_INVALID));169 $this->cookie->expects($this->once())170 ->method("setcookie")171 ->with($this->anything(), $this->anything(), $this->lessThan($now));172 $this->rememberme->login();173 }174 public function testAllStoredTokensAreClearedIfTripletIsInvalid() {175 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(176 $this->userid, $this->invalidToken, $this->validPersistentToken));177 $this->storage->expects($this->any())178 ->method("findTriplet")179 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_INVALID));180 $this->storage->expects($this->once())181 ->method("cleanAllTriplets")182 ->with($this->equalTo($this->userid));183 $this->rememberme->setCleanStoredTokensOnInvalidResult(true);184 $this->rememberme->login();185 $this->rememberme->setCleanStoredTokensOnInvalidResult(false);186 $this->rememberme->login();187 }188 public function testInvalidTripletStateIsStored() {189 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(190 $this->userid, $this->invalidToken, $this->validPersistentToken));191 $this->storage->expects($this->once())192 ->method("findTriplet")193 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_INVALID));194 $this->assertFalse($this->rememberme->loginTokenWasInvalid());195 $this->rememberme->login();196 $this->assertTrue($this->rememberme->loginTokenWasInvalid());197 }198 /* Cookie tests */199 public function testCookieNameCanBeSet() {200 $cookieName = "myCustomName";201 $this->rememberme->setCookieName($cookieName);202 $_COOKIE[$cookieName] = implode("|", array($this->userid, $this->validToken, $this->validPersistentToken));203 $this->storage->expects($this->once())204 ->method("findTriplet")205 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));206 $this->cookie->expects($this->once())207 ->method("setcookie")208 ->with($this->equalTo($cookieName));209 $this->assertEquals($this->userid, $this->rememberme->login());210 }211 public function testCookieIsSetToConfiguredExpiryDate() {212 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(213 $this->userid, $this->validToken, $this->validPersistentToken));214 $now = time();215 $expireTime = 31556926; // 1 year216 $this->rememberme->setExpireTime($expireTime);217 $this->storage->expects($this->once())218 ->method("findTriplet")219 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));220 $this->cookie->expects($this->once())221 ->method("setcookie")222 ->with($this->anything(), $this->anything(), $this->equalTo($now+$expireTime, 10));223 $this->rememberme->login();224 }225 /* Salting test */226 public function testSaltIsAddedToTokensOnLogin() {227 $salt = "Mozilla Firefox 4.0";228 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(229 $this->userid, $this->validToken, $this->validPersistentToken));230 $this->storage->expects($this->once())231 ->method("findTriplet")232 ->with($this->equalTo($this->userid), $this->equalTo($this->validToken.$salt), $this->equalTo($this->validPersistentToken.$salt))233 ->will($this->returnValue(Birke\Rememberme\Storage\StorageInterface::TRIPLET_FOUND));234 $this->storage->expects($this->once())235 ->method("replaceTriplet")236 ->with(237 $this->equalTo($this->userid), 238 $this->matchesRegularExpression('/^[a-f0-9]{32,}'.preg_quote($salt)."$/"), 239 $this->equalTo($this->validPersistentToken.$salt)240 );241 $this->rememberme->setSalt($salt);242 $this->rememberme->login();243 }244 public function testSaltIsAddedToTokensOnCookieIsValid() {245 $salt = "Mozilla Firefox 4.0";246 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(247 $this->userid, $this->validToken, $this->validPersistentToken));248 $this->storage->expects($this->once())249 ->method("findTriplet")250 ->with($this->equalTo($this->userid), $this->equalTo($this->validToken.$salt), $this->equalTo($this->validPersistentToken.$salt));251 $this->rememberme->setSalt($salt);252 $this->rememberme->cookieIsValid($this->userid);253 }254 public function testSaltIsAddedToTokensOnCreateCookie() {255 $salt = "Mozilla Firefox 4.0";256 $testExpr = '/^[a-f0-9]{32,}'.preg_quote($salt).'$/';257 $this->storage->expects($this->once())258 ->method("storeTriplet")259 ->with(260 $this->equalTo($this->userid),261 $this->matchesRegularExpression($testExpr),262 $this->matchesRegularExpression($testExpr)263 );264 $this->rememberme->setSalt($salt);265 $this->rememberme->createCookie($this->userid);266 }267 public function testSaltIsAddedToTokensOnClearCookie() {268 $salt = "Mozilla Firefox 4.0";269 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(270 $this->userid, $this->validToken, $this->validPersistentToken));271 $this->storage->expects($this->once())272 ->method("cleanTriplet")273 ->with(274 $this->equalTo($this->userid),275 $this->equalTo($this->validPersistentToken.$salt)276 );277 $this->rememberme->setSalt($salt);278 $this->rememberme->clearCookie(true);279 }280 /* Other functions */281 public function testCreateCookieCreatesCookieAndStoresTriplets() {282 $now = time();283 $this->cookie->expects($this->once())284 ->method("setcookie")285 ->with(286 $this->equalTo($this->rememberme->getCookieName()),287 $this->matchesRegularExpression('/^'.$this->userid.'\|[a-f0-9]{32,}\|[a-f0-9]{32,}$/'),288 $this->greaterThan($now)289 );290 $testExpr = '/^[a-f0-9]{32,}$/';291 $this->storage->expects($this->once())292 ->method("storeTriplet")293 ->with(294 $this->equalTo($this->userid),295 $this->matchesRegularExpression($testExpr),296 $this->matchesRegularExpression($testExpr)297 );298 $this->rememberme->createCookie($this->userid);299 }300 public function testClearCookieExpiresCookieAndDeletesTriplet() {301 $_COOKIE[$this->rememberme->getCookieName()] = implode("|", array(302 $this->userid, $this->validToken, $this->validPersistentToken));303 $now = time();304 $this->cookie->expects($this->once())305 ->method("setcookie")306 ->with(307 $this->equalTo($this->rememberme->getCookieName()),308 $this->anything(),309 $this->lessThan($now)310 );311 $this->storage->expects($this->once())312 ->method("cleanTriplet")313 ->with(314 $this->equalTo($this->userid),315 $this->equalTo($this->validPersistentToken)316 );317 $this->rememberme->clearCookie(true);318 }319 320}...
Ox_SchemaTest.php
Source:Ox_SchemaTest.php
...41 }42 public function testField() {43 $schema_array = array(44 'basicField' => array(45 '__validator' => new Ox_DefaultValidator(),46 ),47 );48 $doc = array (49 'basicField' => 'anything',50 );51 $schema = new TestSchema($schema_array);52 $this->assertTrue($schema->isFieldValid('basicField',$doc['basicField'],$doc));53 $this->assertTrue($schema->isValid($doc));54 }55 public function testFieldFail() {56 $schema_array = array(57 'basicField' => array(58 '__validator' => new Ox_RegExValidator('/^willFail$/'),59 ),60 );61 $doc = array (62 'basicField' => 'anything',63 );64 $schema = new TestSchema($schema_array);65 $this->assertFalse($schema->isFieldValid('basicField',$doc['basicField'],$doc));66 $this->assertFalse($schema->isValid($doc));67 }68 public function testObject() {69 $objectSchema = array(70 'basicField' => array(71 '__validator' => new Ox_DefaultValidator(),72 ),73 );74 $schema_array = array(75 'basicObject' => array(76 '__schema' => new TestSchema($objectSchema),77 ),78 );79 $doc = array (80 'basicObject' => array(81 'basicField' => 'anything',82 ),83 );84 $schema = new TestSchema($schema_array);85// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));86 $this->assertTrue($schema->isValid($doc));87 }88 public function testObjectFail() {89 $objectSchema = array(90 'basicField' => array(91 '__validator' => new Ox_RegExValidator('/^willFail$/'),92 ),93 );94 $schema_array = array(95 'basicObject' => array(96 '__schema' => new TestSchema($objectSchema),97 ),98 );99 $doc = array (100 'basicObject' => array(101 'basicField' => 'anything',102 ),103 );104 $schema = new TestSchema($schema_array);105// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));106 $this->assertFalse($schema->isValid($doc));107 }108 public function testEmbeddedObject() {109 $objectSchema = array(110 'basicField' => array(111 '__validator' => new Ox_RegExValidator('/^\w+/'),112 ),113 );114 $embedArray = array(115 'basicObject' => array(116 '__schema' => new TestSchema($objectSchema),117 ),118 );119 $schemaArray = array(120 'basicObject' => array(121 '__schema' => new TestSchema($embedArray),122 ),123 );124 $doc = array (125 'basicObject' => array(126 'embedObject' => array(127 'basicField' => 'anything',128 ),129 ),130 );131 $schema = new TestSchema($schemaArray);132// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));133 $this->assertTrue($schema->isValid($doc));134 }135 public function testEmbeddedObjectFail() {136 $objectSchema = array(137 'basicField' => array(138 '__validator' => new Ox_RegExValidator('/^willFail$/'),139 ),140 );141 $embedArray = array(142 'embedObject' => array(143 '__schema' => new TestSchema($objectSchema),144 ),145 );146 $schemaArray = array(147 'basicObject' => array(148 '__schema' => new TestSchema($embedArray),149 ),150 );151 $doc = array (152 'basicObject' => array(153 'embedObject' => array(154 'basicField' => 'anything',155 ),156 ),157 );158 $schema = new TestSchema($schemaArray);159// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));160 $this->assertFalse($schema->isValid($doc));161 }162 public function testArray() {163 $objectSchema = array(164 'basicField' => array(165 '__validator' => new Ox_RegExValidator('/^\w+$/'),166 ),167 );168 $schemaObject = new TestSchema($objectSchema);169 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);170 $schemaArray = array(171 'basicArray' => array(172 '__schema' => $schemaObject,173 ),174 );175 $doc = array (176 'basicArray' => array(177 array('basicField' => 'anything'),178 array('basicField' => 'anything'),179 array('basicField' => 'anything'),180 ),181 );182 $schema = new TestSchema($schemaArray);183 $valid = $schema->isValid($doc);184 if (!$valid) {185 print_r($schema->getErrors());186 }187 $this->assertTrue($valid);188 }189 public function testArrayFail() {190 $objectSchema = array(191 'basicField' => array(192 '__validator' => new Ox_RegExValidator('/^\w+$/'),193 ),194 );195 $schemaObject = new TestSchema($objectSchema);196 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);197 $schemaArray = array(198 'basicArray' => array(199 '__schema' => new TestSchema($objectSchema),200 ),201 );202 $doc = array (203 'basicArray' => array(204 array('basicField' => 'anything'),205 array('basicField' => 'anything'),206 array('basicField' => 'any-thing'), //this one fails207 ),208 );209 $schema = new TestSchema($schemaArray);210// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));211 $this->assertFalse($schema->isValid($doc));212 }213 public function testEmbedArray() {214 $objectSchema = array(215 'basicField' => array(216 '__validator' => new Ox_RegExValidator('/^\w+$/'),217 ),218 );219 $schemaObject = new TestSchema($objectSchema);220 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);221 $embedArray = array(222 'embedArray' => array(223 '__schema' => $schemaObject,224 ),225 );226 $schemaObject = new TestSchema($embedArray);227 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);228 $schemaArray = array(229 'basicArray' => array(230 '__schema' => $schemaObject,231 ),232 );233 $doc = array (234 'basicArray' => array(235 array('embedArray' => array(236 array('basicField' => 'anything'),237 array('basicField' => 'anything'),238 array('basicField' => 'anything'),239 )),240 array('embedArray' => array(241 array('basicField' => 'anything'),242 array('basicField' => 'anything'),243 array('basicField' => 'anything'),244 )),245 array('embedArray' => array(246 array('basicField' => 'anything'),247 array('basicField' => 'anything'),248 array('basicField' => 'anything'),249 )),250 ),251 );252 $schema = new TestSchema($schemaArray);253// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));254 $valid = $schema->isValid($doc);255 if (!$valid) {256 print_r($schema->getErrors());257 }258 $this->assertTrue($valid);259 }260 public function testEmbedArrayFail() {261 $objectSchema = array(262 'basicField' => array(263 '__validator' => new Ox_RegExValidator('/^\w+$/'),264 ),265 );266 $schemaObject = new TestSchema($objectSchema);267 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);268 $embedArray = array(269 'embedArray' => array(270 '__schema' => $schemaObject,271 ),272 );273 $schemaObject = new TestSchema($embedArray);274 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);275 $schemaArray = array(276 'basicArray' => array(277 '__schema' => $schemaObject,278 ),279 );280 $doc = array (281 'basicArray' => array(282 array('embedArray' => array(283 array('basicField' => 'anything'),284 array('basicField' => 'anything'),285 array('basicField' => 'anything'),286 )),287 array('embedArray' => array(288 array('basicField' => 'anything'),289 array('basicField' => 'anything'),290 array('basicField' => 'anything'),291 )),292 array('embedArray' => array(293 array('basicField' => 'anything'),294 array('basicField' => 'anything'),295 array('basicField' => 'any-thing'), //will fail296 )),297 ),298 );299 $schema = new TestSchema($schemaArray);300// $this->assertTrue($schema->isFieldValid('basicObject.basicField',$doc['basicObject']['basicField']));301 $this->assertFalse($schema->isValid($doc));302 }303/*304 public function testArrayButHaveObjectFail() {305 $objectSchema = array(306 'basicField' => array(307 '__validator' => new Ox_RegExValidator('/^\w+$/'),308 ),309 );310 $schemaObject = new TestSchema($objectSchema);311 $schemaObject->setType(Ox_Schema::TYPE_ARRAY);312 $schemaArray = array(313 'basicArray' => array(314 '__schema' => new TestSchema($objectSchema),315 ),316 );317 $doc = array (318 'basicArray' => array(319 'basicField' => 'anything',320 ),321 );...
MultipleStatementAlignmentUnitTest.inc
Source:MultipleStatementAlignmentUnitTest.inc
...3$var1 = 'var1';4$var10 = 'var1';5$var100 = 'var1';6$var1000 = 'var1';7// Invalid8$var1 = 'var1';9$var10 = 'var1';10$var100 = 'var1';11$var1000 = 'var1';12// Valid13$var1 = 'var1';14$var10 = 'var1';15$var100 = 'var1';16$var1000 = 'var1';17// Invalid18$var1 = 'var1';19$var10 = 'var1';20$var100 = 'var1';21$var1000 = 'var1';22// Valid23$var1 .= 'var1';24$var10 .= 'var1';25$var100 .= 'var1';26$var1000 .= 'var1';27// Invalid28$var1 .= 'var1';29$var10.= 'var1';30$var100 .= 'var1';31$var1000 .= 'var1';32// Valid33$var1 = 'var1';34$var10 .= 'var1';35$var100 = 'var1';36$var1000 .= 'var1';37// Invalid38$var1 = 'var1';39$var10 .= 'var1';40$var100 = 'var1';41$var1000.= 'var1';42// Valid43$var1 .= 'var1';44$var10 .= 'var1';45$var100 .= 'var1';46$var1000 .= 'var1';47// Invalid48$var1 .= 'var1';49$var10 .= 'var1';50$var100 .= 'var1';51$var1000 .= 'var1';52// Valid53$var = 100;54// InValid55$var = 100;56$commentStart = $phpcsFile->findPrevious();57$commentEnd = $this->_phpcsFile;58$expected .= '...';59// Invalid60$this->okButton = new Button();61$content = new MyClass();62$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array();63class MyClass64{65 const MODE_DEBUG = 'debug';66 const MODE_DEBUG2 = 'debug';67 $array[$test] = 'anything';68 $var = 'anything';69 const MODE_DEBUG2 = 'debug';70 $array[$test] = 'anything';71 $var = 'anything';72 $array[($test + 1)] = 'anything';73 $array[($blah + (10 - $test))] = 'anything';74}75function myFunction($var=true)76{77 if ($strict === true) {78 $length = strlen($string);79 $lastCharWasCaps = ($classFormat === false) ? false : true;80 for ($i = 1; $i < $length; $i++) {81 $isCaps = (strtoupper($string{$i}) === $string{$i}) ? true : false;82 if ($isCaps === true && $lastCharWasCaps === true) {83 return false;84 }85 $lastCharWasCaps = $isCaps;86 }87 }88}89// Valid90for ($i = 0; $i < 10; $i += 2) {91 $i = ($i - 1);92}93// Invalid94foreach ($files as $file) {95 $saves[$file] = array();96 $contents = stripslashes(file_get_contents($file));97 list($assetid, $time, $content) = explode("\n", $contents);98 $saves[$file]['assetid'] = $assetid;99}100$i = ($i - 10);101$ip = ($i - 10);102for ($i = 0; $i < 10; $i += 2) {103 $i = ($i - 10);104}105// Valid106$variable = 12;107$var = a_very(long_line('that', 'contains'),108 a_bunch('of long', 'parameters'),109 'that_need to be aligned with the equal sign');110$var2 = 12;111// Valid112$variable = 12;113$var = 'a very long line of text that contains '114 .$someVar115 .' and some other stuff that is too long to fit on one line';116$var2 = 12;117// Invalid118$variable = 12;119$var = a_very(long_line('that', 'contains'),120 a_bunch('of long', 'parameters'),121 'that_need to be aligned with the equal sign');122$var2 = 12;123// Invalid124$variable = 12;125$var = 'a very long line of text that contains '126 .$someVar127 .' and some other stuff that is too long to fit on one line';128$var2 = 12;129// Valid130$variable = 12;131$var .= 'a very long line of text that contains '132 .$someVar133 .' and some other stuff that is too long to fit on one line';134$var2 = 12;135// Valid136$variable += 12;137$var .= 'a very long line of text that contains '138 .$someVar139 .' and some other stuff that is too long to fit on one line';140$var2 = 12;141// Invalid142$variable = 12;143$var .= 'a very long line of text that contains '144 .$someVar145 .' and some other stuff that is too long to fit on one line';146$var2 = 12;147// Valid148$error = false;149while (list($h, $f) = each($handle)) {150 $error = true;151}152// Valid153$value = false;154function blah ($value = true) {155 $value = false;...
valid
Using AI Code Generation
1$anything = new Anything();2$anything->doSomething();3$anything = new Anything();4$anything->doSomething();5$anything = new Anything();6$anything->doSomething();7$anything = new Anything();8$anything->doSomething();9$anything = new Anything();10$anything->doSomething();11$anything = new Anything();12$anything->doSomething();13$anything = new Anything();14$anything->doSomething();15$anything = new Anything();16$anything->doSomething();17$anything = new Anything();18$anything->doSomething();19$anything = new Anything();20$anything->doSomething();21$anything = new Anything();22$anything->doSomething();23$anything = new Anything();24$anything->doSomething();25$anything = new Anything();26$anything->doSomething();27$anything = new Anything();28$anything->doSomething();29$anything = new Anything();30$anything->doSomething();31$anything = new Anything();32$anything->doSomething();33$anything = new Anything();34$anything->doSomething();
valid
Using AI Code Generation
1$obj = new Anything();2$obj->doSomething();3$obj = new Anything();4$obj->doSomething();5$obj = new Anything();6$obj->doSomething();7$obj = new Anything();8$obj->doSomething();9$obj = new Anything();10$obj->doSomething();11$obj = new Anything();12$obj->doSomething();13$obj = new Anything();14$obj->doSomething();15$obj = new Anything();16$obj->doSomething();17$obj = new Anything();18$obj->doSomething();19$obj = new Anything();20$obj->doSomething();21$obj = new Anything();22$obj->doSomething();23$obj = new Anything();24$obj->doSomething();25$obj = new Anything();26$obj->doSomething();27$obj = new Anything();28$obj->doSomething();29$obj = new Anything();30$obj->doSomething();31$obj = new Anything();32$obj->doSomething();33$obj = new Anything();34$obj->doSomething();35$obj = new Anything();36$obj->doSomething();37$obj = new Anything();38$obj->doSomething();
valid
Using AI Code Generation
1$a = new Anything();2$a->validMethod();3$a = new Anything();4$a->validMethod();5$a = new Anything();6$a->validMethod();7$a = new Anything();8$a->validMethod();9$a = new Anything();10$a->validMethod();11$a = new Anything();12$a->validMethod();13$a = new Anything();14$a->validMethod();15$a = new Anything();16$a->validMethod();17$a = new Anything();18$a->validMethod();19$a = new Anything();20$a->validMethod();21$a = new Anything();22$a->validMethod();23$a = new Anything();24$a->validMethod();25$a = new Anything();26$a->validMethod();27$a = new Anything();28$a->validMethod();29$a = new Anything();30$a->validMethod();31$a = new Anything();32$a->validMethod();33$a = new Anything();34$a->validMethod();35$a = new Anything();36$a->validMethod();37$a = new Anything();38$a->validMethod();
valid
Using AI Code Generation
1$obj = new Anything();2$obj->method1();3$obj->method2();4$obj->method3();5$obj = new Anything();6$obj->method1();7$obj->method2();8$obj->method3();9$obj = new Anything();10$obj->method1();11$obj->method2();12$obj->method3();13$obj = new Anything();14$obj->method1();15$obj->method2();16$obj->method3();17$obj = new Anything();18$obj->method1();19$obj->method2();20$obj->method3();21$obj = new Anything();22$obj->method1();23$obj->method2();24$obj->method3();25$obj = new Anything();26$obj->method1();27$obj->method2();28$obj->method3();29$obj = new Anything();30$obj->method1();31$obj->method2();32$obj->method3();33$obj = new Anything();34$obj->method1();35$obj->method2();36$obj->method3();37$obj = new Anything();38$obj->method1();39$obj->method2();40$obj->method3();41$obj = new Anything();42$obj->method1();43$obj->method2();44$obj->method3();45$obj = new Anything();46$obj->method1();47$obj->method2();48$obj->method3();49$obj = new Anything();50$obj->method1();51$obj->method2();52$obj->method3();53$obj = new Anything();54$obj->method1();55$obj->method2();
valid
Using AI Code Generation
1$obj = new Anything();2$obj->doSomething();3$obj->doSomethingElse();4$obj->doSomething();5$obj = new Anything();6$obj->doSomething();7$obj->doSomethingElse();8$obj->doSomething();9$obj = new Anything();10$obj->doSomething();11$obj->doSomethingElse();12$obj->doSomething();13$obj = new Anything();14$obj->doSomething();15$obj->doSomethingElse();16$obj->doSomething();17$obj = new Anything();18$obj->doSomething();19$obj->doSomethingElse();20$obj->doSomething();21$obj = new Anything();22$obj->doSomething();23$obj->doSomethingElse();24$obj->doSomething();25$obj = new Anything();26$obj->doSomething();27$obj->doSomethingElse();28$obj->doSomething();29$obj = new Anything();30$obj->doSomething();31$obj->doSomethingElse();32$obj->doSomething();33$obj = new Anything();34$obj->doSomething();35$obj->doSomethingElse();36$obj->doSomething();37$obj = new Anything();38$obj->doSomething();39$obj->doSomethingElse();40$obj->doSomething();41$obj = new Anything();42$obj->doSomething();43$obj->doSomethingElse();44$obj->doSomething();45$obj = new Anything();46$obj->doSomething();47$obj->doSomethingElse();48$obj->doSomething();49$obj = new Anything();50$obj->doSomething();51$obj->doSomethingElse();52$obj->doSomething();
valid
Using AI Code Generation
1$obj = new Anything();2$obj->set("Hello");3$obj->get();4$obj = new Anything();5$obj->set("Hello");6$obj->get();7$obj->invalidMethod();8$obj = new Anything();9$obj->invalidMethod();10$obj = new Anything();11$obj->invalidMethod();12$obj->invalidMethod();13$obj = new Anything();14$obj->invalidMethod();15$obj->invalidMethod();16$obj->invalidMethod();17Fatal error: Uncaught Error: Call to undefined method Anything::invalidMethod() in /path/to/file/6.php:6 Stack trace: #0 {main} thrown in /path/to/file/6.php on line 618The above error message is generated by PHP itself. PHP is a compiled language. The PHP compiler (Zend Engine) compiles the PHP code into an intermediate code called Zend Engine bytecode. This intermediate code is then executed by Zend Engine. The Zend Engine is a virtual machine. It is a machine that executes the intermediate code. It is a virtual machine because it is not a real machine. It is a virtual machine be
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with valid on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!