Permalink
Browse files

make partner more fluent and fix test

  • Loading branch information...
1 parent d2a377e commit 9544c48b58c029ea376845d138e6f97e228bed76 @cordoval cordoval committed with iampersistent Jan 16, 2013
Showing with 50 additions and 0 deletions.
  1. +30 −0 lib/Vespolina/Entity/Partner/Partner.php
  2. +20 −0 tests/Entity/Partner/PartnerTest.php
@@ -62,6 +62,8 @@ public function getPartnerId()
public function setPartnerId($partnerId)
{
$this->partnerId = $partnerId;
+
+ return $this;
}
/**
@@ -78,6 +80,8 @@ public function getPartnerSince()
public function setPartnerSince(\DateTime $partnerSince)
{
$this->partnerSince = $partnerSince;
+
+ return $this;
}
/**
@@ -94,6 +98,8 @@ public function getRoles()
public function addRole($role)
{
$this->roles[] = $role;
+
+ return $this;
}
/**
@@ -102,6 +108,8 @@ public function addRole($role)
public function setRoles($roles)
{
$this->roles = $roles;
+
+ return $this;
}
/**
@@ -118,6 +126,8 @@ public function getName()
public function setName($name)
{
$this->name = $name;
+
+ return $this;
}
/**
@@ -134,6 +144,8 @@ public function getShortName()
public function setShortName($shortName)
{
$this->shortName = $shortName;
+
+ return $this;
}
/**
@@ -150,6 +162,8 @@ public function getType()
public function setType($type)
{
$this->type = $type;
+
+ return $this;
}
/**
@@ -166,6 +180,8 @@ public function getCurrency()
public function setCurrency($currency)
{
$this->currency = $currency;
+
+ return $this;
}
/**
@@ -182,6 +198,8 @@ public function getLanguage()
public function setLanguage($language)
{
$this->language = $language;
+
+ return $this;
}
/**
@@ -198,6 +216,8 @@ public function getPaymentTerms()
public function setPaymentTerms($paymentTerms)
{
$this->paymentTerms = $paymentTerms;
+
+ return $this;
}
/**
@@ -214,6 +234,8 @@ public function getAddresses()
public function setAddresses($addresses)
{
$this->addresses = $addresses;
+
+ return $this;
}
/**
@@ -222,6 +244,8 @@ public function setAddresses($addresses)
public function addAddress($address)
{
$this->addresses[] = $address;
+
+ return $this;
}
/**
@@ -246,6 +270,8 @@ public function getPrimaryContact()
public function setPrimaryContact(Contact $primaryContact)
{
$this->primaryContact = $primaryContact;
+
+ return $this;
}
/**
@@ -262,6 +288,8 @@ public function getPersonalDetails()
public function setPersonalDetails($personalDetails)
{
$this->personalDetails = $personalDetails;
+
+ return $this;
}
/**
@@ -278,6 +306,8 @@ public function getOrganisationDetails()
public function setOrganisationDetails($organisationDetails)
{
$this->organisationDetails = $organisationDetails;
+
+ return $this;
}
}
@@ -7,11 +7,31 @@
*/
use Vespolina\Entity\Partner\Partner;
+use Vespolina\Entity\Partner\Address;
class PartnerTest extends \PHPUnit_Framework_TestCase
{
+ // todo: payment profile (cc profile)
public function testPaymentProfileMethods()
{
$this->markTestIncomplete('tests for payment profiles (including cc) need to be written and implemented');
}
+
+ public function testFluentInterface()
+ {
+ $addressOnFile = new Address();
+
+ $partner = new Partner();
+ $partner
+ ->setShortName('jake')
+ ->setRoles(array('ROLE_USER'))
+ ->setName('customer')
+ ->setLanguage('English')
+ ->setCurrency('USD')
+ ->setType(Partner::INDIVIDUAL)
+ ->setAddresses(array($addressOnFile))
+ ;
+
+ $this->assertContains('ROLE_USER', $partner->getRoles());
+ }
}

0 comments on commit 9544c48

Please sign in to comment.