Jump to content


Photo

ZurmoWalkthroughBaseTest::checkCopyActionResponseAttributeValues

unit testing customization

  • Please log in to reply
5 replies to this topic

#1 windsor

windsor

    Advanced Member

  • Moderators
  • 272 posts
  • LocationTampa, Florida USA

Posted 04 July 2013 - 02:56 PM

In: Zurmo 2.02

 

The following code does not appear to follow convention.

If you have a class model named like: 'CustomModel.php', in module 'customModels' directory

The code on line 6 below will create a route like 'custommodels/default/copy' in line 14

Which will result in this error when testing:

 

CHttpException: unable to resolve the request "custommodels/default/copy"

 

Because the route for app/modules/customModels/controller/defaultController::actionCopy is 'customModels/default/copy'

 

Note the camel case.

 

I think line 6 should be:

 

$realm = lcfirst($class);

 

similarly line 10 should be:

 

$realm = rtrim(lcfirst($linkClass), 's');

 

protected function checkCopyActionResponseAttributeValues($model, $testAttributes, $linkClass = null)
        {
            $class = get_class($model);
            if (empty($linkClass))
            {
                $realm = strtolower($class);
            }
            else
            {
                $realm = rtrim(strtolower($linkClass), 's');
            }
            $this->setGetArray(array('id' => $model->id));
            $this->resetPostArray();
            $response = $this->runControllerWithNoExceptionsAndGetContent($realm.'s/default/copy');
            return $this->checkResponseAgainstAttributeArray($response, $model, $class, $testAttributes, $linkClass);
        }


#2 raysto

raysto

    Zurmo Team

  • Administrators
  • 1,973 posts

Posted 05 July 2013 - 12:36 AM

OK, thanks for bringing this up. I'll pass along to our dev team.


Ray Stoeckicht
Zurmo Team
Try Zurmo Pro


#3 Jason

Jason

    Administrator

  • Administrators
  • 864 posts
  • LocationChicago

Posted 05 July 2013 - 01:33 AM

What needs to happen is we need to call $model::getModuleClassName();

Then we can get from that the $moduleClassName::getDirectoryName();

 

Can you do a pull request for this fix?

Thanks,
Jason


Jason Green
Zurmo Team
Need support? Upgrade now


#4 windsor

windsor

    Advanced Member

  • Moderators
  • 272 posts
  • LocationTampa, Florida USA

Posted 05 July 2013 - 02:07 PM

thanks,  not sure the procedure for a 'pull request' ? do you need any thing else from us? if so, what steps do we need to do?



#5 Jason

Jason

    Administrator

  • Administrators
  • 864 posts
  • LocationChicago

Posted 05 July 2013 - 02:15 PM

Well, the easiest thing is fork the zurmo/zurmo repository. then make the fix. then commit to your fork. then in bitbucket UI you can do a pull request back to zurmo/zurmo


Jason Green
Zurmo Team
Need support? Upgrade now


#6 windsor

windsor

    Advanced Member

  • Moderators
  • 272 posts
  • LocationTampa, Florida USA

Posted 05 July 2013 - 02:40 PM

ok, I'll need to finally get setup with bitbucket  We switched from Subversion to Hg last month. will try this over the weekend with the latest version, then will let you know if any problems on the developer call on Tues.  I made your reccomended changes in local code and seems to work at least for tests of current module (clone of Account), but need to still run all unit tests to ensure no conflicts with the rest of the code.  Thanks!







Also tagged with one or more of these keywords: unit testing, customization

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users