function checkBaseCounts($type = '', $clientCode = '', $customers = 0, $addresses = 0, $phones = 0, $orders = 0, $items = 0, $attributes = 0, $countries = 2, $products = 4) { if ($type != '') { switch ($type) { case 'full': $customers = 1; $addresses = 1; $phones = 1; $orders = 1; $items = 3; $attributes = $clientCode == 'CLIENT2' ? 5 : 4; break; case 'lessoneitem': $customers = 1; $addresses = 1; $phones = 1; $orders = 1; $items = 2; $attributes = $clientCode == 'CLIENT2' ? 5 : 4; break; case 'lessaddress': $customers = 1; $addresses = 0; $phones = 1; $orders = 1; $items = 3; $attributes = $clientCode == 'CLIENT2' ? 5 : 4; break; } } $this->assertEquals($customers, Customer::find()->count()); $this->assertEquals($addresses, Address::find()->count()); $this->assertEquals($attributes, AttributeValues::find()->count()); $this->assertEquals($orders, Order::find()->count()); $this->assertEquals($items, Item::find()->count()); $this->assertEquals($countries, Country::find()->count()); $this->assertEquals($products, Product::find()->count()); }
public function modelRelationMap() { return ['items' => array('type' => 'hasMany', 'class' => Item::className(), 'link' => array('orderId' => 'id'), 'onSaveAll' => ActiveRecord::SAVE_CASCADE, 'onDeleteFull' => ActiveRecord::DELETE_CASCADE, 'autoLinkType' => ActiveRecord::LINK_FROM_PARENT_MAINT, 'allToArray' => true, 'autoLink' => array('fromParent' => array('orderId' => 'id', 'customerId' => 'customerId'))), 'customer' => array('type' => 'belongsTo', 'class' => Customer::className(), 'link' => array('id' => 'customerId'))]; }