Exemplo n.º 1
0
 /**
  * @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());
 }
Exemplo n.º 2
0
 /**
  * @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());
 }
Exemplo n.º 3
0
 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')]);
 }