Skip navigation
All Places > Developer > Blog > 2018 > November
2018

We can probably all agree that automated tests are great, but sometimes we put off writing them because the initial first step of getting everything working correctly can be really difficult.  

 

Good news, Sugar developers!  Writing PHPUnit tests for your customizations just got easier in Sugar Fall '18!  Our engineering team has created a test runner specifically for your custom PHPUnit tests.

 

If you do not have access to the SugarCRM provided unit test suite, submit the Developer Tools Request.

 

The first thing you'll need to do is add the SugarCRM provided unit test suite to your Sugar directory. Be sure to select the branch in the unit test suite that matches the version of your Sugar instance (needs to be 8.2 or higher). Follow the instructions in the branch's readme to add the tests to your Sugar directory, install the necessary dependencies, and update the file permissions.  

 

Now you're ready to write your tests!  Add your new PHPUnit test classes to the custom/tests/unit-php directory. You may need to create it yourself if it doesn't already exist.

 

For example, create a new file named CustomLogicHookTest.php and place it in the custom/tests/unit-php directory.  Paste the following in to the new file:

<?php
    //custom/tests/unit-php/CustomLogicHookTest.php
   
    namespace Sugarcrm\SugarcrmTestsUnit\custom;
   
    use PHPUnit\Framework\TestCase;
   
    /**
     * @coversDefaultClass \CustomLogicHook
     */

    class CustomLogicHookTest extends TestCase
    {
       
        /**
         * @covers ::aFunctionInsideTheCustomLogicHook
         */

        public function testCustomHook()
        {
            // Wow! This is a horrible test.
            // You would never do something like this just to increase your test  
            // coverage, right?
            $this->assertTrue(true);
        }
    }

In a shell, navigate to the Sugar provided unit tests directory by doing something like the following:

cd tests/unit-php

Then you can run the tests by executing

php ../../vendor/bin/phpunit --testsuite custom

or by using gulp (gulp installation instructions are available here)

gulp test:unit:php --suite custom

The above test is extremely simple and doesn't test anything. If you'd like to see an example of a larger test suite that tests Sugar customizations, check out Professor M's School for Gifted Coders.  We've recently updated our PHPUnit test suite so we can use the new test runner.  Check out the pull request associated with this change for the details.

Hey there Sugar Developers! I’m Niegel Leoncio (@niegel), CRM Manager for Bishop-Wisecarver. This year is my 2nd SugarCon and I was privileged to be chosen as a Sugar Scholar.  I attended the session "Sugar, DevOps, and IBM" led by Vineel Nirogi and Julian Coldrey and I wanted to share a few take away that I took from this session.

 

It’s easy to get distracted by the different festivities within the conference, and this year, even distractions outside of the conference is much greater since we are in Vegas. That’s why every time I attend a big event like SugarCon, I would define a goal of why I am attending and will focus my energy towards that goal. This year, it was finding the right tools and best practices now that I am enhancing my development skills. Vineel and Julian’s session is the Las Vegas jackpot that I was waiting for! Although it was the last session on the last day, it’s packed with lot of great nuggets.

 

Julian started the session by painting the picture of the challenges that they have in the beginning. It’s surprising that a company as large as IBM, with 60,000 users worldwide, 5,000+ business partners and 200+ integrations and customizations, struggles with similar issues that smaller companies like us have, except on a larger scale. They struggle with delayed delivery and about 100 code defects per release. Their challenge is – “How do we deliver value to our customers radically faster?”

Julian shared this high-level strategy in approaching this problem.

  • Setting up a goal
  • Identifying the current state
  • Learn from teams better than you
  • Design your roadmap
  • Execute the plan

 

Challenging the status quo and thinking outside the box is a principle that they embraced. They asked themselves, what can we do to shorten the time of code deployment from 45 days to 1 day. It’s an impossible task for some, but their team is ready to break barriers. As of this writing, they were able to move from a 45-day release to a weekly release with about less than 10 defects per release. Impressive!

How did they do that? Vineel took over and talked about how DevOps changed Everything. Since the definition of DevOps differs from everyone, Vineel defined DevOps as a Culture that induces sub-conscious way of continuously redesigning the working style as a Team to increase the happiness index in Software Development Cycle. He further explained that DevOps is influenced by 4 areas. These 4 areas comprise of:

  • Tools
  • Culture
  • Practices
  • Behavior

Vineel also shared some of the DevOps tools that they are using in IBM:

  • Github® - For Source Code Management
  • Jenkins® - For Continuous Integration
  • SonarQube® - For Source Code Analysis
  • PHP Analysis - PhpUnit, PhpLint, SugarLint, Jasmine
  • Zabbix® - For Production Monitoring
  • Slack® - For Communication & Feedback
  • Ansible® - To convert Infrastructure as a Code
  • Docker® - For Containerizing the application

 

For someone who is brand new into Development, knowing tools that are used by experts helps me to get a good foundation in my learning curve. Learning from their journey from identifying their challenges to achieving what they have accomplished gives me a confidence in my quest in the dev world.

 

Check out the session’s slides below to see more of what they covered.
Sugar, DevOps, and IBM

Does the idea of upgrading to the latest version of Sugar keep you awake at night? 

 

Matt Marum discussed how the development community can best be prepared for Sugar upgrades. As a reminder, Sugar cloud instances are upgraded quarterly, the current release is Fall 2018, and on-premise deployments are provided with yearly upgrades, the current release is Sugar 8. 

 

Steps to upgrade success

Preventive Care

Utilizing the latest information on the developer blogs and developer guide ensures that we won't be surprised as SugarCRM updates the Sugar platform. We, as developers, need to keep up to date. We perform preventative care to ensure that we are ready for the latest updates.

Items to be reviewed by for each release

  • Broken customizations and integrations 
  • Configuration based changes within SugarCRM
  • Custom code
  • Restrictions in Sugar Cloud with Custom Code

 

Release upgrade resources

 

Planning and testing

  • Use a staging environment - Sugar Enterprise customers have a sandbox included in their subscription. Be sure to utilize the sandbox. For all customers, it is possible to request a staging environment after GA has been announced and before the actual upgrade occurs. Be sure to leverage this staging environment to test all customizations to ensure success.

  • Heathcheck Tool - Sugar's silent upgrade application has the ability to run just the healthcheck portion of the upgrade script. Be sure to utilize this tool to determine which of your customizations need to be addressed as part of the upgrade.

  • If you get an "F" then you can’t upgrade - each item that has an F (RED) grade has a knowledge base article available on the Sugar Support website.
  • Document all customization and configurations - Be sure to have a list of all of your customizations so that you can run a full test of everything in the staging environment. It may not be necessary to test every customization for each upgrade but be sure to keep the list of changes up to date. 
  • If you utilize the list above and know the critical use cases, at a minimum it would be best to test each critical use cases before the final upgrade so that there are no surprises.

 

Follow the Sugar Developer blog and sign up for Sugar Developer news to make sure you get the latest info as it's available from SugarCRM!

 

For the slides, check out Preparing for Sugar Upgrades!

Hello!  I'm Justin Kuehlthau (@justinkuehlthau), Director of the Sugar Practice at Technology Advisors (Technology Advisors, Inc.).  This was my 8th SugarCon and this year I was lucky enough to be selected as a Sugar Scholar! 

 

I learned a lot about the future of security and authentication in Sugar from Jelle Vink, Distinguished Engineer at SugarCRM.  Jelle discussed Integration Best Practices and demoed a proof of concept integration between Android Assistance and Sugar!

 

Jelle started by covering some of the current pain points when integrating with Sugar:

  • No streamlined federated identity capabilities
  • LDAP & SAML have limited support on Mobile and Plugins
  • Credentials stored or used everywhere
    • Sugar Web Interface, Mobile, Outlook Plugin, Integrations, etc.
  • No fine grained authorization controls

 

Jellle introduced Cloud Identity Services, which will be available to Sugar cloud customers via a limited Beta launching near the end of October. Cloud Identity Services have many improved features including:

  • Federated identity solution
  • Industry standard OpenID Connect
  • Build on top of OAuth2
  • Enterprise SSO support
  • Full audit capabilities
  • Finely control what access each different application has

 

I'm very excited to see where this takes us.  Here is a video of Jelle's proof of concept integration with Android Assistant.

 

You can check out Jelle's slides here!