コード例 #1
0
 public function testCreateDeal()
 {
     //simulate form input
     $post = ['tDeal' => ['Name' => 'Test deal', 'Number' => 'Test deal', 'Note' => 'some text note by deal', 'Date' => date('Y-m-d')]];
     $deal = new tDeal();
     $this->assertTrue($deal->load($post), 'Load POST data');
     $this->assertTrue($deal->save(), 'Create deal');
     $this->assertEquals(1, $deal->delete(), 'Remove just created deal');
 }
コード例 #2
0
 public function testCreateAndLoadDealWithRelations()
 {
     // create deals with relation data
     for ($i = 0; $i < 2; $i++) {
         $this->testCreateDeal();
     }
     // test Eager Loading
     $deals = tDeal::find()->with(['sender', 'reciver', 'address_from', 'address_to', 'goods', 'expenses', 'expenses.prices', 'expenses.prices.service', 'expenses.prices.delivery', 'expenses.prices.goods', 'expenses.prices.transport', 'expenses.prices.transport.driver', 'expenses.executor'])->limit(100)->all();
     $this->assertTrue($deals[0]->sender->role == 'buyer' && $deals[0]->sender->Country == '643' && $deals[0]->sender->OrganizationName == 'Sender organization full name' && $deals[0]->sender->ShortName == 'Sender organization', 'Check sender by deal');
     $this->assertTrue($deals[0]->reciver->role == 'seller' && $deals[0]->reciver->Country == '156' && $deals[0]->reciver->OrganizationName == 'Reciver organization full name' && $deals[0]->reciver->ShortName == 'Reciver organization', 'Check reciver by deal');
     $this->assertTrue($deals[0]->expenses[0]->prices[0]->transport->driver->PersonSurname == 'Ivanov' && $deals[0]->expenses[0]->prices[0]->transport->driver->PersonName == 'Ivan' && $deals[0]->expenses[0]->prices[0]->transport->driver->PersonMiddleName == 'Ivanovich' && $deals[0]->expenses[0]->prices[0]->transport->driver->PersonPost == 'Driver', 'Check driver by deal');
     $this->assertTrue($deals[0]->expenses[0]->prices[0]->goods[0]->GoodsShortDescription == 'Test Goods Short Description' && $deals[0]->expenses[0]->prices[0]->goods[0]->GoodsDescription == 'Full text Goods Description' && $deals[0]->expenses[0]->prices[0]->goods[0]->GoodsQuantity == '100' && $deals[0]->expenses[0]->prices[0]->goods[0]->MeasureUnitQualifierCode == '796' && $deals[0]->expenses[0]->prices[0]->goods[0]->MeasureUnitQualifierCost == '10' && $deals[0]->expenses[0]->prices[0]->goods[0]->Price == '10' && $deals[0]->expenses[0]->prices[0]->goods[0]->Cost == '9.8', 'Check goods by price by deal');
 }