Exemple #1
0
 public function testSetUrlManager()
 {
     $request = new THttpRequest();
     // Try invalid manager id
     $request->setUrlManager('invalidManagerId');
     try {
         $request->init(null);
         $request->getUrlManagerModule();
         self::fail('httprequest_urlmanager_inexist exception not thrown');
     } catch (TConfigurationException $e) {
     }
     $request = null;
     // Try with valid module id, but not instance of TUrlManager
     $module = new TAssetManager();
     self::$app->setModule('badmanager', $module);
     $request = new THttpRequest();
     $request->setUrlManager('badmanager');
     try {
         $request->init(null);
         $request->getUrlManagerModule();
         self::fail('httprequest_urlmanager_invalid exception not thrown');
     } catch (TConfigurationException $e) {
     }
     $request = null;
     // Finally, try with a valid manager
     $module = new TUrlManager();
     self::$app->setModule('goodmanager', $module);
     $request = new THttpRequest();
     $request->setUrlManager('goodmanager');
     $request->init(null);
     self::assertEquals('goodmanager', $request->getUrlManager());
     self::assertInstanceOf('TUrlManager', $request->getUrlManagerModule());
 }