Christopher Johnson (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189952

Change subject: new controller tests
......................................................................

new controller tests

adds ProjectViewController route to SprintApplication

Change-Id: Ib7ad754729e76262d284a0e4abe5898260dee752
---
M src/application/SprintApplication.php
M src/controller/SprintReportController.php
M src/tests/SprintApplicationTest.php
M src/tests/SprintControllerTest.php
M src/tests/SprintTestCase.php
M src/view/reports/SprintReportBurnUpView.php
6 files changed, 99 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint 
refs/changes/52/189952/1

diff --git a/src/application/SprintApplication.php 
b/src/application/SprintApplication.php
index 387dff2..2701ae6 100644
--- a/src/application/SprintApplication.php
+++ b/src/application/SprintApplication.php
@@ -10,8 +10,7 @@
     return pht('Sprint');
   }
 
-  public function getBaseURI()
-  {
+  public function getBaseURI() {
       return '/project/sprint/';
   }
 
@@ -92,7 +91,7 @@
           ),
           // primary tag route override
           '/tag/' => array(
-              '(?P<slug>[^/]+)/' => 'SprintBoardViewController',
+              '(?P<slug>[^/]+)/' => 'SprintProjectViewController',
               '(?P<slug>[^/]+)/board/' => 'SprintBoardViewController',
           ),
       );
diff --git a/src/controller/SprintReportController.php 
b/src/controller/SprintReportController.php
index ce29eae..5baa1ea 100644
--- a/src/controller/SprintReportController.php
+++ b/src/controller/SprintReportController.php
@@ -26,7 +26,7 @@
 
     $nav = $this->buildNavMenu();
     $this->view = $nav->selectFilter($this->view, 'List');
-    require_celerity_resource('sprint-report-css', 'sprint');
+
 
     switch ($this->view) {
       case 'list':
diff --git a/src/tests/SprintApplicationTest.php 
b/src/tests/SprintApplicationTest.php
index 51928d0..e01f186 100644
--- a/src/tests/SprintApplicationTest.php
+++ b/src/tests/SprintApplicationTest.php
@@ -2,37 +2,37 @@
 final class SprintApplicationTest extends SprintTestCase {
 
   public function testGetName () {
-    $burndown_application = new SprintApplication;
+    $burndown_application = new SprintApplication();
     $name = $burndown_application->getName();
     $this->assertEquals('Sprint', $name);
   }
 
   public function testBaseURI () {
-    $burndown_application = new SprintApplication;
+    $burndown_application = new SprintApplication();
     $baseuri = $burndown_application->getBaseURI();
     $this->assertEquals('/project/sprint/', $baseuri);
   }
 
   public function testgetIconName() {
-    $burndown_application = new SprintApplication;
+    $burndown_application = new SprintApplication();
     $icon_name = $burndown_application->getIconName();
     $this->assertEquals('fa-puzzle-piece', $icon_name);
   }
 
   public function testgetShortDescription() {
-    $burndown_application = new SprintApplication;
+    $burndown_application = new SprintApplication();
     $description = $burndown_application->getShortDescription();
     $this->assertEquals('Build Sprints', $description);
   }
 
   public function testgetEventListeners() {
-    $burndown_application = new SprintApplication;
+    $burndown_application = new SprintApplication();
     $eventlistener = $burndown_application->getEventListeners();
     $this->assertInstanceOf('BurndownActionMenuEventListener', 
$eventlistener[0]);
   }
 
   public function testgetRoutes() {
-    $burndown_application = new SprintApplication;
+    $burndown_application = new SprintApplication();
     $routes = $burndown_application->getRoutes();
     $assertion = array(
       // this is the default application route controller
@@ -89,7 +89,7 @@
         ),
       // primary tag route override
         '/tag/' => array(
-            '(?P<slug>[^/]+)/' => 'SprintBoardViewController',
+            '(?P<slug>[^/]+)/' => 'SprintProjectViewController',
             '(?P<slug>[^/]+)/board/' => 'SprintBoardViewController',
         ),
     );
diff --git a/src/tests/SprintControllerTest.php 
b/src/tests/SprintControllerTest.php
index 8d8fbb8..5e2ed32 100644
--- a/src/tests/SprintControllerTest.php
+++ b/src/tests/SprintControllerTest.php
@@ -24,20 +24,6 @@
     $this->assertInstanceOf('SprintDataView', $burndownview);
   }
 
-  public function testgetSprintDataViewRender() {
-    $projectobj = new PhabricatorProject();
-    $viewer = $this->generateNewTestUser();
-    $request = new AphrontRequest('phab.wmde.de', '/project/sprint/view/18');
-    $objectboxes = id(new SprintDataViewController())
-        ->setRequest($request)
-        ->setProject($projectobj)
-        ->setViewer($viewer)
-        ->render();
-    foreach ($objectboxes as $objectbox) {
-      $this->assertInstanceOf('PHUIObjectBox', $objectbox);
-    };
-  }
-
   public function testgetErrorBox() {
     $e = new Exception();
     $dv = new SprintDataViewController();
@@ -45,32 +31,99 @@
     $this->assertInstanceOf('PHUIErrorView', $errorbox);
   }
 
-  public function testprocessRequestFail() {
+  public function testhandleRequestDataViewController() {
     $dvcontroller = new SprintDataViewController();
     $sprint = new SprintApplication();
     $dvcontroller->setCurrentApplication($sprint);
     $request = new AphrontRequest('phab.wmde.de', '/project/sprint/view/18');
+    $dvcontroller->setRequest($request);
     $data = array();
-    $data['id'] =  3;
-    $request->setRequestdata($data);
+    $data['id'] =  18;
+    $request->setURIMap($data);
     $viewer = $this->generateNewTestUser();
     $request->setUser($viewer);
     $dvcontroller->willProcessRequest($data);
+    $response = $dvcontroller->handleRequest($request);
+    $this->assertInstanceOf('AphrontResponse', $response);
+  }
+
+  public function testhandleRequestDataViewControllerFail() {
+    $dvcontroller = new SprintDataViewController();
+    $sprint = new SprintApplication();
+    $dvcontroller->setCurrentApplication($sprint);
+    $request = new AphrontRequest('phab.wmde.de', '/project/sprint/view/18');
     $dvcontroller->setRequest($request);
-    $response = $dvcontroller->processRequest();
+    $data = array();
+    $data['id'] =  3;
+    $request->setURIMap($data);
+    $viewer = $this->generateNewTestUser();
+    $request->setUser($viewer);
+    $dvcontroller->willProcessRequest($data);
+    $response = $dvcontroller->handleRequest($request);
     $this->assertInstanceOf('Aphront404Response', $response);
   }
 
-//  public function testprocessRequestListController() {
-//     $this->willRunTests();
-//     $lcontroller = new SprintListController();
-//     $sprint = new SprintApplication();
-//     $lcontroller->setCurrentApplication($sprint);
-//     $request = new AphrontRequest('phab.wmde.de', 
'/project/sprint/view/18');
-//     $viewer = $this->generateNewTestUser();
-//     $request->setUser($viewer);
-//     $lcontroller->setRequest($request);
-//     $response = $lcontroller->processRequest();
-//     $this->assertInstanceOf('AphrontWebpageResponse', $response);
-//   }
+  public function testhandleRequestProjectProfileController() {
+    $dvcontroller = new SprintProjectProfileController();
+    $sprint = new SprintApplication();
+    $dvcontroller->setCurrentApplication($sprint);
+    $request = new AphrontRequest('phab.wmde.de', '/project/profile/18');
+    $dvcontroller->setRequest($request);
+    $data = array();
+    $data['id'] =  18;
+    $request->setURIMap($data);
+    $viewer = $this->generateNewTestUser();
+    $request->setUser($viewer);
+    $dvcontroller->willProcessRequest($data);
+    $response = $dvcontroller->handleRequest($request);
+    $this->assertInstanceOf('AphrontResponse', $response);
+  }
+
+  public function testhandleRequestProjectProfileControllerFail() {
+    $dvcontroller = new SprintProjectProfileController();
+    $sprint = new SprintApplication();
+    $dvcontroller->setCurrentApplication($sprint);
+    $request = new AphrontRequest('phab.wmde.de', '/project/profile/18');
+    $dvcontroller->setRequest($request);
+    $data = array();
+    $data['id'] =  3;
+    $request->setURIMap($data);
+    $viewer = $this->generateNewTestUser();
+    $request->setUser($viewer);
+    $dvcontroller->willProcessRequest($data);
+    $response = $dvcontroller->handleRequest($request);
+    $this->assertInstanceOf('Aphront404Response', $response);
+  }
+
+  public function testhandleRequestProjectViewController() {
+    $dvcontroller = new SprintProjectViewController();
+    $sprint = new SprintApplication();
+    $dvcontroller->setCurrentApplication($sprint);
+    $request = new AphrontRequest('phab.wmde.de', '/project/tag/null_project');
+    $dvcontroller->setRequest($request);
+    $data = array();
+    $data['slug'] =  'null_project';
+    $request->setURIMap($data);
+    $viewer = $this->generateNewTestUser();
+    $request->setUser($viewer);
+    $dvcontroller->willProcessRequest($data);
+    $response = $dvcontroller->handleRequest($request);
+    $this->assertInstanceOf('AphrontResponse', $response);
+  }
+
+  public function testhandleRequestProjectViewControllerFail() {
+    $dvcontroller = new SprintProjectViewController();
+    $sprint = new SprintApplication();
+    $dvcontroller->setCurrentApplication($sprint);
+    $request = new AphrontRequest('phab.wmde.de', '/project/tag/null_project');
+    $dvcontroller->setRequest($request);
+    $data = array();
+    $data['slug'] =  'fail_project';
+    $request->setURIMap($data);
+    $viewer = $this->generateNewTestUser();
+    $request->setUser($viewer);
+    $dvcontroller->willProcessRequest($data);
+    $response = $dvcontroller->handleRequest($request);
+    $this->assertInstanceOf('Aphront404Response', $response);
+  }
 }
diff --git a/src/tests/SprintTestCase.php b/src/tests/SprintTestCase.php
index 862c1f2..9abb705 100644
--- a/src/tests/SprintTestCase.php
+++ b/src/tests/SprintTestCase.php
@@ -91,8 +91,8 @@
       LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();
     }
 
-//    $this->env = new PhabricatorEnv();
-//    $this->env->initializeWebEnvironment();
+    $this->env = new PhabricatorEnv();
+    $this->env->initializeScriptEnvironment();
 
     // NOTE: While running unit tests, we act as though all applications are
     // installed, regardless of the install's configuration. Tests which need
@@ -105,6 +105,9 @@
     $this->env->overrideEnvConfig(
         'phabricator.show-prototypes',
         true);
+    $this->env->overrideEnvConfig(
+        'phabricator.serious-business',
+        true);
 
     // Reset application settings to defaults, particularly policies.
     $this->env->overrideEnvConfig(
diff --git a/src/view/reports/SprintReportBurnUpView.php 
b/src/view/reports/SprintReportBurnUpView.php
index 7892f2d..b7ff0eb 100644
--- a/src/view/reports/SprintReportBurnUpView.php
+++ b/src/view/reports/SprintReportBurnUpView.php
@@ -15,6 +15,7 @@
   }
 
   public function render() {
+    require_celerity_resource('sprint-report-css', 'sprint');
     $filter = $this->BuildFilter();
     $chart = $this->buildBurnDownChart();
     $table = $this->buildStatsTable();

-- 
To view, visit https://gerrit.wikimedia.org/r/189952
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7ad754729e76262d284a0e4abe5898260dee752
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/extensions/Sprint
Gerrit-Branch: master
Gerrit-Owner: Christopher Johnson (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to