Skip to content

Commit 22801dd

Browse files
Add testing setup
1 parent 3e6cdf8 commit 22801dd

Some content is hidden

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

41 files changed

+1277
-107
lines changed

.github/workflows/codeception.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
push:
3+
branches: [master]
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
codeception:
9+
runs-on: ubuntu-latest
10+
11+
services:
12+
mysql-service:
13+
image: mysql:5.7
14+
env:
15+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
16+
MYSQL_DATABASE: craft-test
17+
ports:
18+
- 33306:3306
19+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '7.2'
27+
extensions: mbstring, intl
28+
tools: composer:v2
29+
coverage: none
30+
31+
- name: Get composer cache directory
32+
id: composer-cache
33+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
34+
35+
- name: Cache dependencies
36+
uses: actions/cache@v2
37+
with:
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: ${{ runner.os }}-composer-
41+
42+
- name: Install dependencies
43+
run: composer install --prefer-dist
44+
45+
- name: Execute codeception
46+
run: |
47+
cp tests/.env.example.mysql tests/.env
48+
chmod -R 777 tests/_craft/storage
49+
composer run test

.travis.yml

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

codeception.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ coverage:
2020
- src/translations/*
2121
params:
2222
- tests/.env
23+
2324
modules:
2425
config:
2526
\craft\test\Craft:
@@ -29,8 +30,10 @@ modules:
2930
migrations: []
3031
fullMock: false
3132
plugins:
32-
- handle: contentfield
33-
- handle: redactor
33+
- class: lenz\contentfield\Plugin
34+
handle: contentfield
35+
- class: craft\redactor\Plugin
36+
handle: redactor
3437

3538
# Should tests and fixtures be cleaned
3639
cleanup: true
@@ -43,9 +46,5 @@ modules:
4346
clean: true
4447
setupCraft: true
4548

46-
DataFactory:
47-
factories: tests/_craft/config/factories
48-
depends: \craft\test\Craft
49-
5049
groups:
5150
fields: [tests/unit/fieldTypes]

composer.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
"symfony/yaml": "^5.2.2"
1616
},
1717
"require-dev": {
18-
"codeception/codeception": "^4.1.16",
19-
"codeception/mockery-module": "^0.4",
20-
"codeception/specify": "^1.4.0",
21-
"codeception/verify": "^2.1.1",
22-
"vlucas/phpdotenv": "^5.3.0",
23-
"league/factory-muffin": "^3.3.0",
24-
"fzaninotto/faker": "^1.9.2",
25-
"solspace/craft3-calendar": "^3.1"
18+
"codeception/codeception": "^4.0.0",
19+
"codeception/module-asserts": "^1.0.0",
20+
"codeception/module-datafactory": "^1.0.0",
21+
"codeception/module-yii2": "^1.0.0",
22+
"vlucas/phpdotenv": "^3.0"
2623
},
2724
"autoload": {
2825
"psr-4": {

tests/_bootstrap.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
ini_set('date.timezone', 'UTC');
66

77
// Use the current installation of Craft
8-
define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage');
9-
define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates');
108
define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config');
119
define('CRAFT_MIGRATIONS_PATH', __DIR__ . '/_craft/migrations');
10+
define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage');
11+
define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates');
12+
define('CRAFT_TESTS_PATH', __DIR__);
1213
define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations');
13-
define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor');
14+
define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor');
1415

1516
TestSetup::configureCraft();

tests/_craft/config/factories/factories.php

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

tests/fixtures/AssetsFixture.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace lenz\contentfield\tests\fixtures;
4+
5+
use craft\test\fixtures\elements\AssetFixture;
6+
7+
/**
8+
* Class AssetsFixture.
9+
*/
10+
class AssetsFixture extends AssetFixture
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public $dataFile = __DIR__ . '/data/assets.php';
16+
17+
/**
18+
* @inheritdoc
19+
*/
20+
public $depends = [VolumesFixture::class, VolumesFolderFixture::class];
21+
}

tests/fixtures/EntryFixture.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace lenz\contentfield\tests\fixtures;
4+
5+
use craft\test\fixtures\elements\EntryFixture as BaseEntriesFixture;
6+
7+
/**
8+
* Class EntryFixture
9+
*/
10+
class EntryFixture extends BaseEntriesFixture
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public $dataFile = __DIR__ . '/data/entries.php';
16+
17+
/**
18+
* @inheritdoc
19+
*/
20+
public $depends = [SectionsFixture::class, EntryTypeFixture::class];
21+
}

tests/fixtures/EntryTypeFixture.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace lenz\contentfield\tests\fixtures;
4+
5+
use craft\records\EntryType;
6+
use craft\test\Fixture;
7+
8+
/**
9+
* Class EntryTypeFixture
10+
*/
11+
class EntryTypeFixture extends Fixture
12+
{
13+
/**
14+
* @inheritdoc
15+
*/
16+
public $dataFile = __DIR__ . '/data/entry-types.php';
17+
18+
/**
19+
* @inheritdoc
20+
*/
21+
public $modelClass = EntryType::class;
22+
23+
/**
24+
* @inheritdoc
25+
*/
26+
public $depends = [FieldLayoutFixture::class, SectionsFixture::class];
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace lenz\contentfield\tests\fixtures;
4+
5+
use craft\test\fixtures\elements\EntryFixture as BaseEntriesFixture;
6+
7+
/**
8+
* Class EntryWithFieldsFixture
9+
*/
10+
class EntryWithFieldsFixture extends BaseEntriesFixture
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public $dataFile = __DIR__ . '/data/entry-with-fields.php';
16+
17+
/**
18+
* @inheritdoc
19+
*/
20+
public $depends = [FieldLayoutFixture::class, SectionsFixture::class, EntryTypeFixture::class];
21+
}

0 commit comments

Comments
 (0)