Skip to content

Commit 8676ecd

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 7cf67e6 + f3b8ec7 commit 8676ecd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+573
-482
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,22 @@ jobs:
1111
strategy:
1212
matrix:
1313
include:
14-
- php: 8.0
14+
- php: 8.3
1515
env:
16-
LARAVEL: 8.*
17-
TESTBENCH: 6.*
18-
- php: 8.1
16+
LARAVEL: 11.*
17+
TESTBENCH: 9.*
18+
- php: 8.4
1919
env:
20-
LARAVEL: 8.*
21-
TESTBENCH: 6.*
22-
- php: 8.1
20+
LARAVEL: 11.*
21+
TESTBENCH: 9.*
22+
- php: 8.4
2323
env:
24-
LARAVEL: 9.*
25-
TESTBENCH: 7.*
26-
- php: 8.2
27-
env:
28-
LARAVEL: 10.*
29-
TESTBENCH: 8.*
24+
LARAVEL: 12.*
25+
TESTBENCH: 10.*
3026
env: ${{ matrix.env }}
27+
name: P${{ matrix.php }} - L${{ matrix.env.LARAVEL }} - TB${{ matrix.env.TESTBENCH }}
3128
steps:
32-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
3330
- name: Setup PHP
3431
uses: shivammathur/setup-php@v2
3532
with:
@@ -39,7 +36,7 @@ jobs:
3936
id: composer-cache
4037
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
4138
- name: Cache composer dependencies
42-
uses: actions/cache@v1
39+
uses: actions/cache@v4
4340
with:
4441
path: ${{ steps.composer-cache.outputs.dir }}
4542
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ composer.lock
77
.env.php
88
.env
99
.phpunit.result.cache
10-
.DS_Store
10+
.DS_Store
11+
phpunit.xml.bak

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
"email": "[email protected]"
1010
}],
1111
"require": {
12-
"php": "^8.0|^8.1|^8.2",
13-
"laravel/framework": "^8.0|^9.0|^10.0",
14-
"nesbot/carbon": "^2.0",
12+
"php": "^8.2|^8.3|^8.4",
13+
"laravel/framework": "^10.0|^11.0|^12.0",
14+
"nesbot/carbon": "^2.0|^3.0",
1515
"maatwebsite/excel": "^3.1",
16-
"ext-zip": "*",
17-
"laravel/legacy-factories": "^1.1"
16+
"ext-zip": "*"
1817
},
1918
"require-dev": {
2019
"fakerphp/faker": "^1.19.0",
2120
"mockery/mockery": "^1.3.0",
22-
"phpunit/phpunit": "^9.5",
23-
"doctrine/dbal": "~2.5",
24-
"orchestra/testbench": "6.*|7.*|8.*",
25-
"code16/sharp": "^8.0",
21+
"phpunit/phpunit": "^10.0|^11.0",
22+
"doctrine/dbal": "^3.0",
23+
"orchestra/testbench": "6.*|7.*|8.*|9.*|10.*",
24+
"code16/sharp": "^9.0",
2625
"ext-json": "*"
2726
},
2827
"autoload": {
2928
"psr-4": {
30-
"Code16\\Formoj\\": "src/"
29+
"Code16\\Formoj\\": "src/",
30+
"Code16\\Formoj\\Database\\Factories\\": "database/factories/"
3131
}
3232
},
3333
"minimum-stability": "dev",

database/factories/AnswerFactory.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Code16\Formoj\Database\Factories;
4+
5+
use Code16\Formoj\Models\Answer;
6+
use Code16\Formoj\Models\Form;
7+
use Illuminate\Database\Eloquent\Factories\Factory;
8+
9+
class AnswerFactory extends Factory
10+
{
11+
/**
12+
* The name of the factory's corresponding model.
13+
*
14+
* @var string
15+
*/
16+
protected $model = Answer::class;
17+
18+
/**
19+
* Define the model's default state.
20+
*
21+
* @return array
22+
*/
23+
public function definition()
24+
{
25+
return [
26+
'content' => [
27+
"field 1" => $this->faker->sentence
28+
],
29+
'form_id' => function() {
30+
return Form::factory()->create()->id;
31+
}
32+
];
33+
}
34+
}

database/factories/FieldFactory.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace Code16\Formoj\Database\Factories;
4+
5+
use Code16\Formoj\Models\Field;
6+
use Code16\Formoj\Models\Section;
7+
use Illuminate\Database\Eloquent\Factories\Factory;
8+
use Illuminate\Support\Str;
9+
10+
class FieldFactory extends Factory
11+
{
12+
/**
13+
* The name of the factory's corresponding model.
14+
*
15+
* @var string
16+
*/
17+
protected $model = Field::class;
18+
19+
/**
20+
* Define the model's default state.
21+
*
22+
* @return array
23+
*/
24+
public function definition()
25+
{
26+
$type = $attributes["type"] ?? $this->faker->randomElement([
27+
\Code16\Formoj\Models\Field::TYPE_TEXT,
28+
\Code16\Formoj\Models\Field::TYPE_TEXTAREA,
29+
\Code16\Formoj\Models\Field::TYPE_SELECT,
30+
\Code16\Formoj\Models\Field::TYPE_UPLOAD,
31+
\Code16\Formoj\Models\Field::TYPE_RATING,
32+
]);
33+
34+
$fieldAttributes = [];
35+
36+
if($type == \Code16\Formoj\Models\Field::TYPE_SELECT) {
37+
for($i=0; $i<rand(3, 12); $i++) {
38+
$fieldAttributes["options"][] = $this->faker->word;
39+
}
40+
if($this->faker->boolean(40)) {
41+
$fieldAttributes["multiple"] = true;
42+
$fieldAttributes["max_options"] = $this->faker->boolean() ? $this->faker->numberBetween(2, 4) : null;
43+
}
44+
} elseif($type == \Code16\Formoj\Models\Field::TYPE_UPLOAD) {
45+
$fieldAttributes["max_size"] = 4;
46+
$fieldAttributes["accept"] = ".jpeg,.jpg,.gif,.png,.pdf";
47+
} elseif ($type == \Code16\Formoj\Models\Field::TYPE_RATING) {
48+
$fieldAttributes["lowest_label"] = $this->faker->word;
49+
$fieldAttributes["highest_label"] = $this->faker->word;
50+
}
51+
52+
$label = $this->faker->words(3, true);
53+
54+
return [
55+
'label' => $label,
56+
'identifier' => Str::slug($label,'_'),
57+
'help_text' => $this->faker->boolean(25) ? $this->faker->paragraph : null,
58+
'type' => $type,
59+
'field_attributes' => $fieldAttributes,
60+
'required' => $type == \Code16\Formoj\Models\Field::TYPE_HEADING ? false : $this->faker->boolean(40),
61+
'section_id' => function() {
62+
return Section::factory()->create()->id;
63+
}
64+
];
65+
}
66+
}

database/factories/FormFactory.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Code16\Formoj\Database\Factories;
4+
5+
use Code16\Formoj\Models\Form;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
8+
class FormFactory extends Factory
9+
{
10+
/**
11+
* The name of the factory's corresponding model.
12+
*
13+
* @var string
14+
*/
15+
protected $model = Form::class;
16+
17+
/**
18+
* Define the model's default state.
19+
*
20+
* @return array
21+
*/
22+
public function definition()
23+
{
24+
$hasPublishedDate = $this->faker->boolean();
25+
$publishedDate = $hasPublishedDate ? $this->faker->dateTimeBetween('-10 days', '+5 days') : null;
26+
$unpublishedDate = $this->faker->boolean()
27+
? ($hasPublishedDate ? $this->faker->dateTimeBetween($publishedDate, '+15 days') : $this->faker->dateTimeBetween('-10 days', '+5 days'))
28+
: null;
29+
30+
return [
31+
'title' => $this->faker->words(2, true),
32+
'is_title_hidden' => $this->faker->boolean(),
33+
'description' => $this->faker->paragraph,
34+
'published_at' => $publishedDate,
35+
'unpublished_at' => $unpublishedDate,
36+
];
37+
}
38+
}

database/factories/FormojFactory.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

database/factories/SectionFactory.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Code16\Formoj\Database\Factories;
4+
5+
use Code16\Formoj\Models\Form;
6+
use Code16\Formoj\Models\Section;
7+
use Illuminate\Database\Eloquent\Factories\Factory;
8+
9+
class SectionFactory extends Factory
10+
{
11+
/**
12+
* The name of the factory's corresponding model.
13+
*
14+
* @var string
15+
*/
16+
protected $model = Section::class;
17+
18+
/**
19+
* Define the model's default state.
20+
*
21+
* @return array
22+
*/
23+
public function definition()
24+
{
25+
return [
26+
'title' => $this->faker->words(3, true),
27+
'is_title_hidden' => $this->faker->boolean(),
28+
'description' => $this->faker->paragraph,
29+
'form_id' => function() {
30+
return Form::factory()->create()->id;
31+
}
32+
];
33+
}
34+
}

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<testsuites>
44
<testsuite name="Unit">
55
<directory suffix="Test.php">./tests/Unit</directory>

prototipoj/app/Providers/AppServiceProvider.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Providers;
44

55
use Code16\Formoj\FormojServiceProvider;
6-
use Illuminate\Database\Eloquent\Factory;
76
use Illuminate\Support\ServiceProvider;
87

98
class AppServiceProvider extends ServiceProvider
@@ -25,7 +24,5 @@ public function register()
2524
*/
2625
public function boot()
2726
{
28-
$this->app->make(Factory::class)
29-
->load(__DIR__ . '/../../../database/factories');
3027
}
3128
}

0 commit comments

Comments
 (0)