コード例 #1
0
ファイル: AddressTest.php プロジェクト: clippings/purchases
 /**
  * @coversNothing
  */
 public function testIntegration()
 {
     $address = Address::find(1);
     $purchase = Purchase::find(1);
     $country = Country::find(1);
     $city = City::find(2);
     $this->assertSame($purchase, $address->getPurchase());
     $this->assertSame($city, $address->getCity());
     $this->assertSame($country, $address->getCountry());
 }
コード例 #2
0
ファイル: CountryTest.php プロジェクト: harp-orm/locations
 /**
  * @covers ::initialize
  */
 public function testInitialize()
 {
     $repo = Country::getRepo();
     $this->assertInstanceOf('Harp\\MP\\BelongsTo', $repo->getRel('parent'));
     $this->assertInstanceOf('Harp\\MP\\HasMany', $repo->getRel('children'));
     $city = new Country(['name' => 'test']);
     $this->assertFalse($city->validate());
     $this->assertEquals('code must be present', $city->getErrors()->humanize());
     $city->code = '1';
     $this->assertFalse($city->validate());
     $this->assertEquals('code should be 2 letters', $city->getErrors()->humanize());
     $city->code = 'BG';
     $this->assertTrue($city->validate());
 }
コード例 #3
0
ファイル: Address.php プロジェクト: clippings/purchases
 public static function initialize(Config $config)
 {
     SoftDeleteTrait::initialize($config);
     $config->addRels([new Rel\BelongsTo('city', $config, City::getRepo()), new Rel\BelongsTo('country', $config, Country::getRepo()), new Rel\HasOne('purchase', $config, Purchase::getRepo(), ['foreignKey' => 'billingId'])])->addAsserts([new Assert\Present('firstName'), new Assert\Present('lastName'), new Assert\Present('email'), new Assert\Present('phone'), new Assert\Present('postCode'), new Assert\Present('line1'), new Assert\Email('email')]);
 }