Skip to content

Commit

Permalink
prepare tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Sep 25, 2024
1 parent 0d83fd4 commit 6cc3ecb
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 21 deletions.
39 changes: 39 additions & 0 deletions database/factories/TaxFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Cone\Bazar\Database\Factories;

use Cone\Bazar\Models\Tax;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class TaxFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Tax::class;

/**
* Get the name of the model that is generated by the factory.
*
* @return class-string<\Illuminate\Database\Eloquent\Model|TModel>
*/
public function modelName(): string
{
return $this->model::getProxiedClass();
}

/**
* Define the model's default state.
*/
public function definition(): array
{
return [
//
];
}
}
39 changes: 39 additions & 0 deletions database/factories/TaxRateFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Cone\Bazar\Database\Factories;

use Cone\Bazar\Models\TaxRate;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class TaxRateFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = TaxRate::class;

/**
* Get the name of the model that is generated by the factory.
*
* @return class-string<\Illuminate\Database\Eloquent\Model|TModel>
*/
public function modelName(): string
{
return $this->model::getProxiedClass();
}

/**
* Define the model's default state.
*/
public function definition(): array
{
return [
//
];
}
}
3 changes: 1 addition & 2 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Cone\Bazar\Interfaces\Models\Address as Contract;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
Expand Down Expand Up @@ -105,7 +104,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): AddressFactory
{
return AddressFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Cone\Bazar\Traits\InteractsWithItems;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -87,7 +86,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): CartFactory
{
return CartFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Cone\Bazar\Interfaces\Models\Category as Contract;
use Cone\Root\Traits\HasMedia;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -49,7 +48,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): CategoryFactory
{
return CategoryFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
Expand Down Expand Up @@ -105,7 +104,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): ItemFactory
{
return ItemFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down Expand Up @@ -113,7 +112,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): OrderFactory
{
return OrderFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Cone\Root\Traits\HasMetaData;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
Expand Down Expand Up @@ -63,7 +62,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): ProductFactory
{
return ProductFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Cone\Bazar\Interfaces\Models\Property as Contract;
use Cone\Root\Traits\HasMedia;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): PropertyFactory
{
return PropertyFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/PropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Cone\Bazar\Database\Factories\PropertyValueFactory;
use Cone\Bazar\Interfaces\Models\PropertyValue as Contract;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -43,7 +42,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): PropertyValueFactory
{
return PropertyValueFactory::new();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): ShippingFactory
{
return ShippingFactory::new();
}
Expand Down
9 changes: 9 additions & 0 deletions src/Models/Tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Cone\Bazar\Models;

use Cone\Bazar\Database\Factories\TaxFactory;
use Cone\Bazar\Interfaces\Models\Tax as Contract;
use Cone\Bazar\Support\Currency;
use Cone\Root\Traits\InteractsWithProxy;
Expand Down Expand Up @@ -58,6 +59,14 @@ public static function getProxiedInterface(): string
return Contract::class;
}

/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): TaxFactory
{
return TaxFactory::new();
}

/**
* Get the taxable model for the model.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/Models/TaxRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Cone\Bazar\Models;

use Cone\Bazar\Database\Factories\TaxRateFactory;
use Cone\Bazar\Interfaces\Models\TaxRate as Contract;
use Cone\Bazar\Interfaces\Taxable;
use Cone\Root\Traits\InteractsWithProxy;
Expand Down Expand Up @@ -29,6 +30,14 @@ public static function getProxiedInterface(): string
return Contract::class;
}

/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): TaxRateFactory
{
return TaxRateFactory::new();
}

/**
* Calculate the tax for the taxable model.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -75,7 +74,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): TransactionFactory
{
return TransactionFactory::new();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Variant.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Cone\Root\Traits\HasMetaData;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -62,7 +61,7 @@ public static function getProxiedInterface(): string
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory
protected static function newFactory(): VariantFactory
{
return VariantFactory::new();
}
Expand Down
15 changes: 15 additions & 0 deletions tests/Models/TaxRateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Cone\Bazar\Tests\Models;

use Cone\Bazar\Tests\TestCase;

class TaxRateTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

//
}
}
15 changes: 15 additions & 0 deletions tests/Models/TaxTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Cone\Bazar\Tests\Models;

use Cone\Bazar\Tests\TestCase;

class TaxTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

//
}
}

0 comments on commit 6cc3ecb

Please sign in to comment.