Skip to content

Commit cd28eea

Browse files
committed
feat: adding first tests, adding codecov.io support
1 parent 1f67fad commit cd28eea

File tree

6 files changed

+153
-26
lines changed

6 files changed

+153
-26
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ jobs:
5353
run: make cs-diff
5454

5555
- name: Execute phpunit and pest tests
56-
run: make test
56+
run: make test-cc
57+
env:
58+
XDEBUG_MODE: coverage
59+
60+
- name: Send code coverage report to codecov.io
61+
env:
62+
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
63+
run: "bash <(curl -s https://codecov.io/bash)"
5764

5865
- name: Run static analysis using phpstan
5966
run: make stan-ci

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"cycle/migrations": "^3.0",
2222
"cycle/orm": "^2.2",
2323
"cycle/schema-renderer": "^1.1",
24-
"illuminate/contracts": "^9.20"
24+
"illuminate/contracts": "^9.20",
25+
"spiral/tokenizer": "^2.13"
2526
},
2627
"require-dev": {
2728
"ergebnis/composer-normalize": "^2.28",

composer.lock

Lines changed: 93 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/cycle.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@
9292
'directory' => database_path('migrations'),
9393
'table' => env('DB_MIGRATIONS_TABLE', 'migrations'),
9494
],
95+
96+
'relations' => [
97+
// ...
98+
],
9599
];

src/Bridge/Laravel/Providers/CycleServiceProvider.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use Cycle\Database\DatabaseProviderInterface;
1010
use Cycle\ORM\SchemaInterface;
1111
use Illuminate\Contracts\Config\Repository as IlluminateConfig;
12+
use Illuminate\Contracts\Container\Container;
1213
use Illuminate\Support\ServiceProvider;
14+
use Spiral\Tokenizer\Tokenizer;
1315
use WayOfDev\Cycle\Config;
1416
use WayOfDev\Cycle\Contracts\Config\Repository as ConfigRepository;
1517
use WayOfDev\Cycle\Contracts\EntityManager;
@@ -41,6 +43,8 @@ public function register(): void
4143
$this->registerDatabaseManager();
4244
$this->registerEntityManager();
4345
$this->registerDatabaseSchema();
46+
$this->registerOrm();
47+
$this->registerTokenizer();
4448
}
4549

4650
private function registerConsoleCommands(): void
@@ -52,7 +56,7 @@ private function registerConsoleCommands(): void
5256

5357
private function registerAdapterConfig(): void
5458
{
55-
$this->app->singleton(ConfigRepository::class, static function ($app): ConfigRepository {
59+
$this->app->singleton(ConfigRepository::class, static function (Container $app): ConfigRepository {
5660
/** @var IlluminateConfig $config */
5761
$config = $app[IlluminateConfig::class];
5862

@@ -62,7 +66,7 @@ private function registerAdapterConfig(): void
6266

6367
private function registerDatabaseConfig(): void
6468
{
65-
$this->app->singleton(DatabaseConfig::class, static function ($app): DatabaseConfig {
69+
$this->app->singleton(DatabaseConfig::class, static function (Container $app): DatabaseConfig {
6670
/** @var IlluminateConfig $config */
6771
$config = $app[IlluminateConfig::class];
6872

@@ -72,7 +76,7 @@ private function registerDatabaseConfig(): void
7276

7377
private function registerDatabaseManager(): void
7478
{
75-
$this->app->singleton(DatabaseProviderInterface::class, function ($app): DatabaseProviderInterface {
79+
$this->app->singleton(DatabaseProviderInterface::class, static function (Container $app): DatabaseProviderInterface {
7680
return new DatabaseManager(
7781
$app[DatabaseConfig::class]
7882
);
@@ -83,15 +87,30 @@ private function registerDatabaseManager(): void
8387

8488
private function registerEntityManager(): void
8589
{
86-
$this->app->singleton(EntityManager::class, function ($app): EntityManager {
90+
$this->app->singleton(EntityManager::class, static function (Container $app): EntityManager {
8791
return $app[Manager::class];
8892
});
8993
}
9094

9195
private function registerDatabaseSchema(): void
9296
{
93-
$this->app->singleton(SchemaInterface::class, function ($app): SchemaInterface {
97+
$this->app->singleton(SchemaInterface::class, static function (Container $app): SchemaInterface {
9498
return $app[SchemaManagerContract::class]->create();
9599
});
96100
}
101+
102+
private function registerOrm(): void
103+
{
104+
// @todo implement...
105+
}
106+
107+
private function registerTokenizer(): void
108+
{
109+
$this->app->singleton(Tokenizer::class, static function (Container $app): Tokenizer {
110+
/** @var IlluminateConfig $config */
111+
$config = $app[IlluminateConfig::class];
112+
113+
return new Tokenizer($config->get('cycle'));
114+
});
115+
}
97116
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WayOfDev\Cycle\Tests\Bridge\Laravel\Providers;
6+
7+
use WayOfDev\Cycle\Contracts\Config\Repository as ConfigRepository;
8+
use WayOfDev\Cycle\Tests\TestCase;
9+
10+
class CycleServiceProviderTest extends TestCase
11+
{
12+
/**
13+
* @test
14+
*/
15+
public function it_should_get_adapter_config_instance_from_container(): void
16+
{
17+
$config = $this->app->make(ConfigRepository::class);
18+
19+
self::assertInstanceOf(ConfigRepository::class, $config);
20+
self::assertEquals(app_path(), $config->directories()[0]);
21+
}
22+
}

0 commit comments

Comments
 (0)