]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/atompub/atompub_test.php
partial stub file for atompub tests
[quix0rs-gnu-social.git] / tests / atompub / atompub_test.php
1 <?php
2
3 class AtomPubClient
4 {
5     /**
6      *
7      * @param string $url collection feed URL
8      * @param string $user auth username
9      * @param string $pass auth password
10      */
11     function __construct($url, $user, $pass)
12     {
13         $this->url = $url;
14         $this->user = $user;
15         $this->pass = $pass;
16     }
17
18     /**
19      * @param string $baseUrl to attempt feed discovery from
20      * @return AtomPubClient
21      */
22     static function discoverFromPage($baseUrl)
23     {
24         
25     }
26
27     function get()
28     {
29         
30     }
31     
32     function post($stuff, $type='application/atom+xml;type=entry')
33     {
34         // post it up!
35         // optional 'Slug' header too
36         // .. receive ..
37         if ($response->getStatus() == '201') {
38             // yay
39             // MUST have a "Location" header
40             // if it has a Content-Location header, it MUST match Location
41             //   and if it does, check the response body -- it should match what we posted, more or less.
42         } else {
43             throw new Exception("Expected HTTP 201 on POST, got " . $response->getStatus());
44         }
45     }
46
47     function put($data, $type='application/atom+xml;type=entry')
48     {
49         // PUT it up!
50         // must get a 200 back.
51         // unlike post, we don't get the location too.
52     }
53 }
54
55 // discover the feed...
56
57 // confirm the feed has edit links ..... ?
58
59 $pub = new AtomPubClient($url, $user, $pass);
60
61 // post!
62 $target = $pub->post($atom);
63
64 // make sure it's accessible
65 // fetch $target -- should give us the atom entry
66 //  edit URL should match
67
68 // refetch the feed; make sure the new entry is in there
69 //  edit URL should match
70
71 // try editing! it should fail.
72 try {
73     $target2 = $pub->put($target, $atom2);
74     // FAIL! this shouldn't work.
75 } catch (AtomPubPermissionDeniedException $e) {
76     // yay
77 }
78
79 // try deleting!
80 $pub->delete();
81
82 // fetch $target -- it should be gone now
83
84 // fetch the feed again; the new entry should be gone again
85
86
87
88
89
90 // make subscriptions
91 // make some posts
92 // make sure the posts go through or not depending on the subs
93 // remove subscriptions
94 // test that they don't go through now
95
96 // group memberships too
97
98
99
100
101 // make sure we can't post to someone else's feed!
102 // make sure we can't delete someone else's messages
103 // make sure we can't create/delete someone else's subscriptions
104 // make sure we can't create/delete someone else's group memberships
105