コード例 #1
0
ファイル: MapperTest.php プロジェクト: taichiatshanghai/yamop
 public function testFindOneAsJson()
 {
     $data = $this->_saveSimpleData();
     $mapperOne = new Mapper('\\Model\\Simple', Mapper::FETCH_JSON);
     $result = $mapperOne->findOne($data);
     $this->assertInternalType('string', $result);
     $decoded = json_decode($result);
     $this->assertInstanceOf('stdClass', $decoded);
     $this->assertAttributeNotEmpty('_id', $decoded);
     $this->assertAttributeInstanceOf('stdClass', '_id', $decoded);
     $this->assertAttributeNotEmpty('test', $decoded);
     $mapperTwo = new Mapper('\\Model\\Simple');
     $mapperTwo->setFetchType(Mapper::FETCH_JSON);
     $result = $mapperTwo->findOne($data);
     $this->assertInternalType('string', $result);
     $decoded = json_decode($result);
     $this->assertInstanceOf('stdClass', $decoded);
     $this->assertAttributeNotEmpty('_id', $decoded);
     $this->assertAttributeInstanceOf('stdClass', '_id', $decoded);
     $this->assertAttributeNotEmpty('test', $decoded);
 }