tests/UnitTests/POData/Writers/Atom/AtomODataWriterTest.php
/**
	 * Test for write top level feed item. 
	 */
Test for write top level feed item.
Test for write top level feed item .
public function testWriteFeed()
    {
    	$feed = new ODataFeed();
    	$feed->id = 'Feed Id';
    	$feed->rowCount = 'Count';
    	$selfLink = new ODataLink ();
    	$selfLink->name = "Self Link Name";
    	$selfLink->tytle = "Self Link Title";
    	$selfLink->type = "";
    	$selfLink->url = "Self Link Url";
    	$feed->selfLink = $selfLink;
    	$nextPageLink = new ODataLink ();
    	$nextPageLink->name = "Next";
    	$nextPageLink->tytle = "";
    	$nextPageLink->type = "";
    	$nextPageLink->url = "Next Link Url";
    	$feed->nextPageLink = $nextPageLink;
    	$feed->title = 'Feed Title';
    	$entry1 = new ODataEntry();
    	$entry1->id = 'Entry 1';
    	$entry1->title = 'Entry Title';
    	$editLink = new ODataLink();
    	$editLink->name = "edit";
    	$editLink->tytle = "Edit Link Title";
    	$editLink->type = "Edit link type";
    	$editLink->url = "Edit Link URL";
    	$entry1->editLink = $editLink;
    	$selfLink = new ODataLink();
    	$selfLink->name = "self";
    	$selfLink->tytle = "self Link Title";
    	$selfLink->type = "";
    	$selfLink->url = "Self Link URL";
    	$entry1->selfLink = $selfLink;
        $entry1->mediaLinks = array(new ODataMediaLink('Media Link Name',
                                                      'Edit Media link', 
                                                      'Src Media Link', 
                                                      'Media Content Type', 
                                                      'Media ETag'));
        $link = new ODataLink();
        $link->name = "Link Name";
    	$link->tytle = "Link Title";
    	$link->type = "Link Type";
    	$link->url = "Link URL";
        $entry1->links = array();
        $entry1->eTag = 'Entry ETag';
        $link->isExpanded       = false;
        $entry1->isMediaLinkEntry = false;
        $bagProp1 = new ODataBagContent();
        $propCont1 = new ODataPropertyContent();
        $propCont1_1 = new ODataPropertyContent();
        $pr1 = new ODataProperty();
        $pr1->name = 'fname';
        $pr1->typeName = 'string';
        $pr1->value = 'Yash';
        $pr2 = new ODataProperty();
        $pr2->name = 'lname';
        $pr2->typeName = 'string';
        $pr2->value = 'Kothari';
        $propCont1_1->properties = array($pr1, $pr2);
		$propCont1_1_1 = new ODataPropertyContent();
		$pr3 = new ODataProperty();
        $pr3->name = 'fname';
        $pr3->typeName = 'string';
        $pr3->value = 'Anu';
        $pr4 = new ODataProperty();
        $pr4->name = 'lname';
        $pr4->typeName = 'string';
        $pr4->value = 'Chandy';
        $pr5 = new ODataProperty();
        $pr5->name = 'name';
        $pr5->typeName = null;
        $pr5->value = $propCont1_1;
        $pr6 = new ODataProperty();
        $pr6->name = 'name';
        $pr6->typeName = null;
        $pr6->value = $propCont1_1;
		$propCont1_1_1->properties = array ($pr3,$pr4);
        $propCont1->properties = array($pr5, $pr6);
        $bagProp1->propertyContents = array($propCont1);
        $pr7 = new ODataProperty();
        $pr7->name = 'name';
        $pr7->typeName = 'Bag(Name)';
        $pr7->value = $bagProp1;
        $prop1 = $pr7;
        $propCont = new ODataPropertyContent ();
        $propCont->properties = array ($prop1);
        $entry1->propertyContent = $propCont;
        $feed->entries = array (
            $entry1,
        );
	    $writer = new AtomODataWriter('http://localhost/NorthWind.svc');
	    $result = $writer->write($feed);
	    $this->assertSame($writer, $result);
	    $actual = $writer->getOutput();
	    $expected = '<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom" xml:base="http://localhost/NorthWind.svc">
  <title type="text">Feed Title</title>
  <id>Feed Id</id>
  <updated>2013-09-17T19:22:33-06:00</updated>
  <link rel="Self Link Name" href="Self Link Url"/>
  <m:count>Count</m:count>
  <entry m:etag="Entry ETag">
    <id>Entry 1</id>
    <title type="text">Entry Title</title>
    <updated>2013-09-17T19:22:33-06:00</updated>
    <author>
      <name/>
    </author>
    <category term="" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
    <content type="application/xml">
      <m:properties>
        <d:name m:type="Bag(Name)">
          <d:element>
            <d:name>
              <d:fname m:type="string">Yash</d:fname>
              <d:lname m:type="string">Kothari</d:lname>
            </d:name>
            <d:name>
              <d:fname m:type="string">Yash</d:fname>
              <d:lname m:type="string">Kothari</d:lname>
            </d:name>
          </d:element>
        </d:name>
      </m:properties>
    </content>
  </entry>
  <link rel="Next" href="Next Link Url"/>
</feed>';
	    $this->assertXmlStringEqualsXmlString($this->removeUpdatedTags($expected), $this->removeUpdatedTags($actual));
    }
public function testWriteFeed ( ) { $ feed = new ODataFeed ( ) ; $ feed -> id = 'Feed Id' ; $ feed -> rowCount = 'Count' ; $ selfLink = new ODataLink ( ) ; $ selfLink -> name = " Self Link Name " ; $ selfLink -> tytle = " Self Link Title " ; $ selfLink -> type = " " ; $ selfLink -> url = " Self Link Url " ; $ feed -> selfLink = $ selfLink ; $ nextPageLink = new ODataLink ( ) ; $ nextPageLink -> name = " Next " ; $ nextPageLink -> tytle = " " ; $ nextPageLink -> type = " " ; $ nextPageLink -> url = " Next Link Url " ; $ feed -> nextPageLink = $ nextPageLink ; $ feed -> title = 'Feed Title' ; $ entry1 = new ODataEntry ( ) ; $ entry1 -> id = 'Entry 1' ; $ entry1 -> title = 'Entry Title' ; $ editLink = new ODataLink ( ) ; $ editLink -> name = " edit " ; $ editLink -> tytle = " Edit Link Title " ; $ editLink -> type = " Edit link type " ; $ editLink -> url = " Edit Link URL " ; $ entry1 -> editLink = $ editLink ; $ selfLink = new ODataLink ( ) ; $ selfLink -> name = " self " ; $ selfLink -> tytle = " self Link Title " ; $ selfLink -> type = " " ; $ selfLink -> url = " Self Link URL " ; $ entry1 -> selfLink = $ selfLink ; $ entry1 -> mediaLinks = array ( new ODataMediaLink ( 'Media Link Name' , 'Edit Media link' , 'Src Media Link' , 'Media Content Type' , 'Media ETag' ) ) ; $ link = new ODataLink ( ) ; $ link -> name = " Link Name " ; $ link -> tytle = " Link Title " ; $ link -> type = " Link Type " ; $ link -> url = " Link URL " ; $ entry1 -> links = array ( ) ; $ entry1 -> eTag = 'Entry ETag' ; $ link -> isExpanded = false ; $ entry1 -> isMediaLinkEntry = false ; $ bagProp1 = new ODataBagContent ( ) ; $ propCont1 = new ODataPropertyContent ( ) ; $ propCont1_1 = new ODataPropertyContent ( ) ; $ pr1 = new ODataProperty ( ) ; $ pr1 -> name = 'fname' ; $ pr1 -> typeName = 'string' ; $ pr1 -> value = 'Yash' ; $ pr2 = new ODataProperty ( ) ; $ pr2 -> name = 'lname' ; $ pr2 -> typeName = 'string' ; $ pr2 -> value = 'Kothari' ; $ propCont1_1 -> properties = array ( $ pr1 , $ pr2 ) ; $ propCont1_1_1 = new ODataPropertyContent ( ) ; $ pr3 = new ODataProperty ( ) ; $ pr3 -> name = 'fname' ; $ pr3 -> typeName = 'string' ; $ pr3 -> value = 'Anu' ; $ pr4 = new ODataProperty ( ) ; $ pr4 -> name = 'lname' ; $ pr4 -> typeName = 'string' ; $ pr4 -> value = 'Chandy' ; $ pr5 = new ODataProperty ( ) ; $ pr5 -> name = 'name' ; $ pr5 -> typeName = null ; $ pr5 -> value = $ propCont1_1 ; $ pr6 = new ODataProperty ( ) ; $ pr6 -> name = 'name' ; $ pr6 -> typeName = null ; $ pr6 -> value = $ propCont1_1 ; $ propCont1_1_1 -> properties = array ( $ pr3 , $ pr4 ) ; $ propCont1 -> properties = array ( $ pr5 , $ pr6 ) ; $ bagProp1 -> propertyContents = array ( $ propCont1 ) ; $ pr7 = new ODataProperty ( ) ; $ pr7 -> name = 'name' ; $ pr7 -> typeName = 'Bag(Name)' ; $ pr7 -> value = $ bagProp1 ; $ prop1 = $ pr7 ; $ propCont = new ODataPropertyContent ( ) ; $ propCont -> properties = array ( $ prop1 ) ; $ entry1 -> propertyContent = $ propCont ; $ feed -> entries = array ( $ entry1 , ) ; $ writer = new AtomODataWriter ( 'http://localhost/NorthWind.svc' ) ; $ result = $ writer -> write ( $ feed ) ; $ this -> assertSame ( $ writer , $ result ) ; $ actual = $ writer -> getOutput ( ) ; $ expected = '<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom" xml:base="http://localhost/NorthWind.svc">
  <title type="text">Feed Title</title>
  <id>Feed Id</id>
  <updated>2013-09-17T19:22:33-06:00</updated>
  <link rel="Self Link Name" href="Self Link Url"/>
  <m:count>Count</m:count>
  <entry m:etag="Entry ETag">
    <id>Entry 1</id>
    <title type="text">Entry Title</title>
    <updated>2013-09-17T19:22:33-06:00</updated>
    <author>
      <name/>
    </author>
    <category term="" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
    <content type="application/xml">
      <m:properties>
        <d:name m:type="Bag(Name)">
          <d:element>
            <d:name>
              <d:fname m:type="string">Yash</d:fname>
              <d:lname m:type="string">Kothari</d:lname>
            </d:name>
            <d:name>
              <d:fname m:type="string">Yash</d:fname>
              <d:lname m:type="string">Kothari</d:lname>
            </d:name>
          </d:element>
        </d:name>
      </m:properties>
    </content>
  </entry>
  <link rel="Next" href="Next Link Url"/>
</feed>' ; $ this -> assertXmlStringEqualsXmlString ( $ this -> removeUpdatedTags ( $ expected ) , $ this -> removeUpdatedTags ( $ actual ) ) ; }
Test for write top level feed item.
Test for write top level feed item .
// Entry 1