示例#1
0
 public function testShrinkingAString()
 {
     $this->forAll(Generator\string())->then(function ($string) {
         var_dump($string);
         $this->assertNotContains('B', $string);
     });
 }
示例#2
0
 public function testLengthPreservation()
 {
     $this->forAll(Generator\string(), Generator\string())->then(function ($first, $second) {
         $result = string_concatenation($first, $second);
         $this->assertEquals(strlen($first) + strlen($second), strlen($result), "Concatenating '{$first}' to '{$second}' gives '{$result}'" . PHP_EOL . var_export($first, true) . PHP_EOL . "strlen(): " . strlen($first) . PHP_EOL . var_export($second, true) . PHP_EOL . "strlen(): " . strlen($second) . PHP_EOL . var_export($result, true) . PHP_EOL . "strlen(): " . strlen($result) . PHP_EOL . "First hex: " . var_export(bin2hex($first), true) . PHP_EOL . "Second hex: " . var_export(bin2hex($second), true) . PHP_EOL . "Result hex: " . var_export(bin2hex($result), true) . PHP_EOL);
     });
 }
 public function testLengthPreservation()
 {
     $this->shrinkingTimeLimit(2)->forAll(Generator\string(), Generator\string())->then(function ($first, $second) {
         $result = very_slow_concatenation($first, $second);
         $this->assertEquals(strlen($first) + strlen($second), strlen($result), "Concatenating '{$first}' to '{$second}' gives '{$result}'" . PHP_EOL);
     });
 }
示例#4
0
 public function testSuchThatAcceptsPHPUnitConstraints()
 {
     $this->forAll(Generator\vector(5, Generator\suchThat($this->isType('integer'), Generator\oneOf(Generator\choose(0, 1000), Generator\string()))))->then($this->allNumbersAreBiggerThan(42));
 }
示例#5
0
 public function testGenericExceptionsDoNotShrinkButStillShowTheInput()
 {
     $this->forAll(Generator\string())->then(function ($string) {
         throw new RuntimeException("Something like a missing array index happened.");
     });
 }