SyncTokenPropertyTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace Sabre\DAV;
  3. class SyncTokenPropertyTest extends \Sabre\DAVServerTest {
  4. /**
  5. * The assumption in these tests is that a PROPFIND is going on, and to
  6. * fetch the sync-token, the event handler is just able to use the existing
  7. * result.
  8. *
  9. * @dataProvider data
  10. */
  11. function testAlreadyThere1($name, $value) {
  12. $propFind = new PropFind('foo', [
  13. '{http://calendarserver.org/ns/}getctag',
  14. $name,
  15. ]);
  16. $propFind->set($name, $value);
  17. $corePlugin = new CorePlugin();
  18. $corePlugin->propFindLate($propFind, new SimpleCollection('hi'));
  19. $this->assertEquals("hello", $propFind->get('{http://calendarserver.org/ns/}getctag'));
  20. }
  21. /**
  22. * In these test-cases, the plugin is forced to do a local propfind to
  23. * fetch the items.
  24. *
  25. * @dataProvider data
  26. */
  27. function testRefetch($name, $value) {
  28. $this->server->tree = new Tree(
  29. new SimpleCollection('root', [
  30. new Mock\PropertiesCollection(
  31. 'foo',
  32. [],
  33. [$name => $value]
  34. )
  35. ])
  36. );
  37. $propFind = new PropFind('foo', [
  38. '{http://calendarserver.org/ns/}getctag',
  39. $name,
  40. ]);
  41. $corePlugin = $this->server->getPlugin('core');
  42. $corePlugin->propFindLate($propFind, new SimpleCollection('hi'));
  43. $this->assertEquals("hello", $propFind->get('{http://calendarserver.org/ns/}getctag'));
  44. }
  45. function testNoData() {
  46. $this->server->tree = new Tree(
  47. new SimpleCollection('root', [
  48. new Mock\PropertiesCollection(
  49. 'foo',
  50. [],
  51. []
  52. )
  53. ])
  54. );
  55. $propFind = new PropFind('foo', [
  56. '{http://calendarserver.org/ns/}getctag',
  57. ]);
  58. $corePlugin = $this->server->getPlugin('core');
  59. $corePlugin->propFindLate($propFind, new SimpleCollection('hi'));
  60. $this->assertNull($propFind->get('{http://calendarserver.org/ns/}getctag'));
  61. }
  62. function data() {
  63. return [
  64. [
  65. '{http://sabredav.org/ns}sync-token',
  66. "hello"
  67. ],
  68. [
  69. '{DAV:}sync-token',
  70. "hello"
  71. ],
  72. [
  73. '{DAV:}sync-token',
  74. new Xml\Property\Href(Sync\Plugin::SYNCTOKEN_PREFIX . "hello", false)
  75. ]
  76. ];
  77. }
  78. }