-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mark Scherer
committed
Sep 30, 2015
1 parent
e5c0eb2
commit 45d3765
Showing
6 changed files
with
107 additions
and
57 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,16 +49,16 @@ public function setUp() { | |
public function testSerialize() { | ||
$Request = new Request(); | ||
$Response = new Response(); | ||
$items = array( | ||
array('title' => 'Title One', 'link' => 'http://example.org/one', 'author' => '[email protected]', 'description' => 'Content one'), | ||
array('title' => 'Title Two', 'link' => 'http://example.org/two', 'author' => '[email protected]', 'description' => 'Content two'), | ||
); | ||
$items = [ | ||
['title' => 'Title One', 'link' => 'http://example.org/one', 'author' => '[email protected]', 'description' => 'Content one'], | ||
['title' => 'Title Two', 'link' => 'http://example.org/two', 'author' => '[email protected]', 'description' => 'Content two'], | ||
]; | ||
$View = new AjaxView($Request, $Response); | ||
$View->set(array('items' => $items, '_serialize' => array('items'))); | ||
$View->set(['items' => $items, '_serialize' => ['items']]); | ||
$result = $View->render(false); | ||
|
||
$this->assertSame('application/json', $Response->type()); | ||
$expected = array('error' => null, 'content' => null, 'items' => $items); | ||
$expected = ['error' => null, 'content' => null, 'items' => $items]; | ||
$expected = json_encode($expected); | ||
$this->assertTextEquals($expected, $result); | ||
} | ||
|
@@ -71,17 +71,17 @@ public function testSerialize() { | |
public function testRenderWithSerialize() { | ||
$Request = new Request(); | ||
$Response = new Response(); | ||
$items = array( | ||
array('title' => 'Title One', 'link' => 'http://example.org/one', 'author' => '[email protected]', 'description' => 'Content one'), | ||
array('title' => 'Title Two', 'link' => 'http://example.org/two', 'author' => '[email protected]', 'description' => 'Content two'), | ||
); | ||
$items = [ | ||
['title' => 'Title One', 'link' => 'http://example.org/one', 'author' => '[email protected]', 'description' => 'Content one'], | ||
['title' => 'Title Two', 'link' => 'http://example.org/two', 'author' => '[email protected]', 'description' => 'Content two'], | ||
]; | ||
$View = new AjaxView($Request, $Response); | ||
$View->set(array('items' => $items, '_serialize' => 'items')); | ||
$View->set(['items' => $items, '_serialize' => 'items']); | ||
$View->viewPath = 'Items'; | ||
$result = $View->render('index'); | ||
|
||
$this->assertSame('application/json', $Response->type()); | ||
$expected = array('error' => null, 'content' => 'My Index Test ctp', 'items' => $items); | ||
$expected = ['error' => null, 'content' => 'My Index Test ctp', 'items' => $items]; | ||
$expected = json_encode($expected); | ||
$this->assertTextEquals($expected, $result); | ||
} | ||
|
@@ -94,17 +94,17 @@ public function testRenderWithSerialize() { | |
public function testError() { | ||
$Request = new Request(); | ||
$Response = new Response(); | ||
$items = array( | ||
array('title' => 'Title One', 'link' => 'http://example.org/one', 'author' => '[email protected]', 'description' => 'Content one'), | ||
array('title' => 'Title Two', 'link' => 'http://example.org/two', 'author' => '[email protected]', 'description' => 'Content two'), | ||
); | ||
$items = [ | ||
['title' => 'Title One', 'link' => 'http://example.org/one', 'author' => '[email protected]', 'description' => 'Content one'], | ||
['title' => 'Title Two', 'link' => 'http://example.org/two', 'author' => '[email protected]', 'description' => 'Content two'], | ||
]; | ||
$View = new AjaxView($Request, $Response); | ||
$View->set(array('error' => 'Some message', 'items' => $items, '_serialize' => array('error', 'items'))); | ||
$View->set(['error' => 'Some message', 'items' => $items, '_serialize' => ['error', 'items']]); | ||
$View->viewPath = 'Items'; | ||
$result = $View->render('index'); | ||
|
||
$this->assertSame('application/json', $Response->type()); | ||
$expected = array('error' => 'Some message', 'content' => null, 'items' => $items); | ||
$expected = ['error' => 'Some message', 'content' => null, 'items' => $items]; | ||
$expected = json_encode($expected); | ||
$this->assertTextEquals($expected, $result); | ||
} | ||
|
@@ -124,9 +124,44 @@ public function testWithoutSubdir() { | |
$result = $View->render('index'); | ||
|
||
$this->assertSame('application/json', $Response->type()); | ||
$expected = array('error' => null, 'content' => 'My Index Test ctp'); | ||
$expected = ['error' => null, 'content' => 'My Index Test ctp']; | ||
$expected = json_encode($expected); | ||
$this->assertTextEquals($expected, $result); | ||
} | ||
|
||
public function _testRender() { | ||
$Request = new Request(); | ||
$Response = new Response(); | ||
$Controller = new AjaxComponentTestController($Request, $Response); | ||
|
||
$Controller->viewBuilder()->className('Ajax.Ajax'); | ||
$Controller->viewBuilder()->template('myTest'); | ||
$Controller->viewBuilder()->templatePath('AjaxComponentTest'); | ||
$Controller->myTest(); | ||
|
||
//$Controller->subDir = false; | ||
$result = $Controller->render(); | ||
|
||
$this->assertSame('application/json', $Response->type()); | ||
$expected = ['error' => null, 'content' => 'My Index Test ctp']; | ||
$expected = json_encode($expected); | ||
$this->assertTextEquals($expected, $result); | ||
} | ||
|
||
} | ||
|
||
// Use Controller instead of AppController to avoid conflicts | ||
class AjaxComponentTestController extends Controller { | ||
|
||
public $components = ['Ajax.Ajax']; | ||
|
||
/** | ||
* A test action | ||
* | ||
* @return void | ||
*/ | ||
public function myTest() { | ||
|
||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
Cake\Core\Configure::write('Config', [ | ||
'adminEmail' => '[email protected]', | ||
'adminName' => 'Mark']); | ||
Cake\Mailer\Email::config('default', array('transport' => 'Debug')); | ||
Cake\Mailer\Email::config('default', ['transport' => 'Debug']); | ||
Cake\Mailer\Email::configTransport('Debug', [ | ||
'className' => 'Debug' | ||
]); | ||
|