Skip to content
This repository was archived by the owner on Sep 28, 2019. It is now read-only.

Commit 846c756

Browse files
authored
Merge pull request #5 from avored/dev
merging dev to master
2 parents 9ea56eb + 9c05f3c commit 846c756

File tree

9 files changed

+176
-39
lines changed

9 files changed

+176
-39
lines changed

assets/countries.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"BD": "Bangladesh", "BE": "Belgium", "BF": "Burkina Faso", "BG": "Bulgaria", "BA": "Bosnia and Herzegovina", "BB": "Barbados", "WF": "Wallis and Futuna", "BL": "Saint Barthelemy", "BM": "Bermuda", "BN": "Brunei", "BO": "Bolivia", "BH": "Bahrain", "BI": "Burundi", "BJ": "Benin", "BT": "Bhutan", "JM": "Jamaica", "BV": "Bouvet Island", "BW": "Botswana", "WS": "Samoa", "BQ": "Bonaire, Saint Eustatius and Saba ", "BR": "Brazil", "BS": "Bahamas", "JE": "Jersey", "BY": "Belarus", "BZ": "Belize", "RU": "Russia", "RW": "Rwanda", "RS": "Serbia", "TL": "East Timor", "RE": "Reunion", "TM": "Turkmenistan", "TJ": "Tajikistan", "RO": "Romania", "TK": "Tokelau", "GW": "Guinea-Bissau", "GU": "Guam", "GT": "Guatemala", "GS": "South Georgia and the South Sandwich Islands", "GR": "Greece", "GQ": "Equatorial Guinea", "GP": "Guadeloupe", "JP": "Japan", "GY": "Guyana", "GG": "Guernsey", "GF": "French Guiana", "GE": "Georgia", "GD": "Grenada", "GB": "United Kingdom", "GA": "Gabon", "SV": "El Salvador", "GN": "Guinea", "GM": "Gambia", "GL": "Greenland", "GI": "Gibraltar", "GH": "Ghana", "OM": "Oman", "TN": "Tunisia", "JO": "Jordan", "HR": "Croatia", "HT": "Haiti", "HU": "Hungary", "HK": "Hong Kong", "HN": "Honduras", "HM": "Heard Island and McDonald Islands", "VE": "Venezuela", "PR": "Puerto Rico", "PS": "Palestinian Territory", "PW": "Palau", "PT": "Portugal", "SJ": "Svalbard and Jan Mayen", "PY": "Paraguay", "IQ": "Iraq", "PA": "Panama", "PF": "French Polynesia", "PG": "Papua New Guinea", "PE": "Peru", "PK": "Pakistan", "PH": "Philippines", "PN": "Pitcairn", "PL": "Poland", "PM": "Saint Pierre and Miquelon", "ZM": "Zambia", "EH": "Western Sahara", "EE": "Estonia", "EG": "Egypt", "ZA": "South Africa", "EC": "Ecuador", "IT": "Italy", "VN": "Vietnam", "SB": "Solomon Islands", "ET": "Ethiopia", "SO": "Somalia", "ZW": "Zimbabwe", "SA": "Saudi Arabia", "ES": "Spain", "ER": "Eritrea", "ME": "Montenegro", "MD": "Moldova", "MG": "Madagascar", "MF": "Saint Martin", "MA": "Morocco", "MC": "Monaco", "UZ": "Uzbekistan", "MM": "Myanmar", "ML": "Mali", "MO": "Macao", "MN": "Mongolia", "MH": "Marshall Islands", "MK": "Macedonia", "MU": "Mauritius", "MT": "Malta", "MW": "Malawi", "MV": "Maldives", "MQ": "Martinique", "MP": "Northern Mariana Islands", "MS": "Montserrat", "MR": "Mauritania", "IM": "Isle of Man", "UG": "Uganda", "TZ": "Tanzania", "MY": "Malaysia", "MX": "Mexico", "IL": "Israel", "FR": "France", "IO": "British Indian Ocean Territory", "SH": "Saint Helena", "FI": "Finland", "FJ": "Fiji", "FK": "Falkland Islands", "FM": "Micronesia", "FO": "Faroe Islands", "NI": "Nicaragua", "NL": "Netherlands", "NO": "Norway", "NA": "Namibia", "VU": "Vanuatu", "NC": "New Caledonia", "NE": "Niger", "NF": "Norfolk Island", "NG": "Nigeria", "NZ": "New Zealand", "NP": "Nepal", "NR": "Nauru", "NU": "Niue", "CK": "Cook Islands", "XK": "Kosovo", "CI": "Ivory Coast", "CH": "Switzerland", "CO": "Colombia", "CN": "China", "CM": "Cameroon", "CL": "Chile", "CC": "Cocos Islands", "CA": "Canada", "CG": "Republic of the Congo", "CF": "Central African Republic", "CD": "Democratic Republic of the Congo", "CZ": "Czech Republic", "CY": "Cyprus", "CX": "Christmas Island", "CR": "Costa Rica", "CW": "Curacao", "CV": "Cape Verde", "CU": "Cuba", "SZ": "Swaziland", "SY": "Syria", "SX": "Sint Maarten", "KG": "Kyrgyzstan", "KE": "Kenya", "SS": "South Sudan", "SR": "Suriname", "KI": "Kiribati", "KH": "Cambodia", "KN": "Saint Kitts and Nevis", "KM": "Comoros", "ST": "Sao Tome and Principe", "SK": "Slovakia", "KR": "South Korea", "SI": "Slovenia", "KP": "North Korea", "KW": "Kuwait", "SN": "Senegal", "SM": "San Marino", "SL": "Sierra Leone", "SC": "Seychelles", "KZ": "Kazakhstan", "KY": "Cayman Islands", "SG": "Singapore", "SE": "Sweden", "SD": "Sudan", "DO": "Dominican Republic", "DM": "Dominica", "DJ": "Djibouti", "DK": "Denmark", "VG": "British Virgin Islands", "DE": "Germany", "YE": "Yemen", "DZ": "Algeria", "US": "United States", "UY": "Uruguay", "YT": "Mayotte", "UM": "United States Minor Outlying Islands", "LB": "Lebanon", "LC": "Saint Lucia", "LA": "Laos", "TV": "Tuvalu", "TW": "Taiwan", "TT": "Trinidad and Tobago", "TR": "Turkey", "LK": "Sri Lanka", "LI": "Liechtenstein", "LV": "Latvia", "TO": "Tonga", "LT": "Lithuania", "LU": "Luxembourg", "LR": "Liberia", "LS": "Lesotho", "TH": "Thailand", "TF": "French Southern Territories", "TG": "Togo", "TD": "Chad", "TC": "Turks and Caicos Islands", "LY": "Libya", "VA": "Vatican", "VC": "Saint Vincent and the Grenadines", "AE": "United Arab Emirates", "AD": "Andorra", "AG": "Antigua and Barbuda", "AF": "Afghanistan", "AI": "Anguilla", "VI": "U.S. Virgin Islands", "IS": "Iceland", "IR": "Iran", "AM": "Armenia", "AL": "Albania", "AO": "Angola", "AQ": "Antarctica", "AS": "American Samoa", "AR": "Argentina", "AU": "Australia", "AT": "Austria", "AW": "Aruba", "IN": "India", "AX": "Aland Islands", "AZ": "Azerbaijan", "IE": "Ireland", "ID": "Indonesia", "UA": "Ukraine", "QA": "Qatar", "MZ": "Mozambique"}

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
"AvoRed\\Ecommerce\\": "src/"
3737
}
3838
},
39+
"autoload-dev" : {
40+
"psr-4" : {
41+
"AvoRed\\Ecommerce\\Tests\\" : "tests/"
42+
}
43+
},
3944
"extra": {
4045
"laravel": {
4146
"providers": [

database/migrations/2017_03_29_000001_avored_ecommerce_schema.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,27 @@ public function up()
2828
$table->timestamp('created_at');
2929
});
3030

31+
Schema::create('roles', function (Blueprint $table) {
32+
$table->increments('id');
33+
$table->string('name')->nullable()->default(null);
34+
$table->text('description')->nullable()->default(null);
35+
$table->timestamps();
36+
});
37+
3138
Schema::create('admin_users', function (Blueprint $table) {
3239
$table->increments('id');
3340
$table->tinyInteger('is_super_admin')->nullable();
34-
$table->integer('role_id');
35-
$table->string('first_name');
36-
$table->string('last_name');
41+
$table->integer('role_id')->unsigned()->default(null);
42+
$table->string('first_name')->nullable();
43+
$table->string('last_name')->nullable();
3744
$table->string('email')->unique();
3845
$table->string('password');
3946
$table->string('language')->nullable()->default('en');
4047
$table->string('image_path')->nullable()->default(null);
4148
$table->rememberToken();
4249
$table->timestamps();
50+
51+
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
4352
});
4453

4554
Schema::create('users', function (Blueprint $table) {
@@ -130,9 +139,9 @@ public function up()
130139

131140
Schema::create('pages', function (Blueprint $table) {
132141
$table->increments('id');
133-
$table->string('name');
134-
$table->string('slug');
135-
$table->text('content');
142+
$table->string('name')->nullable()->default(null);
143+
$table->string('slug')->nullable()->default(null);
144+
$table->text('content')->nullable()->default(null);
136145
$table->string('meta_title')->nullable();
137146
$table->string('meta_description')->nullable();
138147
$table->timestamps();
@@ -148,13 +157,6 @@ public function up()
148157
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
149158
});
150159

151-
Schema::create('roles', function (Blueprint $table) {
152-
$table->increments('id');
153-
$table->string('name');
154-
$table->text('description');
155-
$table->timestamps();
156-
});
157-
158160
Schema::create('permissions', function (Blueprint $table) {
159161
$table->increments('id');
160162
$table->string('name')->unique();
@@ -184,9 +186,9 @@ public function up()
184186
});
185187

186188
Schema::table('orders', function (Blueprint $table) {
187-
$table->integer('user_id')->unsigned();
188-
$table->integer('shipping_address_id')->unsigned();
189-
$table->integer('billing_address_id')->unsigned();
189+
$table->integer('user_id')->unsigned()->nullable();
190+
$table->integer('shipping_address_id')->unsigned()->nullable();
191+
$table->integer('billing_address_id')->unsigned()->nullable();
190192

191193
$table->foreign('user_id')->references('id')->on('users');
192194
$table->foreign('shipping_address_id')->references('id')->on('addresses');
@@ -197,7 +199,7 @@ public function up()
197199
Configuration::create(['configuration_key' => 'general_site_description', 'configuration_value' => 'AvoRed is a free open-source e-commerce application development platform written in PHP based on Laravel. Its an ingenuous and modular e-commerce that is easily customizable according to your needs, with a modern responsive mobile friendly interface as default']);
198200

199201
Configuration::create(['configuration_key' => 'general_site_description', 'configuration_value' => 'AvoRed Laravel Ecommerce']);
200-
$path = public_path().'/countries.json';
202+
$path = __DIR__ .'/../../assets/countries.json';
201203

202204
$json = json_decode(file_get_contents($path), true);
203205
foreach ($json as $code => $name) {

phpunit.dist.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
syntaxCheck="false"
11+
>
12+
<testsuites>
13+
<testsuite name="AvoRed Ecommerce Tests">
14+
<directory suffix=".php">./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<filter>
19+
<whitelist>
20+
<directory suffix=".php">src</directory>
21+
</whitelist>
22+
</filter>
23+
24+
25+
<!--logging>
26+
<log type="coverage-html" target="../../../public/cov" charset="UTF-8"
27+
yui="true" highlight="true"
28+
lowUpperBound="50" highLowerBound="80"/>
29+
</logging-->
30+
</phpunit>

src/Http/Controllers/ConfigurationController.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
class ConfigurationController extends Controller
1212
{
13-
1413
/**
1514
*
1615
* @var \AvoRed\Framework\Models\Repository\ConfigurationRepository
@@ -47,15 +46,9 @@ public function index()
4746
public function store(Request $request)
4847
{
4948
foreach ($request->except(['_token', '_method']) as $key => $value) {
50-
5149
$configModel = $this->repository->findByKey($key);
5250

53-
if ($configModel->configuration_value == $value) {
54-
continue;
55-
}
56-
5751
if (null === $configModel) {
58-
5952
$data['configuration_key'] = $key;
6053
$data['configuration_value'] = $value;
6154

src/Http/Controllers/DashboardController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public function __construct(OrderInterface $repository)
2525
*/
2626
public function index()
2727
{
28+
29+
2830
$value = Configuration::getConfiguration('avored_user_total');
2931
$totalRegisteredUser = (null === $value) ? 0 : $value;
3032

src/Http/Controllers/OrderController.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616

1717
class OrderController extends Controller
1818
{
19-
20-
/**
21-
*
22-
* @var \AvoRed\Framework\Models\Repository\OrderRepository
23-
*/
19+
/**
20+
*
21+
* @var \AvoRed\Framework\Models\Repository\OrderRepository
22+
*/
2423
protected $repository;
2524

2625
public function __construct(OrderInterface $repository)
@@ -41,9 +40,9 @@ public function index()
4140
}
4241

4342
/**
44-
* View an Order Details
43+
* View an Order Details
4544
* @param \AvoRed\Ecommerce\Models\Database\Order $order
46-
*
45+
*
4746
* @return \Illuminate\Http\Response
4847
*/
4948
public function view(Model $order)
@@ -54,19 +53,19 @@ public function view(Model $order)
5453
/**
5554
* Send an Order Invioced PDF to User
5655
* @param \AvoRed\Ecommerce\Models\Database\Order $order
57-
*
56+
*
5857
* @return \Illuminate\Http\RedirectResponse
5958
*/
6059
public function sendEmailInvoice(Model $order)
6160
{
62-
$user = $order->user;
61+
$user = $order->user;
6362
$view = view('avored-ecommerce::mail.order-pdf')->with('order', $order);
6463

6564
$folderPath = public_path('uploads/order/invoice');
66-
if (! File::exists($folderPath)) {
65+
if (!File::exists($folderPath)) {
6766
File::makeDirectory($folderPath, '0775', true, true);
6867
}
69-
$path = $folderPath.DIRECTORY_SEPARATOR.$order->id.'.pdf';
68+
$path = $folderPath . DIRECTORY_SEPARATOR . $order->id . '.pdf';
7069
PDF::loadHTML($view->render())->save($path);
7170

7271
Mail::to($user->email)->send(new OrderInvoicedMail($order, $path));
@@ -77,7 +76,7 @@ public function sendEmailInvoice(Model $order)
7776
/**
7877
* Edit the Order Status View
7978
* @param \AvoRed\Ecommerce\Models\Database\Order $order
80-
*
79+
*
8180
* @return \Illuminate\Http\Response
8281
*/
8382
public function editStatus(Model $order)
@@ -92,15 +91,15 @@ public function editStatus(Model $order)
9291
return $view;
9392
}
9493

95-
/**
94+
/**
9695
* Change the Order Status
9796
* @param \AvoRed\Ecommerce\Models\Database\Order $order
98-
*
97+
*
9998
* @return \Illuminate\Http\RedirectResponse
10099
*/
101100
public function updateStatus(Model $order, UpdateOrderStatusRequest $request)
102101
{
103-
$order = Model::find($id);
102+
//$order = Model::find($id);
104103
$order->update($request->all());
105104

106105
$userEmail = $order->user->email;

tests/BaseTestCase.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace AvoRed\Ecommerce\Tests;
4+
5+
use AvoRed\Ecommerce\Provider;
6+
use AvoRed\Framework\Provider as FrameworkProvider;
7+
use Orchestra\Testbench\TestCase as OrchestraTestCase;
8+
9+
abstract class BaseTestCase extends OrchestraTestCase
10+
{
11+
public function setUp()
12+
{
13+
parent::setUp();
14+
$this->app['config']->set('app.key', 'base64:UTyp33UhGolgzCK5CJmT+hNHcA+dJyp3+oINtX+VoPI=');
15+
$this->app['config']->set('app.url', 'http://localhost:8000/admin');
16+
17+
$this->setUpDatabase();
18+
$this->resetDatabase();
19+
}
20+
21+
private function resetDatabase()
22+
{
23+
$this->artisan('migrate', [
24+
'--database' => 'sqlite',
25+
]);
26+
}
27+
28+
protected function getPackageProviders($app)
29+
{
30+
return [
31+
FrameworkProvider::class,
32+
Provider::class,
33+
];
34+
}
35+
36+
protected function getPackageAliases($app)
37+
{
38+
return [
39+
'Widget' => 'AvoRed\Framework\Widget\Facade'
40+
];
41+
}
42+
43+
/**
44+
* Set up the environment.
45+
*
46+
* @param \Illuminate\Foundation\Application $app
47+
*/
48+
protected function getEnvironmentSetUp($app)
49+
{
50+
$app['config']->set('database.default', 'sqlite');
51+
$app['config']->set('database.connections.sqlite', [
52+
'driver' => 'sqlite',
53+
'database' => ':memory:',
54+
'prefix' => '',
55+
]);
56+
}
57+
58+
protected function setUpDatabase()
59+
{
60+
$this->resetDatabase();
61+
}
62+
}

tests/Controller/LoginTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace AvoRed\Ecommerce\Tests\Controller;
4+
5+
use AvoRed\Ecommerce\Tests\BaseTestCase;
6+
use AvoRed\Ecommerce\Models\Database\AdminUser;
7+
use AvoRed\Ecommerce\Models\Database\Role;
8+
9+
class LoginTest extends BaseTestCase
10+
{
11+
/**
12+
* Test to check if admin login get controller is working
13+
*
14+
* @return void
15+
*/
16+
public function testLoginGetTest()
17+
{
18+
$response = $this->get('login');
19+
$response->assertStatus(200);
20+
$response->assertSee('AvoRed Admin Login');
21+
}
22+
23+
/**
24+
* Test to check if admin login get controller is working
25+
*
26+
* @return void
27+
*/
28+
public function testLoginPostTest()
29+
{
30+
$role = Role::create(['name' => 'Administrator','description' => 'Administrator']);
31+
$user = AdminUser::create(['role_id' => $role->id,
32+
'is_super_admin' => 1,
33+
'first_name' => 'Purvesh',
34+
'last_name' => 'Patel',
35+
'email' => '[email protected]',
36+
'password' => bcrypt('admin123')
37+
]);
38+
39+
$response = $this->post('login', ['email' => '[email protected]', 'password' => 'admin123']);
40+
$response->assertRedirect('admin');
41+
42+
}
43+
}

0 commit comments

Comments
 (0)