/** * If input is an empty string then return false. */ public function testIfInputIsAnEmptyStringThenReturnFalse() { static::assertFalse(String::isRegex('')); }
/** * When first chunk is a NULL string then return null value. */ public function testWhenFirstChunkIsANULLStringThenReturnNullValue() { $response = String::getFirstChunk('NULL or something "fun"'); static::assertNull($response); }
public static function extractFieldDefault($fieldString, $field) { $stringUtils = new String(stripslashes($fieldString)); $field->Default = String::getFirstChunk($stringUtils->substr('/DEFAULT\\s/')); if ($field->Type === 'INT') { $field->Default = (int) $field->Default; } }
/** * When the input string contains unbalanced quotes then return true. * @dataProvider dataProviderUnbalancedQuotesStrings */ public function testWhenTheInputStringContainsUnbalancedQuotesThenReturnTrue($input) { static::assertFalse(String::areQuotesBalanced($input)); }
/** * If pattern matched multiple times then return the remaining string */ public function testIfPatternMatchedMultipleTimesThenReturnTheRemainingString() { $response = String::substringFrom('/DEFAULT\\s/', 'test DEFAULT 123 DEFAULT ab'); static::assertEquals('123 DEFAULT ab', $response); }
/** * If pattern matched only inside single quotes and flag is set as true then return remaining. * @dataProvider dataProviderStringWithQuotes */ public function testIfPatternMatchedOnlyInsideSingleQuotesAndFlagIsSetAsTrueThenReturnRemaining($input, $expected) { $worker = new String($input); static::assertEquals($expected, $worker->substr('/DEFAULT\\s/', true)); }