opensrs\backwardcompatibility\dataconversion\domains\lookup\NameSuggest::convertDataObject PHP Method

convertDataObject() public method

public convertDataObject ( $dataObject, $newStructure = null )
    public function convertDataObject($dataObject, $newStructure = null)
    {
        $p = new parent();
        if (is_null($newStructure)) {
            $newStructure = $this->newStructure;
        }
        $newDataObject = $p->convertDataObject($dataObject, $newStructure);
        // run old 'getTlds' method (now called 'getServiceOverride') to get
        // info that should be part of service override entries
        $newDataObject->attributes->service_override = $this->getServiceOverride($dataObject);
        $newDataObject->attributes->services = array('lookup', 'suggestion');
        /* end setting service_override **/
        return $newDataObject;
    }

Usage Example

 /**
  * Valid conversion should complete with no
  * exception thrown.
  *
  *
  * @group validconversion
  */
 public function testValidDataConversion()
 {
     $data = json_decode(json_encode($this->validSubmission));
     $data->data->domain = 'phptest' . time() . '.com';
     $data->data->maximum = '10';
     $data->data->nsselected = '.com;.net;.org';
     $data->data->lkselected = '.com;.net;.org';
     $shouldMatchNewDataObject = new \stdClass();
     $shouldMatchNewDataObject->attributes = new \stdClass();
     $shouldMatchNewDataObject->attributes->service_override = new \stdClass();
     $shouldMatchNewDataObject->attributes->service_override->lookup = new \stdClass();
     $shouldMatchNewDataObject->attributes->service_override->suggestion = new \stdClass();
     $shouldMatchNewDataObject->attributes->searchstring = $data->data->domain;
     $shouldMatchNewDataObject->attributes->services = array('lookup', 'suggestion');
     $shouldMatchNewDataObject->attributes->service_override->lookup->maximum = $data->data->maximum;
     $shouldMatchNewDataObject->attributes->service_override->lookup->tlds = array('.com', '.net', '.org');
     $shouldMatchNewDataObject->attributes->service_override->suggestion->maximum = $data->data->maximum;
     $shouldMatchNewDataObject->attributes->service_override->suggestion->tlds = array('.com', '.net', '.org');
     $ns = new NameSuggest();
     $newDataObject = $ns->convertDataObject($data);
     $this->assertTrue($newDataObject == $shouldMatchNewDataObject);
 }