mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 16:36:25 +00:00
Link App with SmsController
This commit is contained in:
parent
42df9cc510
commit
860b4a3fb5
@ -41,7 +41,8 @@ class Application extends App {
|
|||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
$c->query('UserId'),
|
$c->query('UserId'),
|
||||||
$c->query('SmsMapper')
|
$c->query('SmsMapper'),
|
||||||
|
$this
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,5 +87,7 @@ class Application extends App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return self::$contacts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,14 @@ use \OCA\OcSms\Db\SmsMapper;
|
|||||||
|
|
||||||
class SmsController extends Controller {
|
class SmsController extends Controller {
|
||||||
|
|
||||||
|
private $app;
|
||||||
private $userId;
|
private $userId;
|
||||||
private $smsMapper;
|
private $smsMapper;
|
||||||
private $errorMsg;
|
private $errorMsg;
|
||||||
|
|
||||||
public function __construct ($appName, IRequest $request, $userId, SmsMapper $mapper){
|
public function __construct ($appName, IRequest $request, $userId, SmsMapper $mapper, Application $app){
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
$this->app = $app;
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->smsMapper = $mapper;
|
$this->smsMapper = $mapper;
|
||||||
}
|
}
|
||||||
@ -80,7 +82,7 @@ class SmsController extends Controller {
|
|||||||
public function getConversation ($phoneNumber, $lastDate = 0) {
|
public function getConversation ($phoneNumber, $lastDate = 0) {
|
||||||
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate);
|
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate);
|
||||||
// @ TODO: filter correctly
|
// @ TODO: filter correctly
|
||||||
return new JSONResponse(array("conversation" => $messages));
|
return new JSONResponse(array("conversation" => $messages, $contacts => $this->app->getContacts()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* ownCloud - ocsms
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later. See the COPYING file.
|
|
||||||
*
|
|
||||||
* @author Loic Blot <loic.blot@unix-experience.fr>
|
|
||||||
* @copyright Loic Blot 2014
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\OcSms\Controller;
|
|
||||||
|
|
||||||
|
|
||||||
use \OCP\IRequest;
|
|
||||||
use \OCP\AppFramework\Http\TemplateResponse;
|
|
||||||
use \OCP\AppFramework\Http\JSONResponse;
|
|
||||||
|
|
||||||
use \OCA\OcSms\AppInfo\Application;
|
|
||||||
|
|
||||||
|
|
||||||
class PageControllerTest extends \PHPUnit_Framework_TestCase {
|
|
||||||
|
|
||||||
private $container;
|
|
||||||
|
|
||||||
public function setUp () {
|
|
||||||
$app = new Application();
|
|
||||||
$phpunit = $this;
|
|
||||||
$this->container = $app->getContainer();
|
|
||||||
$this->container->registerService('Request', function($c) use ($phpunit) {
|
|
||||||
return $phpunit->getMockBuilder('\OCP\IRequest')->getMock();
|
|
||||||
});
|
|
||||||
$this->container->registerParameter('UserId', 'john');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function testIndex () {
|
|
||||||
$result = $this->container->query('PageController')->index();
|
|
||||||
|
|
||||||
$this->assertEquals(array('user' => 'john'), $result->getParams());
|
|
||||||
$this->assertEquals('main', $result->getTemplateName());
|
|
||||||
$this->assertTrue($result instanceof TemplateResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function testEcho () {
|
|
||||||
$result = $this->container->query('PageController')->doEcho('hi');
|
|
||||||
|
|
||||||
$this->assertEquals(array('echo' => 'hi'), $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user