Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
8 / 8
CartProduct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
8 / 8
 install
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
8 / 8
<?php
namespace Entity;
class CartProduct extends ModelBase
{
    protected function install()
    {
        $dbPrefix = $this->getDbPrefix();
        $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}cart_product` (
            `cart_id` INTEGER(11) UNSIGNED NOT NULL,
            `product_id` INTEGER(11) UNSIGNED NULL,
            `quantity` INTEGER(10) UNSIGNED NOT NULL,
            FOREIGN KEY (`cart_id`) REFERENCES `{$dbPrefix}cart`(id),
            FOREIGN KEY (`product_id`) REFERENCES `{$dbPrefix}product`(id),
            UNIQUE(`cart_id`, `product_id`)
        )");
        if ($result === false)
            throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
        return true;
    }
}