Skip to content

Instantly share code, notes, and snippets.

@mfrost503
Created October 9, 2012 14:45
Show Gist options
  • Save mfrost503/3859273 to your computer and use it in GitHub Desktop.
Save mfrost503/3859273 to your computer and use it in GitHub Desktop.
Account Test
<?php
/**
* This test addresses the following function requirements:
* Given that an Account is created (properly filled out and saved) then
* the DBA field (dba_c) should be populated with the name that was provided
* for the Account name
*
* This is a pretty common type of Sugar customization/enhancement that I've come
* across, so this test is how I would validate that my logic hook is working
*
* I would use this even though my logic hook consists of one line of code.
**/
class DBASetProperly extends Sugar_PHPUnit_Framework_TestCase
{
public function setup()
{
// This is an example of the create account helper
$this->account = SugarTestAccountUtilities::createAccount();
}
public function tearDown()
{
// This helper removes all the accounts created by the test
SugarTestAccountUtilities::removeAllCreatedAccounts();
}
/**
* @test
* Given that an account is saved then we should expect the dba_c field to be updated
* with the account name
**/
public function SetDBAFieldToTheFieldNameWhenSaved()
{
// since setup gets called before each test runs we can access $this->account
$this->account->name = "Test Account";
$this->account->save();
// we want to ensure our logic hook is setting the account name to the dba_c field properly
$this->assertEquals($this->account->name,$this->account->dba_c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment