EntryTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @package Zend_Gdata_App
  16. * @subpackage UnitTests
  17. * @copyright Copyright (c) 2006-2008 Zend Technologies USA Inc. (http://www.zend.com);
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. require_once 'Zend/Gdata/App/Entry.php';
  21. require_once 'Zend/Gdata/App.php';
  22. require_once 'Zend/Gdata/TestUtility/MockHttpClient.php';
  23. require_once 'Zend/Gdata/HttpClient.php';
  24. /**
  25. * @package Zend_Gdata_App
  26. * @subpackage UnitTests
  27. */
  28. class Zend_Gdata_App_EntryTest extends PHPUnit_Framework_TestCase
  29. {
  30. public function setUp()
  31. {
  32. $this->enryText = file_get_contents(
  33. 'Zend/Gdata/App/_files/EntrySample1.xml',
  34. true);
  35. $this->httpEntrySample = file_get_contents(
  36. 'Zend/Gdata/App/_files/EntrySampleHttp1.txt',
  37. true);
  38. $this->enry = new Zend_Gdata_App_Entry();
  39. $this->adapter = new Test_Zend_Gdata_MockHttpClient();
  40. $this->client = new Zend_Gdata_HttpClient();
  41. $this->client->setAdapter($this->adapter);
  42. $this->service = new Zend_Gdata_App($this->client);
  43. }
  44. public function testEmptyEntryShouldHaveEmptyExtensionsList()
  45. {
  46. $this->assertTrue(is_array($this->enry->extensionElements));
  47. $this->assertTrue(count($this->enry->extensionElements) == 0);
  48. }
  49. public function testEmptyEntryToAndFromStringShouldMatch()
  50. {
  51. $enryXml = $this->enry->saveXML();
  52. $newEntry = new Zend_Gdata_App_Entry();
  53. $newEntry->transferFromXML($enryXml);
  54. $newEntryXml = $newEntry->saveXML();
  55. $this->assertTrue($enryXml == $newEntryXml);
  56. }
  57. public function testConvertEntryToAndFromString()
  58. {
  59. $this->enry->transferFromXML($this->enryText);
  60. $enryXml = $this->enry->saveXML();
  61. $newEntry = new Zend_Gdata_App_Entry();
  62. $newEntry->transferFromXML($enryXml);
  63. /*
  64. $this->assertEquals(1, count($newEntry->entry));
  65. $this->assertEquals('dive into mark', $newEntry->title->text);
  66. $this->assertEquals('text', $newEntry->title->type);
  67. $this->assertEquals('2005-07-31T12:29:29Z', $newEntry->updated->text);
  68. $this->assertEquals('tag:example.org,2003:3', $newEntry->id->text);
  69. $this->assertEquals(2, count($newEntry->link));
  70. $this->assertEquals('http://example.org/',
  71. $newEntry->getAlternateLink()->href);
  72. $this->assertEquals('en',
  73. $newEntry->getAlternateLink()->hrefLang);
  74. $this->assertEquals('text/html',
  75. $newEntry->getAlternateLink()->type);
  76. $this->assertEquals('http://example.org/enry.atom',
  77. $newEntry->getSelfLink()->href);
  78. $this->assertEquals('application/atom+xml',
  79. $newEntry->getSelfLink()->type);
  80. $this->assertEquals('Copyright (c) 2003, Mark Pilgrim',
  81. $newEntry->rights->text);
  82. $entry = $newEntry->entry[0];
  83. $this->assertEquals('Atom draft-07 snapshot', $entry->title->text);
  84. $this->assertEquals('tag:example.org,2003:3.2397',
  85. $entry->id->text);
  86. $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text);
  87. $this->assertEquals('2003-12-13T08:29:29-04:00',
  88. $entry->published->text);
  89. $this->assertEquals('Mark Pilgrim',
  90. $entry->author[0]->name->text);
  91. $this->assertEquals('http://example.org/',
  92. $entry->author[0]->uri->text);
  93. $this->assertEquals(2, count($entry->contributor));
  94. $this->assertEquals('Sam Ruby',
  95. $entry->contributor[0]->name->text);
  96. $this->assertEquals('Joe Gregorio',
  97. $entry->contributor[1]->name->text);
  98. $this->assertEquals('xhtml', $entry->content->type);
  99. */
  100. }
  101. public function testCanSetAndGetEtag()
  102. {
  103. $data = "W/&amp;FooBarBaz&amp;";
  104. $this->enry->setEtag($data);
  105. $this->assertEquals($this->enry->getEtag(), $data);
  106. }
  107. public function testCanSetAndgetService()
  108. {
  109. $data = new Zend_Gdata_App();
  110. $this->enry->setService($data);
  111. $this->assertEquals($this->enry->getService(), $data);
  112. $data = null;
  113. $this->enry->setService($data);
  114. $this->assertEquals($this->enry->getService(), $data);
  115. }
  116. public function testsetServiceProvidesFluentInterface()
  117. {
  118. $result = $this->enry->setService(null);
  119. $this->assertEquals($this->enry, $result);
  120. }
  121. public function testGetHttpClientPullsFromServiceInstance()
  122. {
  123. $s = new Zend_Gdata_App();
  124. $this->enry->setService($s);
  125. $c = new Zend_Gdata_HttpClient();
  126. $s->setHttpClient($c);
  127. $this->assertEquals($this->enry->getHttpClient(),
  128. $s->getHttpClient());
  129. $c = new Zend_Http_Client();
  130. $s->setHttpClient($c);
  131. $this->assertEquals($this->enry->getHttpClient(),
  132. $s->getHttpClient($c));
  133. }
  134. public function testSetHttpClientPushesIntoServiceInstance()
  135. {
  136. $s = new Zend_Gdata_App();
  137. $this->enry->setService($s);
  138. $c = new Zend_Gdata_HttpClient();
  139. $this->enry->setHttpClient($c);
  140. $this->assertEquals(get_class($s->getHttpClient()),
  141. 'Zend_Gdata_HttpClient');
  142. $c = new Zend_Http_Client();
  143. $this->enry->setHttpClient($c);
  144. $this->assertEquals(get_class($s->getHttpClient()),
  145. 'Zend_Http_Client');
  146. }
  147. public function testSaveSupportsGdataV2()
  148. {
  149. // Prepare mock response
  150. $this->adapter->setResponse("HTTP/1.1 201 Created");
  151. // Make sure that we're using protocol v2
  152. $this->service->setMajorProtocolVersion(2);
  153. $this->enry->setService($this->service);
  154. // Set a URL for posting, so that save() will work
  155. $editLink = new Zend_Gdata_App_extension_Link('http://example.com',
  156. 'edit');
  157. $this->enry->setLink(array($editLink));
  158. // Perform a (mock) save
  159. $this->enry->save();
  160. // Check to make sure that a v2 header was sent
  161. $headers = $this->adapter->popRequest()->headers;
  162. $found = false;
  163. foreach ($headers as $header) {
  164. if ($header == 'GData-Version: 2')
  165. $found = true;
  166. }
  167. $this->assertTrue($found,
  168. 'GData-Version header missing or incorrect.');
  169. }
  170. public function testDeleteSupportsGdataV2()
  171. {
  172. // Prepare mock response
  173. $this->adapter->setResponse("HTTP/1.1 200 OK");
  174. // Make sure that we're using protocol v2
  175. $this->service->setMajorProtocolVersion(2);
  176. $this->enry->setService($this->service);
  177. // Set a URL for posting, so that save() will work
  178. $editLink = new Zend_Gdata_App_extension_Link('http://example.com',
  179. 'edit');
  180. $this->enry->setLink(array($editLink));
  181. // Perform a (mock) save
  182. $this->enry->delete();
  183. // Check to make sure that a v2 header was sent
  184. $headers = $this->adapter->popRequest()->headers;
  185. $found = false;
  186. foreach ($headers as $header) {
  187. if ($header == 'GData-Version: 2')
  188. $found = true;
  189. }
  190. $this->assertTrue($found,
  191. 'GData-Version header missing or incorrect.');
  192. }
  193. public function testIfMatchHeaderCanBeSetOnSave()
  194. {
  195. $etagOverride = 'foo';
  196. $etag = 'ABCD1234';
  197. $this->service->setMajorProtocolVersion(2);
  198. $this->adapter->setResponse($this->httpEntrySample);
  199. $entry = $this->service->newEntry();
  200. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  201. 'http://www.example.com',
  202. 'edit',
  203. 'application/atom+xml'));
  204. $entry->setEtag($etag);
  205. $newEntry = $entry->save(null, null,
  206. array('If-Match' => $etagOverride));
  207. $headers = $this->adapter->popRequest()->headers;
  208. $found = false;
  209. foreach ($headers as $header) {
  210. if ($header == 'If-Match: ' . $etagOverride)
  211. $found = true;
  212. }
  213. $this->assertTrue($found,
  214. 'If-Match header not found or incorrect');
  215. }
  216. public function testIfNoneMatchHeaderCanBeSetOnSave()
  217. {
  218. $etagOverride = 'foo';
  219. $etag = 'ABCD1234';
  220. $this->service->setMajorProtocolVersion(2);
  221. $this->adapter->setResponse($this->httpEntrySample);
  222. $entry = $this->service->newEntry();
  223. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  224. 'http://www.example.com',
  225. 'edit',
  226. 'application/atom+xml'));
  227. $entry->setEtag($etag);
  228. $newEntry = $entry->save(null, null,
  229. array('If-None-Match' => $etagOverride));
  230. $headers = $this->adapter->popRequest()->headers;
  231. $found = false;
  232. foreach ($headers as $header) {
  233. if ($header == 'If-None-Match: ' . $etagOverride)
  234. $found = true;
  235. }
  236. $this->assertTrue($found,
  237. 'If-None-Match header not found or incorrect');
  238. }
  239. public function testCanSetUriOnSave()
  240. {
  241. $uri = 'http://example.net/foo/bar';
  242. $this->adapter->setResponse($this->httpEntrySample);
  243. $entry = $this->service->newEntry();
  244. $newEntry = $entry->save($uri);
  245. $request = $this->adapter->popRequest();
  246. $uriObject = Zend_Uri_Http::fromString($uri);
  247. $uriObject->setPort('80');
  248. $this->assertEquals($uriObject, $request->uri);
  249. }
  250. public function testCanSetClassnameOnSave()
  251. {
  252. $className = 'Zend_Gdata_Entry';
  253. $this->adapter->setResponse($this->httpEntrySample);
  254. $entry = $this->service->newEntry();
  255. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  256. 'http://www.example.com',
  257. 'edit',
  258. 'application/atom+xml'));
  259. $newEntry = $entry->save(null, $className);
  260. $this->assertEquals($className, get_class($newEntry));
  261. }
  262. public function testIfNoneMatchSetOnReload()
  263. {
  264. $etag = 'ABCD1234';
  265. $this->adapter->setResponse($this->httpEntrySample);
  266. $entry = $this->service->newEntry();
  267. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  268. 'http://www.example.com',
  269. 'edit',
  270. 'application/atom+xml'));
  271. $entry->setEtag($etag);
  272. $newEntry = $entry->reload();
  273. $headers = $this->adapter->popRequest()->headers;
  274. $found = false;
  275. foreach ($headers as $header) {
  276. if ($header == 'If-None-Match: ' . $etag)
  277. $found = true;
  278. }
  279. $this->assertTrue($found,
  280. 'If-None-Match header not found or incorrect');
  281. }
  282. public function testIfNoneMatchCanBeSetOnReload()
  283. {
  284. $etagOverride = 'foo';
  285. $etag = 'ABCD1234';
  286. $this->adapter->setResponse($this->httpEntrySample);
  287. $entry = $this->service->newEntry();
  288. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  289. 'http://www.example.com',
  290. 'edit',
  291. 'application/atom+xml'));
  292. $entry->setEtag($etag);
  293. $newEntry = $entry->reload(null, null,
  294. array('If-None-Match' => $etagOverride));
  295. $headers = $this->adapter->popRequest()->headers;
  296. $found = false;
  297. foreach ($headers as $header) {
  298. if ($header == 'If-None-Match: ' . $etagOverride)
  299. $found = true;
  300. }
  301. $this->assertTrue($found,
  302. 'If-None-Match header not found or incorrect');
  303. }
  304. public function testReloadReturnsEntryObject()
  305. {
  306. $etag = 'ABCD1234';
  307. $this->adapter->setResponse($this->httpEntrySample);
  308. $entry = $this->service->newEntry();
  309. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  310. 'http://www.example.com',
  311. 'edit',
  312. 'application/atom+xml'));
  313. $entry->setEtag($etag);
  314. $newEntry = $entry->reload();
  315. $this->assertEquals('Zend_Gdata_App_Entry', get_class($newEntry));
  316. }
  317. public function testReloadPopulatesEntryObject()
  318. {
  319. $etag = 'ABCD1234';
  320. $this->adapter->setResponse($this->httpEntrySample);
  321. $entry = $this->service->newEntry();
  322. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  323. 'http://www.example.com',
  324. 'edit',
  325. 'application/atom+xml'));
  326. $entry->setEtag($etag);
  327. $newEntry = $entry->reload();
  328. $this->assertEquals('Hello world', $newEntry->title->text);
  329. }
  330. public function testReloadDoesntThrowExceptionIfNoEtag()
  331. {
  332. $this->adapter->setResponse($this->httpEntrySample);
  333. $entry = $this->service->newEntry();
  334. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  335. 'http://www.example.com',
  336. 'edit',
  337. 'application/atom+xml'));
  338. $newEntry = $entry->reload();
  339. $this->assertEquals('Zend_Gdata_App_Entry', get_class($newEntry));
  340. }
  341. public function testReloadExtractsURIFromEditLink()
  342. {
  343. $expectedUri = 'http://www.example.com';
  344. $etag = 'ABCD1234';
  345. $this->service->setMajorProtocolVersion(2);
  346. $this->adapter->setResponse($this->httpEntrySample);
  347. $entry = $this->service->newEntry();
  348. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  349. $expectedUri,
  350. 'edit',
  351. 'application/atom+xml'));
  352. $entry->setEtag($etag);
  353. $newEntry = $entry->reload();
  354. $requestUri = $this->adapter->popRequest()->uri;
  355. $expectedUriObject = Zend_Uri_Http::fromString($expectedUri);
  356. $expectedUriObject->setPort('80');
  357. $this->assertEquals($expectedUriObject, $requestUri);
  358. }
  359. public function testReloadAllowsCustomURI()
  360. {
  361. $uriOverride = 'http://www.example.org';
  362. $etag = 'ABCD1234';
  363. $this->service->setMajorProtocolVersion(2);
  364. $this->adapter->setResponse($this->httpEntrySample);
  365. $entry = $this->service->newEntry();
  366. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  367. 'http://www.example.com',
  368. 'edit',
  369. 'application/atom+xml'));
  370. $entry->setEtag($etag);
  371. $newEntry = $entry->reload($uriOverride);
  372. $requestUri = $this->adapter->popRequest()->uri;
  373. $uriOverrideObject = Zend_Uri_Http::fromString($uriOverride);
  374. $uriOverrideObject->setPort('80');
  375. $this->assertEquals($uriOverrideObject, $requestUri);
  376. }
  377. public function testReloadReturnsNullIfEntryNotModified()
  378. {
  379. $etag = 'ABCD1234';
  380. $this->service->setMajorProtocolVersion(2);
  381. $this->adapter->setResponse('HTTP/1.1 304 Not Modified');
  382. $entry = $this->service->newEntry();
  383. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  384. 'http://www.example.com',
  385. 'edit',
  386. 'application/atom+xml'));
  387. $entry->setEtag($etag);
  388. $newEntry = $entry->reload();
  389. $this->assertEquals(null, $newEntry);
  390. }
  391. public function testCanSetReloadReturnClassname()
  392. {
  393. $className = 'Zend_Gdata_Entry';
  394. $etag = 'ABCD1234';
  395. $this->service->setMajorProtocolVersion(2);
  396. $this->adapter->setResponse($this->httpEntrySample);
  397. $entry = $this->service->newEntry();
  398. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  399. 'http://www.example.com',
  400. 'edit',
  401. 'application/atom+xml'));
  402. $entry->setEtag($etag);
  403. $newEntry = $entry->reload(null, $className);
  404. $this->assertEquals($className, get_class($newEntry));
  405. }
  406. public function testReloadInheritsClassname()
  407. {
  408. $className = 'Zend_Gdata_Entry';
  409. $etag = 'ABCD1234';
  410. $this->service->setMajorProtocolVersion(2);
  411. $this->adapter->setResponse($this->httpEntrySample);
  412. $entry = new $className;
  413. $entry->setService($this->service);
  414. $entry->link = array(new Zend_Gdata_App_Extension_Link(
  415. 'http://www.example.com',
  416. 'edit',
  417. 'application/atom+xml'));
  418. $entry->setEtag($etag);
  419. $newEntry = $entry->reload();
  420. $this->assertEquals($className, get_class($newEntry));
  421. }
  422. public function testCanSetMajorProtocolVersion()
  423. {
  424. $expectedVersion = 42;
  425. $entry = $this->service->newEntry();
  426. $entry->setMajorProtocolVersion($expectedVersion);
  427. $receivedVersion = $entry->getMajorProtocolVersion();
  428. $this->assertEquals($expectedVersion, $receivedVersion);
  429. }
  430. public function testCanSetMinorProtocolVersion()
  431. {
  432. $expectedVersion = 42;
  433. $entry = $this->service->newEntry();
  434. $entry->setMinorProtocolVersion($expectedVersion);
  435. $receivedVersion = $entry->getMinorProtocolVersion();
  436. $this->assertEquals($expectedVersion, $receivedVersion);
  437. }
  438. public function testMajorProtocolVersionCannotBeZero()
  439. {
  440. $expectedVersion = 0;
  441. $entry = $this->service->newEntry();
  442. $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException');
  443. $entry->setMajorProtocolVersion($expectedVersion);
  444. }
  445. public function testMajorProtocolVersionCannotBeNegative()
  446. {
  447. $expectedVersion = -1;
  448. $entry = $this->service->newEntry();
  449. $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException');
  450. $entry->setMajorProtocolVersion($expectedVersion);
  451. }
  452. public function testMajorProtocolVersionMayBeNull()
  453. {
  454. $expectedVersion = null;
  455. $entry = $this->service->newEntry();
  456. $entry->setMajorProtocolVersion($expectedVersion);
  457. $receivedVersion = $entry->getMajorProtocolVersion();
  458. $this->assertNull($receivedVersion);
  459. }
  460. public function testMinorProtocolVersionMayBeZero()
  461. {
  462. $expectedVersion = 0;
  463. $entry = $this->service->newEntry();
  464. $entry->setMinorProtocolVersion($expectedVersion);
  465. $receivedVersion = $entry->getMinorProtocolVersion();
  466. $this->assertEquals($expectedVersion, $receivedVersion);
  467. }
  468. public function testMinorProtocolVersionCannotBeNegative()
  469. {
  470. $expectedVersion = -1;
  471. $entry = $this->service->newEntry();
  472. $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException');
  473. $entry->setMinorProtocolVersion($expectedVersion);
  474. }
  475. public function testMinorProtocolVersionMayBeNull()
  476. {
  477. $expectedVersion = null;
  478. $entry = $this->service->newEntry();
  479. $entry->setMinorProtocolVersion($expectedVersion);
  480. $receivedVersion = $entry->getMinorProtocolVersion();
  481. $this->assertNull($receivedVersion);
  482. }
  483. public function testDefaultMajorProtocolVersionIs1()
  484. {
  485. $entry = $this->service->newEntry();
  486. $this->assertEquals(1, $entry->getMajorProtocolVersion());
  487. }
  488. public function testDefaultMinorProtocolVersionIsNull()
  489. {
  490. $entry = $this->service->newEntry();
  491. $this->assertNull($entry->getMinorProtocolVersion());
  492. }
  493. public function testLookupNamespaceUsesCurrentVersion()
  494. {
  495. $prefix = 'test';
  496. $v1TestString = 'TEST-v1';
  497. $v2TestString = 'TEST-v2';
  498. Zend_Gdata_App_Base::flushNamespaceLookupCache();
  499. $entry = $this->service->newEntry();
  500. $entry->registerNamespace($prefix, $v1TestString, 1, 0);
  501. $entry->registerNamespace($prefix, $v2TestString, 2, 0);
  502. $entry->setMajorProtocolVersion(1);
  503. $result = $entry->lookupNamespace($prefix);
  504. $this->assertEquals($v1TestString, $result);
  505. $entry->setMajorProtocolVersion(2);
  506. $result = $entry->lookupNamespace($prefix);
  507. $this->assertEquals($v2TestString, $result);
  508. $entry->setMajorProtocolVersion(null); // Should default to latest
  509. $result = $entry->lookupNamespace($prefix);
  510. $this->assertEquals($v2TestString, $result);
  511. }
  512. public function testLookupNamespaceObeysParentBehavior()
  513. {
  514. $prefix = 'test';
  515. $testString10 = 'TEST-v1-0';
  516. $testString20 = 'TEST-v2-0';
  517. $testString11 = 'TEST-v1-1';
  518. $testString21 = 'TEST-v2-1';
  519. $testString12 = 'TEST-v1-2';
  520. $testString22 = 'TEST-v2-2';
  521. Zend_Gdata_App_Base::flushNamespaceLookupCache();
  522. $entry = $this->service->newEntry();
  523. $entry->registerNamespace($prefix, $testString10, 1, 0);
  524. $entry->registerNamespace($prefix, $testString20, 2, 0);
  525. $entry->registerNamespace($prefix, $testString11, 1, 1);
  526. $entry->registerNamespace($prefix, $testString21, 2, 1);
  527. $entry->registerNamespace($prefix, $testString12, 1, 2);
  528. $entry->registerNamespace($prefix, $testString22, 2, 2);
  529. // Assumes default version (1)
  530. $result = $entry->lookupNamespace($prefix, 1, null);
  531. $this->assertEquals($testString12, $result);
  532. $result = $entry->lookupNamespace($prefix, 2, null);
  533. $this->assertEquals($testString22, $result);
  534. $result = $entry->lookupNamespace($prefix, 1, 1);
  535. $this->assertEquals($testString11, $result);
  536. $result = $entry->lookupNamespace($prefix, 2, 1);
  537. $this->assertEquals($testString21, $result);
  538. $result = $entry->lookupNamespace($prefix, null, null);
  539. $this->assertEquals($testString12, $result);
  540. $result = $entry->lookupNamespace($prefix, null, 1);
  541. $this->assertEquals($testString11, $result);
  542. // Override to retrieve latest version
  543. $entry->setMajorProtocolVersion(null);
  544. $result = $entry->lookupNamespace($prefix, null, null);
  545. $this->assertEquals($testString22, $result);
  546. $result = $entry->lookupNamespace($prefix, null, 1);
  547. $this->assertEquals($testString21, $result);
  548. }
  549. }