diff --git a/appinfo/application.php b/appinfo/application.php index 997336e..c48b1f7 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -41,7 +41,8 @@ class Application extends App { $c->query('AppName'), $c->query('Request'), $c->query('UserId'), - $c->query('SmsMapper') + $c->query('SmsMapper'), + $this ); }); @@ -86,5 +87,7 @@ class Application extends App { } } } + + return self::$contacts; } } diff --git a/controller/smscontroller.php b/controller/smscontroller.php index 364ee54..14116ce 100644 --- a/controller/smscontroller.php +++ b/controller/smscontroller.php @@ -20,12 +20,14 @@ use \OCA\OcSms\Db\SmsMapper; class SmsController extends Controller { + private $app; private $userId; private $smsMapper; 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); + $this->app = $app; $this->userId = $userId; $this->smsMapper = $mapper; } @@ -80,7 +82,7 @@ class SmsController extends Controller { public function getConversation ($phoneNumber, $lastDate = 0) { $messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate); // @ TODO: filter correctly - return new JSONResponse(array("conversation" => $messages)); + return new JSONResponse(array("conversation" => $messages, $contacts => $this->app->getContacts())); } /** diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php deleted file mode 100644 index baa4136..0000000 --- a/tests/unit/controller/PageControllerTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @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); - } - - -} \ No newline at end of file