Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'dev' of github.com:microweber/microweber into dev
- Loading branch information
Showing
15 changed files
with
348 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 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
21 changes: 21 additions & 0 deletions
21
src/MicroweberPackages/App/resources/views/rss/posts.blade.php
This file contains 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,21 @@ | ||
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> | ||
<rss version="2.0" | ||
xmlns:g="http://base.google.com/ns/1.0"> | ||
<channel> | ||
<title>{{ $siteTitle }}</title> | ||
<link>{{ $siteUrl }}</link> | ||
<description>{{ $siteDescription }}</description> | ||
@foreach ($rssData as $item) | ||
<item> | ||
<g:title>{{ $item['title'] }}</g:title> | ||
<g:description>{{ $item['description'] }}</g:description> | ||
@if(!empty($item['image'])) | ||
<g:image_link>{{ $item['image'] }}</g:image_link> | ||
@endif | ||
@if(isset($item['price'])) | ||
<g:price>{{ $item['price'] }}</g:price> | ||
@endif | ||
</item> | ||
@endforeach | ||
</channel> | ||
</rss> |
This file contains 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 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 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 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
211 changes: 211 additions & 0 deletions
211
src/MicroweberPackages/Content/tests/ContentApiControllerTest.php
This file contains 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,211 @@ | ||
<?php | ||
namespace MicroweberPackages\Content\tests; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Facades\Auth; | ||
use MicroweberPackages\Category\Models\Category; | ||
use MicroweberPackages\Core\tests\TestCase; | ||
use MicroweberPackages\User\Models\User; | ||
|
||
class ContentApiControllerTest extends TestCase | ||
{ | ||
public function testAddContentFull() | ||
{ | ||
$categoryIds = []; | ||
|
||
$user = User::where('is_admin','=', '1')->first(); | ||
Auth::login($user); | ||
|
||
|
||
$category = new Category(); | ||
$category->title = 'New cat for my custom model'. rand(); | ||
$category->save(); | ||
$categoryIds[] = $category->id; | ||
|
||
$category = new Category(); | ||
$category->title = 'New cat for my custom model'. rand(); | ||
$category->save(); | ||
$categoryIds[] = $category->id; | ||
|
||
$title = 'Iphone and spire 4ever! - '. rand(); | ||
$title2 = 'Iphone and spire 4ever! 2 - '. rand(); | ||
$contentBody = 'This is my cool content description.'; | ||
|
||
|
||
$response = $this->call( | ||
'POST', | ||
route('api.content.store'), | ||
[ | ||
'title' => $title, | ||
'category_ids'=>implode(',', $categoryIds), | ||
'content_body' => $contentBody, | ||
'content' => '', | ||
] | ||
); | ||
|
||
$contentDataSaved = $response->getData()->data; | ||
$this->assertEquals($contentDataSaved->title, $title); | ||
|
||
|
||
|
||
$response = $this->call( | ||
'PUT', | ||
route('api.content.update', [ | ||
'content' => $contentDataSaved->id, | ||
'title' => $title2, | ||
]) | ||
|
||
); | ||
|
||
$this->assertEquals(200, $response->status()); | ||
$contentDataSaved = $response->getData()->data; | ||
|
||
$this->assertEquals($contentDataSaved->title, $title2); | ||
|
||
|
||
$response = $this->call( | ||
'PUT', | ||
route('api.content.update', [ | ||
'content' => $contentDataSaved->id, | ||
'title' => 'new title', | ||
]) | ||
|
||
); | ||
$this->assertEquals(200, $response->status()); | ||
|
||
$contentDataSaved = $response->getData()->data; | ||
$this->assertEquals($contentDataSaved->title, 'new title'); | ||
|
||
|
||
$response = $this->call( | ||
'PUT', | ||
route('api.content.update', [ | ||
'content' => $contentDataSaved->id, | ||
'title' => '0', | ||
]) | ||
|
||
); | ||
$this->assertEquals(200, $response->status()); | ||
|
||
$contentDataSaved = $response->getData()->data; | ||
$this->assertEquals($contentDataSaved->title, 0); | ||
|
||
|
||
$response = $this->call( | ||
'PUT', | ||
route('api.content.update', [ | ||
'content' => $contentDataSaved->id, | ||
]) | ||
|
||
); | ||
$this->assertEquals(200, $response->status()); | ||
|
||
$contentDataSaved = $response->getData()->data; | ||
} | ||
|
||
public function testSaveContentFromController() | ||
{ | ||
$user = User::where('is_admin','=', '1')->first(); | ||
Auth::login($user); | ||
|
||
$title = 'Test add content from api ' . rand(); | ||
$title2 = 'Test update content from api ' . rand(); | ||
|
||
$response = $this->call( | ||
'POST', | ||
route('api.content.store'), | ||
[ | ||
'title' => $title, | ||
'content_body' => '<b>Bold text</b>', | ||
'content' => '<b onmouseover=alert(‘XSS testing!‘)>XSS</b> <IMG SRC=jAvascript:alert(\'test2\')>' | ||
] | ||
); | ||
|
||
|
||
$this->assertEquals(201, $response->status()); | ||
$contentData = $response->getData(); | ||
$this->assertEquals($contentData->data->title, $title); | ||
|
||
$content_id = $contentData->data->id; | ||
|
||
|
||
$response = $this->call( | ||
'GET', | ||
route('api.content.show', | ||
[ | ||
'content' => $content_id, | ||
]) | ||
); | ||
|
||
$contentData = $response->getData(); | ||
|
||
|
||
$this->assertEquals($contentData->data->title, $title); | ||
|
||
|
||
$response = $this->call( | ||
'PUT', | ||
route('api.content.update', [ | ||
'content' => $content_id, | ||
'title' => $title2, | ||
]) | ||
|
||
); | ||
|
||
$this->assertEquals(200, $response->status()); | ||
|
||
$response = $this->call( | ||
'GET', | ||
route('api.content.show', | ||
[ | ||
'content' => $content_id, | ||
]) | ||
); | ||
|
||
$contentData = $response->getData(); | ||
|
||
$this->assertEquals($contentData->data->title, $title2); | ||
|
||
|
||
|
||
$response = $this->call( | ||
'GET', | ||
route('api.content.index', | ||
[ | ||
]) | ||
); | ||
|
||
$contentData = $response->getData(); | ||
$this->assertEquals(true,!empty($contentData->data)); | ||
|
||
} | ||
|
||
public function testDeleteContentFromController() | ||
{ | ||
$user = User::where('is_admin', '=', '1')->first(); | ||
Auth::login($user); | ||
|
||
$title = 'Test add content from api ' . rand(); | ||
|
||
$response = $this->call( | ||
'POST', | ||
route('api.content.store'), | ||
[ | ||
'title' => $title, | ||
] | ||
); | ||
|
||
|
||
$response = $this->call( | ||
'DELETE', | ||
route('api.content.destroy', [ | ||
'content' => $response->getData()->data->id, | ||
]) | ||
); | ||
|
||
$this->assertEquals(200, $response->status()); | ||
$contentData = $response->getData()->data->ids; | ||
|
||
$this->assertNotEmpty($contentData); | ||
} | ||
} |
Oops, something went wrong.