Ejemplo n.º 1
0
 public function specification_met($name, $test)
 {
     if (isset($test['disabled'])) {
         $this->skip('Disabed');
     } else {
         if (isset($test['error'])) {
             try {
                 $changes = new Changes(...$test['patch']);
             } catch (IllegalArgumentException $expected) {
                 return;
                 // OK
             }
             $this->assertFalse($changes->apply($test['doc'])->successful());
         } else {
             if (isset($test['expected'])) {
                 $changes = new Changes(...$test['patch']);
                 $result = $changes->apply($test['doc']);
                 if (!$result->successful()) {
                     $this->fail('Changes did not apply successfully', $result->error()->message(), null);
                 }
                 $this->assertEquals($test['expected'], $result->value());
             } else {
                 if (isset($test['patch'])) {
                     $changes = new Changes(...$test['patch']);
                     $this->assertTrue($changes->apply($test['doc'])->successful());
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function apply_returns_failure()
 {
     $changes = new Changes(['op' => 'test', 'path' => '/non-existant', 'value' => null]);
     $value = ['value' => self::ORIGINAL];
     $this->assertEquals(new Failure(new PathDoesNotExist('/non-existant')), $changes->apply($value));
 }