setMaximumRedirects(0); } function TestCreateEntries() { $this->helper = new AtomTestHelper(); } function testCreateEntry() { $contents = << <![CDATA[Hello world!]]> EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertTitle('TEXT','Hello world!'); $this->delete($location); $this->assertResponse(200); } function testCreateEntryI18N() { $contents = << Japan Times社へのテクノラティウィジェット提供について tag:www.technorati.jp,2007:/weblog//2.867 テクノラティジャパンのウィジェットをJapan Times社に提供を開始しました... Japan Times社に提供を開始しました。 全ての記事の右側部分にテクノラティジャパンのウィジェットが掲載されています。 このウィジェットにより、Japan Timesのどの記事に ブロガーがもっともよくリンクしているのか、 ブロガーの間でのJapan Timesの記事のランキングを見ることができます。 是非お試しください。 JT%EF%BC%91.png JT%EF%BC%92.png ]]> EOD; $title = "Japan Times社へのテクノラティウィジェット提供について"; $this->post($this->helper->get_posts_url(), asciiToUtf8($contents)); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertTitle('TEXT',asciiToUtf8($title)); $this->delete($location); $this->assertResponse(200); } function testCreateEntryWithHTMLinText() { $contents = << <![CDATA[Hello < world!]]> EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertTitle('TEXT', 'Hello < world!'); $this->delete($location); $this->assertResponse(200); } /* Testing that tags are stripped from HTML title and that HTML summary is maintained. */ function testCreateEntryWithHTML() { $contents = << <![CDATA[Hello <b>world!</b>]]> first post. Edit or delete it, then start blogging!]]> EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertTitle('TEXT','Hello world!'); $this->assertSummary('HTML','Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'); $this->delete($location); $this->assertResponse(200); } function testCreateEntryWithXHTML() { $contents = << <![CDATA[Hello <b>world!</b>]]> first post. Edit or delete it, then start blogging!]]>

Hello World

EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->delete($location); $this->assertResponse(200); } function testCreateEntryWithPublishTime() { $contents = << <![CDATA[Hello <b>world!</b>]]> 2017-06-15T12:00:12-06:00 first post. Edit or delete it, then start blogging!]]>

Hello World

EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->assertEqual("2017-06-15T18:00:12Z", $this->get_first_entry()->published); $this->delete($location); $this->assertResponse(200); } function testCreateEntryWithBadPublishTime() { $contents = << <![CDATA[Hello <b>world!</b>]]> 2017-06-15 12:00:12-0600 first post. Edit or delete it, then start blogging!]]>

Hello World

EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->assertNotEqual("2017-06-15T18:00:12Z", $this->get_first_entry()->published); $this->delete($location); $this->assertResponse(200); } function testPut() { $contents = << <![CDATA[Hello <b>world!</b>]]> first post. Edit or delete it, then start blogging!]]>

Hello World

EOD; $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->assertSummary('HTML', 'Welcome to REPLACE_WITH_FOO first post. Edit or delete it, then start blogging!'); $edited_content = $this->getBrowser()->getContent(); $this->put($location, ereg_replace('REPLACE_WITH_FOO','FOO',$edited_content)); $this->assertResponse(200); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->assertSummary('HTML', 'Welcome to FOO first post. Edit or delete it, then start blogging!'); $this->delete($location); $this->assertResponse(200); } function testDraft() { $contents = << <![CDATA[Hello <b>world!</b>]]> yes first post. Edit or delete it, then start blogging!]]>

Hello World

EOD; // initial post (draft) $this->post($this->helper->get_posts_url(), $contents); $this->assertResponse(401); $this->authenticate($this->helper->get_user(), $this->helper->get_password()); $this->assertResponse(201); $this->assertHeader('Location'); // get entry (and make sure is draft) $location = $this->helper->get_header($this->getBrowser()->getHeaders(), 'Location'); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertDraft(); $this->assertContent('HTML', '

Hello World

'); $this->assertSummary('HTML', 'Welcome to REPLACE_WITH_FOO first post. Edit or delete it, then start blogging!'); $edited_content = $this->getBrowser()->getContent(); // update content (hacky I know) $edited_content = ereg_replace('REPLACE_WITH_FOO','FOO',$edited_content); $edited_content = ereg_replace('yes','no',$edited_content); // put (publish, not draft) $this->put($location, $edited_content); $this->assertResponse(200); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->assertSummary('HTML', 'Welcome to FOO first post. Edit or delete it, then start blogging!'); $this->assertNotDraft(); // let's try to undo and make draft again $edited_content = $this->getBrowser()->getContent(); $edited_content = ereg_replace('no','yes',$edited_content); $this->put($location, $edited_content); $this->assertResponse(200); $this->get($location); $this->assertResponse(200); $this->assertHeader('Content-Type',$this->helper->get_atom_content_type()); $this->assertEntry(); $this->assertContent('HTML', '

Hello World

'); $this->assertSummary('HTML', 'Welcome to FOO first post. Edit or delete it, then start blogging!'); // sorry, once the world knows, it knows. $this->assertNotDraft(); $this->delete($location); $this->assertResponse(200); } } ?>