- Fix trigger yaml file to user laravel instead of larave5.

- Remove codeception/module-laravel5 as it was causing trigger testing to fail since it's outdated and we already upgraded factories to laravel 8.
This commit is contained in:
Abdullah Al-Faqeir 2021-10-05 12:37:21 +03:00
parent 2ab4873e5c
commit 7b612ecc67
6 changed files with 138 additions and 175 deletions

View File

@ -43,7 +43,6 @@
"codeception/module-asserts": "^1.1",
"codeception/module-filesystem": "^1.0",
"codeception/module-laravel": "^2.0",
"codeception/module-laravel5": "^1.1",
"codeception/module-webdriver": "^1.0",
"filp/whoops": "^2.0",
"mockery/mockery": "^1.3.1",

55
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b8c13c4e3310a5c05c64b4137d4d314b",
"content-hash": "46b4c37f75642ba14f3a2913f0f345cd",
"packages": [
{
"name": "algolia/algoliasearch-client-php",
@ -9080,59 +9080,6 @@
},
"time": "2021-09-10T04:19:09+00:00"
},
{
"name": "codeception/module-laravel5",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/Codeception/module-laravel5.git",
"reference": "1d8a82f78a6e8c26f49af65d9001fa311785d54b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/module-laravel5/zipball/1d8a82f78a6e8c26f49af65d9001fa311785d54b",
"reference": "1d8a82f78a6e8c26f49af65d9001fa311785d54b",
"shasum": ""
},
"require": {
"codeception/codeception": "^4.0",
"codeception/lib-innerbrowser": "^1.0",
"php": ">=5.6.0 <9.0"
},
"require-dev": {
"codeception/module-asserts": "^1.0",
"codeception/module-rest": "^1.0"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan-Henk Gerritsen"
},
{
"name": "Michael Bodnarchuk"
}
],
"description": "Codeception module for Laravel 5 framework",
"homepage": "http://codeception.com/",
"keywords": [
"codeception",
"laravel5"
],
"support": {
"issues": "https://github.com/Codeception/module-laravel5/issues",
"source": "https://github.com/Codeception/module-laravel5/tree/1.1.1"
},
"time": "2020-10-28T07:00:17+00:00"
},
{
"name": "codeception/module-webdriver",
"version": "1.4.0",

View File

@ -9,6 +9,6 @@ class ProductTableSeeder extends Seeder
{
public function run()
{
dd('running');
//dd('running');
}
}

View File

@ -8,7 +8,7 @@ modules:
- Asserts
- Filesystem
- \Helper\Unit
- Laravel5:
- Laravel:
environment_file: .env.testing
run_database_migrations: true
run_database_seeder: true

View File

@ -15,6 +15,7 @@ class DatabaseLogicCest
/** @var Locale $localeEn */
private $localeEn;
/** @var Locale $localeDe */
private $localeDe;
@ -37,9 +38,10 @@ class DatabaseLogicCest
public function testGetUrlPathOfCategory(UnitTester $I)
{
$rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [
'slug' => 'root',
'slug' => 'root',
'locale' => 'en',
]);
$rootCategory = $I->grabRecord(Category::class, [
'id' => $rootCategoryTranslation->category_id,
]);
@ -51,43 +53,45 @@ class DatabaseLogicCest
'position' => 1,
'status' => 1,
$this->localeEn->code => [
'name' => $parentCategoryName,
'slug' => strtolower($parentCategoryName),
'name' => $parentCategoryName,
'slug' => strtolower($parentCategoryName),
'description' => $parentCategoryName,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
$this->localeDe->code => [
'name' => $parentCategoryName,
'slug' => strtolower($parentCategoryName),
'name' => $parentCategoryName,
'slug' => strtolower($parentCategoryName),
'description' => $parentCategoryName,
'locale_id' => $this->localeDe->id,
'locale_id' => $this->localeDe->id,
],
];
$parentCategory = $I->make(Category::class, $parentCategoryAttributes)->first();
$parentCategory = $I->make(Category::class, $parentCategoryAttributes)
->first();
$rootCategory->prependNode($parentCategory);
$I->assertNotNull($parentCategory);
$categoryName = $this->faker->word;
$categoryName = $this->faker->word;
$categoryAttributes = [
'position' => 1,
'status' => 1,
'parent_id' => $parentCategory->id,
$this->localeEn->code => [
'name' => $categoryName,
'slug' => strtolower($categoryName),
'name' => $categoryName,
'slug' => strtolower($categoryName),
'description' => $categoryName,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
$this->localeDe->code => [
'name' => $categoryName,
'slug' => strtolower($categoryName),
'name' => $categoryName,
'slug' => strtolower($categoryName),
'description' => $categoryName,
'locale_id' => $this->localeDe->id,
'locale_id' => $this->localeDe->id,
],
];
$category = $I->make(Category::class, $categoryAttributes)->first();
$category = $I->make(Category::class, $categoryAttributes)
->first();
$parentCategory->prependNode($category);
$I->assertNotNull($category);
@ -114,12 +118,13 @@ class DatabaseLogicCest
'status' => 1,
'parent_id' => null,
$this->localeEn->code => [
'name' => $this->faker->word,
'slug' => strtolower($this->faker->word),
'name' => $this->faker->word,
'slug' => strtolower($this->faker->word),
'description' => $this->faker->word,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
])->first();
])
->first();
$root2Category->save();
$I->assertNull($root2Category->refresh()->parent_id);

View File

@ -13,23 +13,33 @@ class TriggerCest
private $faker;
private $parentCategory;
private $category;
private $root2Category;
private $childOfRoot2Category;
private $parentCategoryAttributes;
private $categoryAttributes;
private $root2CategoryAttributes;
private $childOfRoot2CategoryAttributes;
private $parentCategoryName;
private $categoryName;
private $root2CategoryName;
private $childOfRoot2CategoryName;
/** @var Locale $localeEn */
private $localeEn;
/** @var Locale $localeDe */
private $localeDe;
@ -38,16 +48,16 @@ class TriggerCest
$this->faker = Factory::create();
$rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [
'slug' => 'root',
'slug' => 'root',
'locale' => 'en',
]);
$rootCategory = $I->grabRecord(Category::class, [
$rootCategory = $I->grabRecord(Category::class, [
'id' => $rootCategoryTranslation->category_id,
]);
$this->parentCategoryName = $this->faker->word;
$this->categoryName = $this->faker->word . $this->faker->randomDigit;
$this->root2CategoryName = $this->faker->word . $this->faker->randomDigit;
$this->parentCategoryName = $this->faker->word;
$this->categoryName = $this->faker->word . $this->faker->randomDigit;
$this->root2CategoryName = $this->faker->word . $this->faker->randomDigit;
$this->childOfRoot2CategoryName = $this->faker->word . $this->faker->randomDigit;
$this->localeEn = $I->grabRecord(Locale::class, [
@ -63,20 +73,21 @@ class TriggerCest
'position' => 1,
'status' => 1,
$this->localeEn->code => [
'name' => $this->parentCategoryName,
'slug' => strtolower($this->parentCategoryName),
'name' => $this->parentCategoryName,
'slug' => strtolower($this->parentCategoryName),
'description' => $this->parentCategoryName,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
$this->localeDe->code => [
'name' => $this->parentCategoryName,
'slug' => strtolower($this->parentCategoryName),
'name' => $this->parentCategoryName,
'slug' => strtolower($this->parentCategoryName),
'description' => $this->parentCategoryName,
'locale_id' => $this->localeDe->id,
'locale_id' => $this->localeDe->id,
],
];
$this->parentCategory = $I->make(Category::class, $this->parentCategoryAttributes)->first();
$this->parentCategory = $I->make(Category::class, $this->parentCategoryAttributes)
->first();
$rootCategory->appendNode($this->parentCategory);
$I->assertNotNull($this->parentCategory);
@ -85,20 +96,21 @@ class TriggerCest
'status' => 1,
'parent_id' => $this->parentCategory->id,
$this->localeEn->code => [
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'description' => $this->categoryName,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
$this->localeDe->code => [
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'description' => $this->categoryName,
'locale_id' => $this->localeDe->id,
'locale_id' => $this->localeDe->id,
],
];
$this->category = $I->make(Category::class, $this->categoryAttributes)->first();
$this->category = $I->make(Category::class, $this->categoryAttributes)
->first();
$this->parentCategory->appendNode($this->category);
$I->assertNotNull($this->category);
@ -108,20 +120,21 @@ class TriggerCest
'status' => 1,
'parent_id' => null,
$this->localeEn->code => [
'name' => $this->root2CategoryName,
'slug' => strtolower($this->root2CategoryName),
'name' => $this->root2CategoryName,
'slug' => strtolower($this->root2CategoryName),
'description' => $this->root2CategoryName,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
$this->localeDe->code => [
'name' => $this->root2CategoryName,
'slug' => strtolower($this->root2CategoryName),
'name' => $this->root2CategoryName,
'slug' => strtolower($this->root2CategoryName),
'description' => $this->root2CategoryName,
'locale_id' => $this->localeDe->id,
'locale_id' => $this->localeDe->id,
],
];
$this->root2Category = $I->make(Category::class, $this->root2CategoryAttributes)->first();
$this->root2Category = $I->make(Category::class, $this->root2CategoryAttributes)
->first();
$this->root2Category->save();
$I->assertNotNull($this->root2Category);
@ -133,20 +146,21 @@ class TriggerCest
'status' => 1,
'parent_id' => $this->root2Category->id,
$this->localeEn->code => [
'name' => $this->childOfRoot2CategoryName,
'slug' => strtolower($this->childOfRoot2CategoryName),
'name' => $this->childOfRoot2CategoryName,
'slug' => strtolower($this->childOfRoot2CategoryName),
'description' => $this->childOfRoot2CategoryName,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
$this->localeDe->code => [
'name' => $this->childOfRoot2CategoryName,
'slug' => strtolower($this->childOfRoot2CategoryName),
'name' => $this->childOfRoot2CategoryName,
'slug' => strtolower($this->childOfRoot2CategoryName),
'description' => $this->childOfRoot2CategoryName,
'locale_id' => $this->localeDe->id,
'locale_id' => $this->localeDe->id,
],
];
$this->childOfRoot2Category = $I->make(Category::class, $this->childOfRoot2CategoryAttributes)->first();
$this->childOfRoot2Category = $I->make(Category::class, $this->childOfRoot2CategoryAttributes)
->first();
$this->root2Category->appendNode($this->childOfRoot2Category);
$I->assertNotNull($this->childOfRoot2Category);
@ -156,47 +170,47 @@ class TriggerCest
{
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->parentCategory->id,
'name' => $this->parentCategoryName,
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName)
'name' => $this->parentCategoryName,
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->parentCategory->id,
'name' => $this->parentCategoryName,
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName)
'name' => $this->parentCategoryName,
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName)
'name' => $this->categoryName,
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName)
'name' => $this->categoryName,
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->root2Category->id,
'name' => $this->root2CategoryName,
'locale' => $this->localeEn->code,
'url_path' => '',
'name' => $this->root2CategoryName,
'locale' => $this->localeEn->code,
'url_path' => '',
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->childOfRoot2Category->id,
'name' => $this->childOfRoot2CategoryName,
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->childOfRoot2CategoryName)
'name' => $this->childOfRoot2CategoryName,
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->childOfRoot2CategoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->childOfRoot2Category->id,
'name' => $this->childOfRoot2CategoryName,
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->childOfRoot2CategoryName)
'name' => $this->childOfRoot2CategoryName,
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->childOfRoot2CategoryName),
]);
}
@ -204,21 +218,21 @@ class TriggerCest
{
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
]);
$newCategoryName = $this->faker->word;
$newCategoryName = $this->faker->word;
$this->categoryAttributes[$this->localeDe->code]['name'] = $newCategoryName;
$this->categoryAttributes[$this->localeDe->code]['slug'] = strtolower($newCategoryName);
$I->assertTrue($this->category->update($this->categoryAttributes));
@ -226,18 +240,18 @@ class TriggerCest
$I->dontSeeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $newCategoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
'name' => $newCategoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $newCategoryName,
'slug' => strtolower($newCategoryName),
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($newCategoryName),
'name' => $newCategoryName,
'slug' => strtolower($newCategoryName),
'locale' => $this->localeDe->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($newCategoryName),
]);
}
@ -245,46 +259,46 @@ class TriggerCest
{
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->parentCategory->id,
'name' => $this->parentCategoryName,
'slug' => strtolower($this->parentCategoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName),
'name' => $this->parentCategoryName,
'slug' => strtolower($this->parentCategoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName),
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . $this->categoryName,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . $this->categoryName,
]);
}
public function testUpdateTriggersOnCategoriesTable(UnitTester $I)
{
$I->seeRecord(Category::class, [
'id' => $this->category->id,
'id' => $this->category->id,
'parent_id' => $this->parentCategory->id,
]);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName),
]);
$category2Name = $this->faker->word;
$category2Name = $this->faker->word;
$category2Attributes = [
'position' => 1,
'status' => 1,
'parent_id' => $this->parentCategory->id,
'position' => 1,
'status' => 1,
'parent_id' => $this->parentCategory->id,
$this->localeEn->code => [
'name' => $category2Name,
'slug' => strtolower($category2Name),
'name' => $category2Name,
'slug' => strtolower($category2Name),
'description' => $category2Name,
'locale_id' => $this->localeEn->id,
'locale_id' => $this->localeEn->id,
],
];
@ -295,15 +309,13 @@ class TriggerCest
$I->assertTrue($this->category->update($this->categoryAttributes));
$this->category->refresh();
$expectedUrlPath = strtolower($this->parentCategoryName) . '/'
. strtolower($category2Name) . '/'
. strtolower($this->categoryName);
$expectedUrlPath = strtolower($this->parentCategoryName) . '/' . strtolower($category2Name) . '/' . strtolower($this->categoryName);
$I->seeRecord(CategoryTranslation::class, [
'category_id' => $this->category->id,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => $expectedUrlPath,
'name' => $this->categoryName,
'slug' => strtolower($this->categoryName),
'locale' => $this->localeEn->code,
'url_path' => $expectedUrlPath,
]);
}
}