Skip to content

Commit

Permalink
Initial implementation for Tests, Configuring of Data Factories
Browse files Browse the repository at this point in the history
  • Loading branch information
zanechua committed Oct 28, 2018
1 parent 50d40d1 commit cd33b57
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Models/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function invoices()
return $this->hasMany('App\Models\Invoice', 'client_id');
}

public function company()
{
return $this->belongsTo('App\Models\Company', 'company_id');
}

public function scopeDuplicateCheck($query, $companyname)
{
return $query
Expand Down
25 changes: 25 additions & 0 deletions database/factories/ClientFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Faker\Generator as Faker;

$factory->define(App\Models\Client::class, function (Faker $faker) {

return [
'companyname' => $faker->company,
'phone' => '+65' . $faker->randomNumber(8),
'block' => $faker->buildingNumber,
'street' => $faker->streetName,
'unitnumber' => $faker->buildingNumber,
'postalcode' => $faker->postcode,
'country' => $faker->country,
'nickname' => $faker->name,
'crn' => $faker->ean8,
'website' => $faker->url,
'contactsalutation' => $faker->title,
'contactfirstname' => $faker->firstName,
'contactlastname' => $faker->lastName,
'contactgender' => 'male',
'contactemail' => $faker->unique()->companyEmail,
'contactphone' => '+65' . $faker->randomNumber(8)
];
});
13 changes: 13 additions & 0 deletions database/factories/CompanyAddressFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'block' => $faker->buildingNumber,
'street' => $faker->streetName,
'unitnumber' => $faker->buildingNumber,
'postalcode' => $faker->postcode,
'buildingtype' => $faker->numberBetween($min = 1, $max = 2),
];
});
15 changes: 15 additions & 0 deletions database/factories/CompanyFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Faker\Generator as Faker;

$factory->define(App\Models\Company::class, function (Faker $faker) {
return [
'name' => $faker->company,
'invoice_index' => $faker->randomDigit,
'quote_index' => $faker->randomDigit,
'slug' => $faker->slug,
'crn' => $faker->ean8,
'phone' => '+65' . $faker->randomNumber(8),
'email' => $faker->unique()->companyEmail,
];
});
13 changes: 13 additions & 0 deletions database/factories/CompanySettingsFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'invoice_prefix' => $faker->domainWord,
'quote_prefix' => $faker->domainWord,
'invoice_conditions' => $faker->realText($maxNbChars = 200, $indexSize = 2),
'quote_conditions' => $faker->realText($maxNbChars = 200, $indexSize = 2),
'tax' => $faker->numberBetween($min = 1, $max = 100),
];
});
16 changes: 16 additions & 0 deletions database/factories/InvoiceFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'nice_invoice_id' => $faker->slug,
'date' => $faker->dateTime,
'duedate' => $faker->dateTime,
'netdays' => $faker->numberBetween($min = 1, $max = 60),
'total' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL),
'share_token' => $faker->uuid,
'status' => $faker->numberBetween($min = 1, $max = 7),
'archived' => $faker->boolean,
];
});
12 changes: 12 additions & 0 deletions database/factories/InvoiceItemFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'name' => $faker->realText($maxNbChars = 20, $indexSize = 1),
'quantity' => $faker->numberBetween($min = 1, $max = 1000),
'price' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL),
'description' => $faker->randomHtml(2,3),
];
});
12 changes: 12 additions & 0 deletions database/factories/ItemTemplateFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'name' => $faker->realText($maxNbChars = 20, $indexSize = 1),
'quantity' => $faker->numberBetween($min = 1, $max = 1000),
'price' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL),
'description' => $faker->randomHtml(2,3),
];
});
16 changes: 16 additions & 0 deletions database/factories/QuoteFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'nice_quote_id' => $faker->slug,
'date' => $faker->dateTime,
'duedate' => $faker->dateTime,
'netdays' => $faker->numberBetween($min = 1, $max = 60),
'total' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL),
'share_token' => $faker->uuid,
'status' => $faker->numberBetween($min = 1, $max = 7),
'archived' => $faker->boolean,
];
});
27 changes: 27 additions & 0 deletions tests/Feature/CreateClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class CreateClientTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testClient()
{
$client = factory(App\Models\Client::class)->make(function ($client) {
$client->company()->save(factory(App\Models\Company::class)->make());
});

$this->assertTrue(true);
}



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

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class CreateInvoiceTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/Feature/CreatePaymentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class CreatePaymentTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/Feature/CreateQuoteTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class CreateQuoteTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/Feature/UpdateCompanyAddressTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UpdateCompanyAddressTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/Feature/UpdateCompanySettingsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UpdateCompanySettingsTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/Feature/UpdateCompanyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UpdateCompanyTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}
20 changes: 20 additions & 0 deletions tests/Feature/UpdateProfileTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UpdateProfileTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
}
}

0 comments on commit cd33b57

Please sign in to comment.