get() public method

public get ( string $key ) : mixed
$key string
return mixed
Ejemplo n.º 1
0
 /**
  * @group unit
  */
 public function testSerializedData()
 {
     $data = '{"user":"******"}';
     $document = new Document(1, $data);
     $this->assertFalse($document->has('user'));
     try {
         $document->get('user');
         $this->fail('User field should not be available');
     } catch (InvalidException $e) {
         $this->assertTrue(true);
     }
     try {
         $document->remove('user');
         $this->fail('User field should not be available for removal');
     } catch (InvalidException $e) {
         $this->assertTrue(true);
     }
     try {
         $document->set('name', 'shawn');
         $this->fail('Document should not allow to set new data');
     } catch (InvalidException $e) {
         $this->assertTrue(true);
     }
 }