-
Notifications
You must be signed in to change notification settings - Fork 138
[WIP] Content creation #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
ee721cd
add phpstorm configuration to gitignore
adou600 13e6531
WIP: creation of pages from the menu, not working yet
adou600 12d3d3a
WIP remove unnecessary composer require
adou600 56fe68f
Merge branch 'master' into content-creation
adou600 c600811
WIP creation of news with CreateJS
adou600 1b08fa4
fix the tests: there is a new entry in the menu
adou600 1d6213c
WIP test for the news system
adou600 10fc0c0
dirty hack to hide duplicate +Add buttons on content creation
adou600 19caf1b
use the configuration to define plain text types instead of custom sc…
adou600 76451db
update dependencies
adou600 fead397
finalize the RSS feed for the news list
adou600 5d581db
get the created entity subject in JS
adou600 5cea08a
merge master and update dependencies
adou600 a7692c4
temporary CSS hack to hide multiple add buttons
adou600 b71ebde
WIP functional backend route creation
adou600 f8ed1f5
move CmfRoute to the CreateBundle
adou600 e472a33
list of rdf types for which to create routes
adou600 572b512
update dependencies to add saucelabs testing, with corresponding smal…
adou600 deba370
merge master
adou600 75e82dc
WIP - first experiments with Saucelabs frontend testing
adou600 231bfb8
fix test refactoring to work with Sauce base class
adou600 c2bc237
load fixtures for Sauce test cases
adou600 c556fa9
do not run the sauce tests by default
adou600 048afab
load fixtures for sauce tests through a FixtureLoader class
adou600 95af512
WIP news creation with saucelabs
adou600 aaa1634
news creation test finalization with saucelabs
adou600 43cdb1d
write today when creating a news instead of the first creation date
adou600 47c0573
saucelabs tests refactoring and stabilization
adou600 5b6b03b
documentation how to setup the saucelabs tests
adou600 b5f763d
documentation formatting
adou600 c4a5295
various formatting fixes
adou600 001cfd5
update dependencies and sauce tests after fix in phpunit-selenium
adou600 941288a
merge master
adou600 844160e
remove css hack for multiple add buttons
adou600 7f0155f
composer update with --prefer-source on
adou600 5ce5657
new test case about simultaneous content creation and update
adou600 9437599
config changes to handle configurable rdfmapper
adou600 0db69bf
config update after createphp RdfTypeFactory refactoring
adou600 4666954
fix test after error handling improvement for route creation
adou600 9398e9d
remove elements linked to creation from the menu, not ready nor usabl…
adou600 4a7abd2
extract repeated methods in saucelabs tests
adou600 f3aa8db
WIP translated news
adou600 50e809d
finalization of the localizable news system
adou600 88124ff
merge master
adou600 22273cc
dependencies update with corresponding fixes
adou600 cc3d8a7
fix tests
adou600 f37eb7a
insert bug reference URL
adou600 e6a7c63
dependencies update and merge master
adou600 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,7 @@ jackrabbit/ | |
| jackrabbit-standalone-*.jar | ||
| vagrant/.vagrant | ||
| app/bootstrap.php.cache | ||
| .idea/* | ||
| app/phpunit.xml | ||
|
|
||
| /bin/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?php | ||
|
|
||
| namespace Sandbox; | ||
|
|
||
| /** | ||
| * Class used by SaucelabsWebTestCase instances to load normal fixtures | ||
| * with the help of methods comming from WebTestCase | ||
| */ | ||
| class FixturesLoader extends WebTestCase | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| <?php | ||
|
|
||
| namespace Sandbox; | ||
|
|
||
| class NewsTest extends WebTestCase | ||
| { | ||
| public function testAddNews() | ||
| { | ||
| $client = $this->createClient(); | ||
|
|
||
| $title = 'news title from testAddNews'; | ||
| $formattedTitle = 'news-title-from-testAddNews'; | ||
| $content = 'some new content from testAddNews'; | ||
| $documentRequest = $this->generateCreateArticleRequest($title, $content); | ||
|
|
||
| $client->request('POST', '/en/symfony-cmf/create/document/_:bnode89', $documentRequest); | ||
| $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
| //the subject of the saved entity need to be set in the JSON response | ||
| $jsonResponse = json_decode($client->getResponse()->getContent()); | ||
| $this->assertEquals($jsonResponse->{'@subject'},'</cms/content/news/' . $formattedTitle . '>'); | ||
|
|
||
| $locales = array('en', 'fr', 'de'); | ||
|
|
||
| foreach ($locales as $locale) { | ||
| $routeRequest = $this->generateCreateRouteRequest($formattedTitle, $locale); | ||
| $crawler = $client->request( | ||
| 'POST', | ||
| '/' . $locale . ' /symfony-cmf/create/document/_:bnode26', | ||
| $routeRequest | ||
| ); | ||
|
|
||
| $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
| //the subject of the saved entity need to be set in the JSON response | ||
| $jsonResponse = json_decode($client->getResponse()->getContent()); | ||
| $this->assertEquals($jsonResponse->{'@subject'},'</cms/routes/'. $locale . '/news/' . $formattedTitle . '>'); | ||
|
|
||
| $crawler = $client->request('GET', '/' . $locale . '/news/' . $formattedTitle . ''); | ||
| $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
|
|
||
| $this->assertCount(1, $crawler->filter(sprintf('h2:contains("%s")', $title))); | ||
| $this->assertCount(1, $crawler->filter(sprintf('p:contains("%s")', $content))); | ||
| $this->assertCount(1, $crawler->filter(sprintf('div.subtitle:contains("%s")', 'Date: ' . date('Y-m-d')))); | ||
| } | ||
|
|
||
| //try to add a news with the same title, a collision on the node name should happen | ||
| $client->request('POST', '/en/symfony-cmf/create/document/_:bnode89', $documentRequest); | ||
| $this->assertEquals(500, $client->getResponse()->getStatusCode()); | ||
| $this->assertEquals("The document 'http://schema.org/NewsArticle' could not be created", $client->getResponse()->getContent()); | ||
| } | ||
|
|
||
| public function testUpdateNews() | ||
| { | ||
| self::$fixturesLoaded = false; // we only load fixtures once, but after this write test we want to refresh them | ||
| $client = $this->createClient(); | ||
|
|
||
| //prepare the PUT request | ||
| $titleKey = '<http://schema.org/CreativeWork/headline>'; | ||
| $title = 'updated title from testUpdateNews'; | ||
|
|
||
| $contentKey = '<http://schema.org/Article/articleBody>'; | ||
| $content = 'some updated content from testUpdateNews'; | ||
|
|
||
| $subjectKey = '@subject'; | ||
| $subject = '</cms/content/news/news-on-the-sandbox>'; | ||
|
|
||
| $typeKey = '@type'; | ||
| $type = '<<http://schema.org/NewsArticle>'; | ||
|
|
||
| $crawler = $client->request('PUT', '/en/symfony-cmf/create/document/cms/content/news/news-on-the-sandbox', | ||
| array( | ||
| $titleKey => $title, | ||
| $contentKey => $content, | ||
| $subjectKey => $subject, | ||
| $typeKey => $type | ||
| ) | ||
| ); | ||
|
|
||
| $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
|
|
||
| //get the updated page and check if data has been updated | ||
| $crawler = $client->request('GET', '/en/news/news-on-the-sandbox'); | ||
|
|
||
| $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
| $this->assertCount(1, $crawler->filter(sprintf('h2:contains("%s")', $title))); | ||
| $this->assertCount(1, $crawler->filter(sprintf('p:contains("%s")', $content))); | ||
| } | ||
|
|
||
| private function generateCreateRouteRequest($title, $locale) | ||
| { | ||
| //prepare the POST request for the new route in the current locale | ||
| $localeKey = '<http://cmf.symfony.com/CmfRoute/Locale>'; | ||
|
|
||
| $nameKey = '<http://cmf.symfony.com/CmfRoute/Name>'; | ||
| $nameValue = $title; | ||
|
|
||
| $parentKey = '<http://cmf.symfony.com/CmfRoute/Parent>'; | ||
| $parentValue = '/cms/routes/' . $locale . '/news'; | ||
|
|
||
| $routeContentKey = '<http://cmf.symfony.com/CmfRoute/RouteContent>'; | ||
| $routeContentValue = '/cms/content/news/' . $title; | ||
|
|
||
| $partOfKey = '<http://purl.org/dc/terms/partOf>'; | ||
| $partOfValue = '/cms/routes/' . $locale. '/news'; | ||
|
|
||
| $subjectKey = '@subject'; | ||
| $subjectValue = '_:bnode26'; | ||
|
|
||
| $typeKey = '@type'; | ||
| $typeValue = '<http://cmf.symfony.com/CmfRoute>'; | ||
|
|
||
| $routeRequest = array( | ||
| $localeKey => $locale, | ||
| $nameKey => $nameValue, | ||
| $parentKey => $parentValue, | ||
| $routeContentKey => $routeContentValue, | ||
| $partOfKey => array($partOfValue), | ||
| $subjectKey => $subjectValue, | ||
| $typeKey => $typeValue | ||
| ); | ||
|
|
||
| return $routeRequest; | ||
| } | ||
|
|
||
| private function generateCreateArticleRequest($title, $content) | ||
| { | ||
| //prepare the POST request | ||
| $partOfKey = '<http://purl.org/dc/terms/partOf>'; | ||
| $partOf = '</cms/content/news>'; | ||
|
|
||
| $titleKey = '<http://schema.org/CreativeWork/headline>'; | ||
| $titleValue = $title; | ||
|
|
||
| $contentKey = '<http://schema.org/Article/articleBody>'; | ||
| $contentValue = $content; | ||
|
|
||
| $subjectKey = '@subject'; | ||
| $subject = '_:bnode89'; | ||
|
|
||
| $typeKey = '@type'; | ||
| $type = '<http://schema.org/NewsArticle>'; | ||
|
|
||
| $request = array( | ||
| $partOfKey => array($partOf), | ||
| $titleKey => $titleValue, | ||
| $contentKey => $contentValue, | ||
| $subjectKey => $subject, | ||
| $typeKey => $type | ||
| ); | ||
|
|
||
| return $request; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?php | ||
|
|
||
| namespace Sandbox\Saucelabs; | ||
|
|
||
| /** | ||
| * Use Saucelabs to test the edition of content with Create.js | ||
| */ | ||
| class HomepageEditUserTest extends SaucelabsWebTestCase | ||
| { | ||
| public function setUp() | ||
| { | ||
| parent::setUp(); | ||
| $this->setBrowserUrl($this->homeUrl); | ||
| } | ||
|
|
||
| public function testEditHomepageContent() | ||
| { | ||
| //common variables | ||
| $originalTitle = 'Homepage'; | ||
| $toAddToTitle = 'Updated title for '; | ||
| $updatedTitle = $toAddToTitle . $originalTitle; | ||
| $titleCss = 'div.inner h1:first-child'; | ||
|
|
||
| //page loaded correctly? | ||
| $this->assertContains($originalTitle, $this->title()); | ||
|
|
||
| //click on edit | ||
| $this->enterEditMode(); | ||
|
|
||
| //cancel should now be in the button text | ||
| $cancelLink = $this->byId('midgardcreate-edit'); | ||
| $this->assertContains("Cancel", $cancelLink->text()); | ||
|
|
||
| //update the page title | ||
| $titleToEdit = $this->byCss($titleCss); | ||
| $titleToEdit->click(); | ||
| $titleToEdit->value($toAddToTitle); | ||
|
|
||
| //click on save | ||
| $this->saveChanges(); | ||
|
|
||
| //check the result | ||
| $this->assertContains($updatedTitle, $this->byCss($titleCss)->text()); | ||
|
|
||
| //click on cancel | ||
| $this->leaveEditMode(); | ||
|
|
||
| //reload the page to ensure the changes have been persisted | ||
| $this->url('/en'); | ||
| $driver = $this; | ||
| $pageLoaded = function() use ($driver, $updatedTitle) { | ||
| //give some time to load the page | ||
| return ($driver->title() == $updatedTitle); | ||
| }; | ||
| $this->spinAssert("Homepage was not loaded", $pageLoaded); | ||
|
|
||
| //updated title needs to be present in the page title and page content | ||
| $this->assertContains($updatedTitle, $this->title()); | ||
| $this->assertContains($updatedTitle, $this->byCss($titleCss)->text()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we integrate the "map" and "rdfmapper" map?