Exemplo n.º 1
0
 /**
  * Runs all assertions in the block
  *
  * @param  function(): void $block
  * @return void
  * @throws unittest.AssertionFailedError
  */
 public static function of($block)
 {
     Assertions::enter(new AssertionsFailed());
     try {
         $block();
         Assertions::leave()->raiseIf();
     } catch (Throwable $e) {
         Assertions::leave();
         throw $e;
     }
 }
 public function strings_with_Test_do_not_contain_Test($value)
 {
     $this->assertUnverified(['/Failed to verify that .* does not contain "Test"/'], Assertions::of($value)->doesNotContain('Test'));
 }
 public function is_not_a_test()
 {
     $this->assertVerified(Assertions::of('Test')->isNot(newinstance(Condition::class, [], ['matches' => function ($value) {
         return 'Test' !== $value;
     }])));
 }
 public function array_size_and_elements()
 {
     $this->assertVerified(Assertions::of([1, 2, 3])->isNotEqualTo(null)->hasSize(3)->contains(2));
 }
 public function objects_does_not_not_contain_aynthing($value)
 {
     $this->assertUnverified(['/Failed to verify that .* does not contain anything/ms'], Assertions::of($value)->doesNotContain('...'));
 }
Exemplo n.º 6
0
 /**
  * Assert a given condition does not match this value
  * 
  * @param  unittest.assert.Condition $condition
  * @return self
  */
 public function isNot(Condition $condition)
 {
     $this->failed || Assertions::verify(function () use($condition) {
         if ($condition->matches($this->value)) {
             $this->failed = true;
             return new AssertionFailedError('Failed to verify that ' . $condition->describe($this->value, false));
         } else {
             return null;
         }
     });
     return $this;
 }
 public function tearDown()
 {
     Assertions::leave();
 }
 public function is_not_CloseTo1_using_integers($value)
 {
     $this->assertUnverified(['/Failed to verify that .* is close to 1 \\(within a tolerance of 1\\)/'], Assertions::of($value)->isCloseTo(1, 1));
 }
Exemplo n.º 9
0
 public function objects_do_not_end_with_aynthing($value)
 {
     $this->assertUnverified(['/Failed to verify that .* ends with anything/ms'], Assertions::of($value)->endsWith('...'));
 }
Exemplo n.º 10
0
 public function extracting_from_map_via_array_of_string_and_closure()
 {
     $this->assertVerified(Assertions::of(['id' => 1, 'name' => 'Test'])->extracting([function ($person) {
         return $person['name'];
     }, 'id'])->isEqualTo(['Test', 1]));
 }
Exemplo n.º 11
0
 public function all_other_values_are_not_false($value)
 {
     $this->assertUnverified(['/Failed to verify that .* is false/ms'], Assertions::of($value)->isFalse());
 }
Exemplo n.º 12
0
 public function verify_array_ending_with_1($value)
 {
     $this->assertVerified(Assertions::of($value)->endsWith(1));
 }
Exemplo n.º 13
0
 public function is_not_equal_to_other_fixtures($fixture, $value)
 {
     $this->assertUnverified(['/Failed to verify that .* is equal to .*/ms'], Assertions::of($fixture)->isEqualTo($value));
 }