/** * Create one page with tow attachment, push it * pull it on wiki2 */ public function testSimple1() { // create page $this->assertTrue($this->p2pBot1->createPage($this->pageName, $this->content), 'Failed to create page ' . $this->pageName . ' (' . $this->p2pBot1->bot->results . ')'); // assert page Ours exist on wiki1 assertPageExist($this->p2pBot1->bot->wikiServer, $this->pageName); system("cp Import/Ours1.jpg cache/Ours1.jpg"); $file_size = filesize("cache/Ours1.jpg"); for ($i = 1; $i <= $this->nb; $i++) { $file = "cache/Ours" . $i . ".jpg"; // upload the file on wiki1 $this->assertTrue($this->p2pBot1->uploadFile($file, $this->file . $i . ".jpg", '0')); // test if the good file was upload on wiki1 $this->assertTrue($this->p2pBot1->getFileFeatures($this->file . $i . ".jpg", $file_size)); // edit File:Ours.jpg on wiki1 $this->assertTrue($this->p2pBot1->editPage($this->filePage . $i . ".jpg", $this->pushRequest), 'failed to edit page ' . $this->filePage . ' ( ' . $this->p2pBot1->bot->results . ' )'); // remove file system("mv cache/Ours" . $i . ".jpg cache/Ours" . ($i + 1) . ".jpg"); } system("rm cache/Ours*"); // create push on wiki1 $this->assertTrue($this->p2pBot1->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot1->bot->results . ')'); // push $this->assertTrue($this->p2pBot1->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki2 $this->assertTrue($this->p2pBot2->createPull($this->pullName, $this->wiki1, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot2->bot->results . ')'); // pull $this->assertTrue($this->p2pBot2->Pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot2->bot->results . ')'); $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $PatchonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]]', '-3FpatchID'); $PatchonWiki2 = arraytolower($PatchonWiki2); $this->assertEquals(count($PatchonWiki1), count($PatchonWiki2)); }
public function testAppendPage() { $pageName = "Lambach"; $content = 'content page Lambach [[Category:city1]]'; $this->p2pBot1->createPage($pageName, $content); assertPageExist($this->p2pBot1->bot->wikiServer, $pageName); $contentFound = getContentPage($this->p2pBot1->bot->wikiServer, $pageName); $this->assertEquals($content, $contentFound); $this->p2pBot1->editPage($pageName, "toto"); $content .= ' toto'; $contentFound = getContentPage($this->p2pBot1->bot->wikiServer, $pageName); $this->assertEquals($content, $contentFound); }
public function testMultiPull() { $pushName = 'PushCity11'; $pushContent = 'PushFeed: [[name::PushCity11]] [[hasSemanticQuery::-5B-5BCategory:city-5D-5D]] [[hasPushHead::ChangeSet:TestCS1Pull11]]'; $this->assertTrue($this->p2pBot1->createPage('PushFeed:' . $pushName, $pushContent), 'failed on create page pushCity (' . $this->p2pBot1->bot->results . ')'); $CSName = 'TestCS1Pull11'; $CSContent = '[[changeSetID::TestCS1Pull11]] [[inPushFeed::PushFeed:PushCity11]] [[previousChangeSet::none]] [[hasPatch::patch:Testpatch11]]'; $this->assertTrue($this->p2pBot1->createPage('ChangeSet:' . $CSName, $CSContent), 'failed on create page testCS1Pull (' . $this->p2pBot1->bot->results . ')'); $patchName = 'Testpatch11'; $patchContent = 'Patch: patchID: [[patchID::Patch:Testpatch11]] onPage: [[onPage::Pouxeux]] hasOperation: [[hasOperation::46c8a54b5793cea6e2de75cacbab89e31072;Insert;(31093912328563252139:0cd3731e772d2fe6bcdc48d53ce59543) ;Testline]] previous: [[previous::none]] [[siteID::id1]]'; $this->assertTrue($this->p2pBot1->createPage('Patch:' . $patchName, $patchContent), 'failed on create page testPatch1 (' . $this->p2pBot1->bot->results . ')'); $pushName = 'PushCity12'; $pushContent = 'PushFeed: [[name::PushCity12]] [[hasSemanticQuery::-5B-5BCategory:city-5D-5D]] [[hasPushHead::ChangeSet:TestCS1Pull12]]'; $this->assertTrue($this->p2pBot1->createPage('PushFeed:' . $pushName, $pushContent), 'failed on create page pushCity (' . $this->p2pBot1->bot->results . ')'); $CSName = 'TestCS1Pull12'; $CSContent = '[[changeSetID::TestCS1Pull12]] [[inPushFeed::PushFeed:pushCity12]] [[previousChangeSet::none]] [[hasPatch::Patch:Testpatch12]]'; $this->assertTrue($this->p2pBot1->createPage('ChangeSet:' . $CSName, $CSContent), 'failed on create page testCS1Pull (' . $this->p2pBot1->bot->results . ')'); $patchName = 'Testpatch12'; $patchContent = 'Patch: patchID: [[patchID::Patch:Testpatch12]] onPage: [[onPage::Pouxeux]] hasOperation: [[hasOperation::46c8a54b5793cea6e2de75cacbab89e31073;Insert;(21093912328563252139:0cd3731e772d2fe6bcdc48d53ce59543) ;testline]] previous: [[previous::none]] [[siteID::id1]]'; $this->assertTrue($this->p2pBot1->createPage('Patch:' . $patchName, $patchContent), 'failed on create page testPatch12 (' . $this->p2pBot1->bot->results . ')'); exec('rm ../cache/*'); $this->p2pBot2->bot->wikiConnected = false; $pullContent = '[[name::PullFeed:PullCityonWiki11]] [[pushFeedServer::' . $this->wiki1 . ']] [[pushFeedName::PushFeed:PushCity11]] [[hasPullHead::none]]'; $this->assertTrue($this->p2pBot2->createPage('PullFeed:pullCityonWiki11', $pullContent), 'failed on create pull (' . $this->p2pBot2->bot->results . ')'); $pullContent = '[[name::PullFeed:PullCityonWiki12]] [[pushFeedServer::' . $this->wiki1 . ']] [[pushFeedName::PushFeed:PushCity12]] [[hasPullHead::none]]'; $this->assertTrue($this->p2pBot2->createPage('PullFeed:pullCityonWiki12', $pullContent), 'failed on create pull (' . $this->p2pBot2->bot->results . ')'); // pull $array = array('PullFeed:PullCityonWiki11', 'PullFeed:PullCityonWiki12'); $this->assertTrue($this->p2pBot2->pull($array), 'error on pull (' . $this->p2pBot2->bot->results . ')'); assertPageExist($this->p2pBot2->bot->wikiServer, 'ChangeSet:TestCS1Pull11'); assertPageExist($this->p2pBot2->bot->wikiServer, 'Patch:Testpatch11'); assertPageExist($this->p2pBot2->bot->wikiServer, 'ChangeSet:TestCS1Pull12'); assertPageExist($this->p2pBot2->bot->wikiServer, 'Patch:Testpatch12'); }
/** * Create one page, push it * pull it on wiki2 and on wiki3 * modify the page on wiki2 and wiki3 * pull both on wiki1 * wiki1 must have the good page on local */ public function testSimple2() { $this->testSimple1(); // create pull on wiki2 $this->assertTrue($this->p2pBot2->createPull($this->pullName, $this->wiki1, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot2->bot->results . ')'); // pull $this->assertTrue($this->p2pBot2->Pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot2->bot->results . ')'); // assert page Ours exist on wiki2 assertPageExist($this->p2pBot2->bot->wikiServer, $this->pageName); // create pull on wiki3 $this->assertTrue($this->p2pBot3->createPull($this->pullName, $this->wiki1, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot3->bot->results . ')'); // pull $this->assertTrue($this->p2pBot3->Pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot3->bot->results . ')'); // assert page Ours exist on wiki3 assertPageExist($this->p2pBot3->bot->wikiServer, $this->pageName); $addContent2 = "Les caractéristiques communes des ours modernes\nsont un grand corps trapu et massif, un long museau,\nun pelage hirsutes, des pattes plantigrades à cinq griffes\nnon rétractiles, et une queue courte."; $this->assertTrue($this->p2pBot2->editPage($this->pageName, $addContent2), 'failed to edit page ' . $this->pageName); // create push on wiki2 $this->assertTrue($this->p2pBot2->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot2->bot->results . ')'); // push $this->assertTrue($this->p2pBot2->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); $addContent3 = "L'ours polaire est principalement carnivore\net le panda géant se nourrit presque exclusivement de bambou,\nles six autres espèces sont omnivores, leur alimentation variée\ncomprend essentiellement des plantes et des animaux."; $this->assertTrue($this->p2pBot3->editPage($this->pageName, $addContent3), 'failed to edit page ' . $this->pageName); // create push on wiki3 $this->assertTrue($this->p2pBot3->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot3->bot->results . ')'); // push $this->assertTrue($this->p2pBot3->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot3->bot->results . ')'); // create pull on wiki1 from wiki2 $this->assertTrue($this->p2pBot1->createPull($this->pullName . '2', $this->wiki2, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot1->bot->results . ')'); // pull $this->assertTrue($this->p2pBot1->Pull($this->pullFeed . '2'), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot1->bot->results . ')'); // create pull on wiki1 from wiki3 $this->assertTrue($this->p2pBot1->createPull($this->pullName . '3', $this->wiki3, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot1->bot->results . ')'); // pull $this->assertTrue($this->p2pBot1->Pull($this->pullFeed . '3'), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot1->bot->results . ')'); $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->pageName . ']]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $this->assertEquals(count($PatchonWiki1), 3); }
/** * Create one page with tow attachment, push it * pull it on wiki2 * modify the attachment on wiki2 , push it * pull it on wiki1 * the tow wiki must have the same page and attachment */ public function testSimple1() { // create page $this->assertTrue($this->p2pBot1->createPage($this->pageName, $this->content), 'Failed to create page ' . $this->pageName . ' (' . $this->p2pBot1->bot->results . ')'); // assert page Ours exist on wiki1 assertPageExist($this->p2pBot1->bot->wikiServer, $this->pageName); // upload the file on wiki1 $this->assertTrue($this->p2pBot1->uploadFile($this->fileDir . $this->file11, $this->file, '0')); // test if the good file was upload on wiki1 $this->assertTrue($this->p2pBot1->getFileFeatures($this->file, $this->file_size1)); // edit File:Ours.jpg on wiki1 $this->assertTrue($this->p2pBot1->editPage($this->filePage, $this->pushRequest), 'failed to edit page ' . $this->filePage . ' ( ' . $this->p2pBot1->bot->results . ' )'); // upload the second file on wiki1 $this->assertTrue($this->p2pBot1->uploadFile($this->fileDir . $this->file21, $this->file2, '0')); // test if the good file was upload on wiki1 $this->assertTrue($this->p2pBot1->getFileFeatures($this->file2, $this->file_size3)); // edit File:Ours.pdf on wiki1 $this->assertTrue($this->p2pBot1->editPage($this->filePage2, $this->pushRequest), 'failed to edit page ' . $this->filePage . ' ( ' . $this->p2pBot1->bot->results . ' )'); // create push on wiki1 $this->assertTrue($this->p2pBot1->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot1->bot->results . ')'); // push $this->assertTrue($this->p2pBot1->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki2 $this->assertTrue($this->p2pBot2->createPull($this->pullName, $this->wiki1, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot2->bot->results . ')'); // pull $this->assertTrue($this->p2pBot2->Pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot2->bot->results . ')'); // change file on wiki2 $this->assertTrue($this->p2pBot2->uploadFile($this->fileDir . $this->file12, $this->file, '1')); // test if the good file was upload on wiki2 $this->assertTrue($this->p2pBot2->getFileFeatures($this->file, $this->file_size2)); // change second file on wiki2 $this->assertTrue($this->p2pBot2->uploadFile($this->fileDir . $this->file22, $this->file2, '1')); // test if the good file was upload on wiki2 $this->assertTrue($this->p2pBot2->getFileFeatures($this->file2, $this->file_size4)); // create push on wiki2 $this->assertTrue($this->p2pBot2->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot2->bot->results . ')'); // push $this->assertTrue($this->p2pBot2->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki1 $this->assertTrue($this->p2pBot1->createPull($this->pullName, $this->wiki2, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot1->bot->results . ')'); // pull $this->assertTrue($this->p2pBot1->Pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot1->bot->results . ')'); // test if the good file was upload on wiki1 $this->assertTrue($this->p2pBot1->getFileFeatures($this->file, $this->file_size2)); // test if the good file was upload on wiki1 $this->assertTrue($this->p2pBot1->getFileFeatures($this->file2, $this->file_size4)); $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage . ']]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $PatchonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage . ']]', '-3FpatchID'); $PatchonWiki2 = arraytolower($PatchonWiki2); $this->assertEquals(count($PatchonWiki1), count($PatchonWiki2)); $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage2 . ']]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $PatchonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage2 . ']]', '-3FpatchID'); $PatchonWiki2 = arraytolower($PatchonWiki2); $this->assertEquals(count($PatchonWiki1), count($PatchonWiki2)); // assert that wiki1/File:Ours == wiki2/File:Ours assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $this->filePage); // assert that wiki1/File:Ours == wiki2/File:Ours assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $this->filePage2); }
public function test1() { // pages creation // Form:author $pageName = 'Form:Author'; $formauthor = '<noinclude> This is the "Author" form. To add a page with this form, enter the page name below; if a page with that name already exists, you will be sent to a form to edit that page. {{#forminput:Author}} </noinclude><includeonly> <div id="wikiPreview" style="display: none; border-bottom: 1px solid #AAAAAA;"></div> {{{for template|Author}}} {| class="formtable" ! Country: | {{{field|Country}}} |} {{{end template}}} \'\'\'Free text:\'\'\' {{{standard input|free text|rows=10}}} {{{standard input|summary}}} {{{standard input|minor edit}}} {{{standard input|watch}}} {{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}} </includeonly> [[Category:package]]'; $this->assertTrue($this->p2pBot1->createPage($pageName, $formauthor), 'Failed to create page ' . $pageName . ' (' . $this->p2pBot1->bot->results . ')'); // Form:book $pageName1 = 'Form:Book'; $formbook = '<noinclude> This is the "Book" form. To add a page with this form, enter the page name below; if a page with that name already exists, you will be sent to a form to edit that page. {{#forminput:Book}} </noinclude><includeonly> <div id="wikiPreview" style="display: none; border-bottom: 1px solid #AAAAAA;"></div> {{{for template|Book}}} {| class="formtable" ! Authors: | {{{field|Authors}}} |- ! Genres: | {{{field|Genres}}} |- ! Year: | {{{field|Year}}} |- ! Number of pages: | {{{field|Number of pages}}} |} {{{end template}}} \'\'\'Free text:\'\'\' {{{standard input|free text|rows=10}}} {{{standard input|summary}}} {{{standard input|minor edit}}} {{{standard input|watch}}} {{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}} </includeonly> [[Category:package]]'; $this->assertTrue($this->p2pBot1->createPage($pageName1, $formbook), 'Failed to create page ' . $pageName1 . ' (' . $this->p2pBot1->bot->results . ')'); // Property:Has genre $pageName2 = 'Property:Has_genre'; $hasgenre = 'This is a property of type [[Has type::String]]. The allowed values for this property are: * [[Allows value::Art]] * [[Allows value::Cookbook]] * [[Allows value::Fiction]] * [[Allows value::History]] * [[Allows value::Poetry]] * [[Allows value::Science]] [[Category:package]]'; $this->assertTrue($this->p2pBot1->createPage($pageName2, $hasgenre), 'Failed to create page ' . $pageName2 . ' (' . $this->p2pBot1->bot->results . ')'); // Property:Has number of pages $pageName3 = 'Property:Has_number_of_pages'; $nbpages = 'This is a property of type [[Has type::Number]]. [[Category:package]]'; $this->assertTrue($this->p2pBot1->createPage($pageName3, $nbpages), 'Failed to create page ' . $pageName3 . ' (' . $this->p2pBot1->bot->results . ')'); // Property:Is from country $pageName4 = 'Property:Is_from_country'; $isfromcountry = 'This is a property of type [[Has type::String]]. [[Category:package]]'; $this->assertTrue($this->p2pBot1->createPage($pageName4, $isfromcountry), 'Failed to create page ' . $pageName4 . ' (' . $this->p2pBot1->bot->results . ')'); // Property:Was published in year $pageName5 = 'Property:Was_published_in_year'; $pubyear = 'This is a property of type [[Has type::Number]]. [[Category:package]]'; $this->assertTrue($this->p2pBot1->createPage($pageName5, $pubyear), 'Failed to create page ' . $pageName5 . ' (' . $this->p2pBot1->bot->results . ')'); // Property:Was written by $pageName6 = 'Property:Was_written_by'; $written = 'This is a property of type [[Has type::Page]]. [[Category:package]] This property uses the form [[Has default form::Form:Author]].'; $this->assertTrue($this->p2pBot1->createPage($pageName6, $written), 'Failed to create page ' . $pageName6 . ' (' . $this->p2pBot1->bot->results . ')'); // Template:Book // $pageName7 = 'Template:Book'; // $tampBook = '<noinclude> // This is the "Book" template. // It should be called in the following format: // <pre> // {{Book // |Authors= // |Genres= // |Year= // |Number of pages= // }} // </pre> // Edit the page to see the template text. // </noinclude><includeonly> // {| class="wikitable" // ! Author(s) // | {{#arraymap:{{{Authors|}}}|,|x|[[Was written by::x]]}} // |- // ! Genre(s) // | {{#arraymap:{{{Genres|}}}|,|x|[[Has genre::x]]}} // |- // ! Year of publication // | [[Was published in year::{{{Year|}}}]] // |- // ! Number of pages // | [[Has number of pages::{{{Number of pages|}}}]] // |} // // [[Category:Books]] // </includeonly> // [[Category:package]] // '; // $this->assertTrue($this->p2pBot1->createPage($pageName7,$tampBook), // 'Failed to create page '.$pageName7.' ('.$this->p2pBot1->bot->results.')'); // // //Template:Author // $pageName8 = 'Template:Author'; // $tampAuthor = '<noinclude> // This is the "Author" template. // It should be called in the following format: // <pre> // {{Author // |Country= // }} // </pre> // Edit the page to see the template text. // </noinclude><includeonly> // {| class="wikitable" // ! Country of origin // | [[Is from country::{{{Country|}}}]] // |- // ! Books by this author // | {{#ask:[[Was written by::{{SUBJECTPAGENAME}}]]|format=list}} // |} // // [[Category:Authors]] // </includeonly> // [[Category:package]]'; // // $this->assertTrue($this->p2pBot1->createPage($pageName8,$tampAuthor), // 'Failed to create page '.$pageName8.' ('.$this->p2pBot1->bot->results.')'); // create push on wiki1 $pushName = 'PushPackage'; $pushRequest = '[[Category:package]]'; $this->assertTrue($this->p2pBot1->createPush($pushName, $pushRequest), 'Failed to create push : ' . $pushName . ' (' . $this->p2pBot1->bot->results . ')'); // push on wiki1 $this->assertTrue($this->p2pBot1->push('PushFeed:' . $pushName), 'failed to push ' . $pushName . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki2 $pullName = 'PullPackage'; $this->assertTrue($this->p2pBot2->createPull($pullName, $this->wiki1, $pushName), 'failed to create pull ' . $pullName . ' (' . $this->p2pBot2->bot->results . ')'); // pull $this->assertTrue($this->p2pBot2->Pull('PullFeed:' . $pullName), 'failed to pull ' . $pullName . ' (' . $this->p2pBot2->bot->results . ')'); // assert pages exist assertPageExist($this->p2pBot2->bot->wikiServer, $pageName); assertPageExist($this->p2pBot2->bot->wikiServer, $pageName1); assertPageExist($this->p2pBot2->bot->wikiServer, $pageName2); assertPageExist($this->p2pBot2->bot->wikiServer, $pageName3); assertPageExist($this->p2pBot2->bot->wikiServer, $pageName4); assertPageExist($this->p2pBot2->bot->wikiServer, $pageName5); assertPageExist($this->p2pBot2->bot->wikiServer, $pageName6); // assertPageExist($this->p2pBot2->bot->wikiServer, $pageName7); // assertPageExist($this->p2pBot2->bot->wikiServer, $pageName8); // assert that there is the same changeSet on the 2 wikis $CSonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[ChangeSet:+]]', '-3FchangeSetID'); $CSonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[ChangeSet:+]]', '-3FchangeSetID'); $this->assertEquals($CSonWiki1, $CSonWiki2, 'changeSet are not equals on the 2 wikis'); // assert that there is the same patch on the 2 wikis $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]]', '-3FpatchID'); $PatchonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $PatchonWiki2 = arraytolower($PatchonWiki2); $this->assertEquals($PatchonWiki1, $PatchonWiki2, 'patch are not equals on the 2 wikis'); // assert that wiki1/page == wiki2/page assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName1); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName2); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName3); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName4); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName5); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageName6); }
/** * execute criss cross merge W1|W2 1 2 - make change in 2 wiki |\/| |/\| 3==4 */ public function testSimple3() { // create page $this->assertTrue($this->p2pBot1->createPage($this->pageName, $this->content), 'Failed to create page ' . $this->pageName . ' (' . $this->p2pBot1->bot->results . ')'); // assert page Ours exist on wiki1 assertPageExist($this->p2pBot1->bot->wikiServer, $this->pageName); // create push on wiki1 $this->assertTrue($this->p2pBot1->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot1->bot->results . ')'); // push $this->assertTrue($this->p2pBot1->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create page $this->assertTrue($this->p2pBot2->createPage($this->pageName, $this->content), 'Failed to create page ' . $this->pageName . ' (' . $this->p2pBot2->bot->results . ')'); // assert page Ours exist on wiki2 assertPageExist($this->p2pBot2->bot->wikiServer, $this->pageName); // create push on wiki2 $this->assertTrue($this->p2pBot2->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot2->bot->results . ')'); // push $this->assertTrue($this->p2pBot2->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki2 $this->assertTrue($this->p2pBot2->createPull($this->pullName, $this->wiki1, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot2->bot->results . ')'); // pull $this->assertTrue($this->p2pBot2->pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki1 $this->assertTrue($this->p2pBot1->createPull($this->pullName, $this->wiki2, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot1->bot->results . ')'); // pull $this->assertTrue($this->p2pBot1->pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot1->bot->results . ')'); // assert that there is the same changeSet on the 2 wikis $CSonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[ChangeSet:+]][[inPushFeed::' . $this->pushFeed . ']]', '-3FchangeSetID'); $CSonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[ChangeSet:+]][[inPullFeed::' . $this->pullFeed . ']]', '-3FchangeSetID'); $this->assertEquals($CSonWiki1, $CSonWiki2, 'changeSet are not equals on the 2 wikis'); // assert that there is the same patch on the 2 wikis $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->pageName . ']]', '-3FpatchID'); $PatchonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->pageName . ']]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $PatchonWiki2 = arraytolower($PatchonWiki2); $this->assertEquals($PatchonWiki1, $PatchonWiki2, 'patch are not equals on the 2 wikis'); // assert that wiki1/File:Ours == wiki2/File:Ours assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $this->pageName); }
function testSimple4() { $this->testSimple2(); $countCSonWiki1 = count(getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]]', '-3FpatchID')); $countCSonWiki2 = count(getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]]', '-3FpatchID')); $pushName = 'PushCity10'; $pullName = 'pullCity'; $this->assertTrue($this->p2pBot1->push('PushFeed:' . $pushName), 'failed to push ' . $pushName . ' (' . $this->p2pBot1->bot->results . ')'); $this->assertTrue($this->p2pBot2->Pull('PullFeed:' . $pullName), 'failed to pull ' . $pullName . ' (' . $this->p2pBot2->bot->results . ')'); $countCS = count(getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]]', '-3FpatchID')); //assert no patch created $this->assertTrue($countCSonWiki2 == $countCS); // assert that wiki1/Category:Lambach == wiki2/Category:Lambach $contentWiki1 = getContentPage($this->p2pBot1->bot->wikiServer, 'Category:Lambach'); $contentWiki2 = getContentPage($this->p2pBot2->bot->wikiServer, 'Category:Lambach'); assertPageExist($this->p2pBot2->bot->wikiServer, 'Category:Lambach'); $this->assertEquals($contentWiki1, $contentWiki2, 'Failed content page Lambach'); //assert that there is the same changeSet on the 2 wikis $CSonWiki1 = count(getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[ChangeSet:+]]', '-3FchangeSetID')); $CSonWiki2 = count(getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[ChangeSet:+]]', '-3FchangeSetID')); $this->assertEquals($CSonWiki1, $CSonWiki2); //assert that there is the same patch on the 2 wikis $PatchonWiki1 = count(getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]]', '-3FpatchID')); $PatchonWiki2 = count(getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]]', '-3FpatchID')); $this->assertEquals($PatchonWiki1, $PatchonWiki2); }
/** * Create one page with an attachment, push it * pull it on wiki2 * wiki2 change the file, pull the page * wiki1 push the page and must have the new attachment on local */ public function testSimple4() { $this->testSimple3(); // change file on wiki2 $this->assertTrue($this->p2pBot2->uploadFile($this->fileDir . $this->file2, $this->file, '1')); $PatchonWiki1 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage . ']]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $this->assertEquals(count($PatchonWiki1), 3); // test si le fichier a été uploder sur le wiki2 $this->assertTrue($this->p2pBot2->getFileFeatures($this->file, $this->file_size2)); // create push on wiki2 $this->assertTrue($this->p2pBot2->createPush($this->pushName, $this->pushRequest), 'Failed to create push : ' . $this->pushName . ' (' . $this->p2pBot1->bot->results . ')'); // push $this->assertTrue($this->p2pBot2->push($this->pushFeed), 'failed to push ' . $this->pushFeed . ' (' . $this->p2pBot2->bot->results . ')'); // create pull on wiki1 from wiki2 $this->assertTrue($this->p2pBot1->createPull($this->pullName, $this->wiki2, $this->pushName), 'failed to create pull ' . $this->pullName . ' (' . $this->p2pBot1->bot->results . ')'); // pull $this->assertTrue($this->p2pBot1->Pull($this->pullFeed), 'failed to pull ' . $this->pullFeed . ' (' . $this->p2pBot1->bot->results . ')'); // test if the good file was upload on wiki1 from wiki2 $this->assertTrue($this->p2pBot1->getFileFeatures($this->file, $this->file_size2)); assertPageExist($this->p2pBot1->bot->wikiServer, $this->filePage); // assert that there is the same changeSet on the 2 wikis $CSonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[ChangeSet:+]][[inPullFeed::' . $this->pullFeed . ']]', '-3FchangeSetID'); $CSonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[ChangeSet:+]][[inPushFeed::' . $this->pushFeed . ']]', '-3FchangeSetID'); $this->assertEquals($CSonWiki1, $CSonWiki2, 'changeSet are not equals on the 2 wikis'); // assert that there is the same patch on the 2 wikis $PatchonWiki1 = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage . ']]', '-3FpatchID'); $PatchonWiki2 = getSemanticRequest($this->p2pBot2->bot->wikiServer, '[[Patch:+]][[onPage::' . $this->filePage . ']]', '-3FpatchID'); $PatchonWiki1 = arraytolower($PatchonWiki1); $PatchonWiki2 = arraytolower($PatchonWiki2); $this->assertEquals($PatchonWiki1, $PatchonWiki2, 'patch are not equals on the 2 wikis'); // assert that wiki1/File:Ours == wiki2/File:Ours assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $this->filePage); }
public function testPushWithChangeSet1() { $this->testCreatePush(); $this->assertTrue($this->p2pBot1->createPage('Arches', "content arches [[Category:titi]]", 'failed to create page Arches (' . $this->p2pBot1->bot->results . ')')); $this->assertTrue($this->p2pBot1->createPage('Paris11', 'content Paris11 [[Category:titi]]', 'failed to create page Paris11 (' . $this->p2pBot1->bot->results . ')')); $this->assertTrue($this->p2pBot1->push('PushFeed:PushCity11'), 'failed to push ' . $pushName . ' (' . $this->p2pBot1->bot->results . ')'); // assert that pushHead attribute is not null and the changeSet page exist $pushFound = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[name::PushFeed:PushCity11]]', '-3FhasPushHead'); $this->assertNotEquals('', $pushFound[0]); $CSIDFound = $pushFound[0]; assertPageExist($this->p2pBot1->bot->wikiServer, $CSIDFound); // assert the changeSet created is ok $CSFound = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[changeSetID::' . $CSIDFound . ']]', '-3FchangeSetID/-3FinPushFeed/-3FpreviousChangeSet/-3FhasPatch'); // assert inPushFeed $this->assertEquals(strtolower('PushFeed:PushCity11'), strtolower($CSFound[1]), 'failed to push PushCity11, ChangeSet push name must be PushFeed:' . $pushName . ' but ' . $CSFound[1] . ' was found'); // assert previousChangeSet $this->assertEquals('none', strtolower($CSFound[2]), 'failed to push PushCity11, ChangeSet previous must be None but ' . $CSFound[2] . ' was found'); $patchCS = explode(',', $CSFound[3]); $this->assertTrue(count($patchCS) == 2, 'failed to push PushCity11, ChangeSet must contains 2 patchs but ' . count($patchCS) . ' patchs were found'); // assert patchs contains in the changeSet is ok $lastPatchNancy = utils::getLastPatchId('Arches', $this->p2pBot1->bot->wikiServer); $lastPatchParis = utils::getLastPatchId('Paris11', $this->p2pBot1->bot->wikiServer); $assert1 = strtolower($lastPatchNancy) == strtolower($patchCS[0]) || strtolower($lastPatchNancy) == strtolower($patchCS[1]); $assert2 = strtolower($lastPatchParis) == strtolower($patchCS[0]) || strtolower($lastPatchParis) == strtolower($patchCS[1]); $this->assertTrue($assert1 && $assert2, 'failed to push ' . $pushName . ', wrong patch in changeSet'); }
public function testSimple() { // wiki1 = prof1 // wiki2 = prof2 // wiki3 = student // create page on wiki1 $pageNameLesson1 = 'Lesson1'; $this->assertTrue($this->p2pBot1->createPage($pageNameLesson1, 'Intro.... [[type::Lesson]][[forYear::2009]]'), 'Failed to create page Exercises1 (' . $this->p2pBot1->bot->results . ')'); $contentWiki1 = "test wiki1"; echo sleep(10); $this->p2pBot1->editPage($pageNameLesson1, $contentWiki1); $this->assertTrue($this->p2pBot1->createPage('Exercises1', 'content exercises1 [[forYear::2009]] [[type::Exercise]]'), 'Failed to create page Exercises1 (' . $this->p2pBot1->bot->results . ')'); $this->assertTrue($this->p2pBot1->createPage('Exam1', 'content exam1 [[forYear::2009]] [[type::Exam]]'), 'Failed to create page Exercises1 (' . $this->p2pBot1->bot->results . ')'); $pageContentLesson1 = getContentPage($this->p2pBot1->bot->wikiServer, $pageNameLesson1); // push on wiki1 for prof2, only the lesson $this->assertTrue($this->p2pBot1->createPush('Course1', '[[type::Lesson]][[forYear::2009]]'), 'Failed to create push : Course1 (' . $this->p2pBot1->bot->results . ')'); $this->assertTrue($this->p2pBot1->push('PushFeed:Course1'), 'failed to push ' . 'Course1' . ' (' . $this->p2pBot1->bot->results . ')'); // pull on wiki2 from prof1 push $this->assertTrue($this->p2pBot2->createPull('Prof1Course1', $this->p2pBot1->bot->wikiServer, 'Course1'), 'failed to create pull Prof1Course1 (' . $this->p2pBot2->bot->results . ')'); // sleep(10); $this->assertTrue($this->p2pBot2->Pull('PullFeed:Prof1Course1'), 'failed to pull Prof1Course1 (' . $this->p2pBot2->bot->results . ')'); assertPageExist($this->p2pBot2->bot->wikiServer, 'Lesson1'); assertContentEquals($this->p2pBot2->bot->wikiServer, $this->p2pBot1->bot->wikiServer, $pageNameLesson1); // edit page lesson1 on wiki2 $addContent1 = 'edition on wiki2'; $this->p2pBot2->editPage($pageNameLesson1, $addContent1); $pageContentLesson1 = getContentPage($this->p2pBot2->bot->wikiServer, $pageNameLesson1); // push on wiki2 for prof1 only the lesson $this->assertTrue($this->p2pBot2->createPush('Course1', '[[type::Lesson]][[forYear::2009]]'), 'Failed to create push : Course1 (' . $this->p2pBot2->bot->results . ')'); $this->assertTrue($this->p2pBot2->push('PushFeed:Course1'), 'failed to push S1Course1 (' . $this->p2pBot2->bot->results . ')'); // pull on wiki1 from prof2 push $this->assertTrue($this->p2pBot1->createPull('Prof2Course1', $this->p2pBot2->bot->wikiServer, 'Course1'), 'failed to create pull Prof2Course1 (' . $this->p2pBot1->bot->results . ')'); $this->assertTrue($this->p2pBot1->Pull('PullFeed:Prof2Course1'), 'failed to pull Prof2Course1 (' . $this->p2pBot1->bot->results . ')'); assertPageExist($this->p2pBot1->bot->wikiServer, 'Lesson1'); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot2->bot->wikiServer, $pageNameLesson1); // push on wiki1 for student, lessons and exercises $this->assertTrue($this->p2pBot1->createPush('S1Course1', '[[type::!Exam]][[forYear::2009]]'), 'Failed to create push : S1Course1 (' . $this->p2pBot1->bot->results . ')'); $this->assertTrue($this->p2pBot1->push('PushFeed:S1Course1'), 'failed to push S1Course1 (' . $this->p2pBot2->bot->results . ')'); // pull on wiki3 from prof1 $this->assertTrue($this->p2pBot3->createPull('Prof1Course1', $this->p2pBot1->bot->wikiServer, 'S1Course1'), 'failed to create pull Prof1Course1 (' . $this->p2pBot3->bot->results . ')'); $this->assertTrue($this->p2pBot3->Pull('PullFeed:Prof1Course1'), 'failed to pull Prof2Course1 (' . $this->p2pBot3->bot->results . ')'); assertPageExist($this->p2pBot3->bot->wikiServer, 'Lesson1'); assertContentEquals($this->p2pBot3->bot->wikiServer, $this->p2pBot1->bot->wikiServer, $pageNameLesson1); assertPageExist($this->p2pBot3->bot->wikiServer, 'Exercises1'); assertContentEquals($this->p2pBot3->bot->wikiServer, $this->p2pBot1->bot->wikiServer, 'Exercises1'); // edit page lesson1 on wiki3 // $this->p2pBot3->bot->wikiLogin(); $addContent = 'content from student'; $this->assertTrue($this->p2pBot3->editPage('Lesson1', $addContent), 'failed to edit page Lesson1'); $pageContentLesson1 = getContentPage($this->p2pBot3->bot->wikiServer, $pageNameLesson1); // push on wiki3 for prof1, lessons and exercises $this->assertTrue($this->p2pBot3->createPush('StudCourse1', '[[type::!Exam]][[forYear::2009]]'), 'failed to create push : StudCourse1 (' . $this->p2pBot3->bot->results . ')'); $this->assertTrue($this->p2pBot3->push('PushFeed:StudCourse1'), 'failed to push StudCourse1 (' . $this->p2pBot3->bot->results . ')'); // pull on wiki1 from student $this->assertTrue($this->p2pBot1->createPull('StudCourse1', $this->p2pBot3->bot->wikiServer, 'StudCourse1'), 'failed to create pull StudCourse1 (' . $this->p2pBot1->bot->results . ')'); $this->assertTrue($this->p2pBot1->Pull('PullFeed:StudCourse1'), 'failed to pull StudCourse1 (' . $this->p2pBot1->bot->results . ')'); assertContentEquals($this->p2pBot1->bot->wikiServer, $this->p2pBot3->bot->wikiServer, $pageNameLesson1); }