Skip to content

Commit 46674eb

Browse files
authored
Adapt configuration group names to Yii conventions (#71)
1 parent 58f11d4 commit 46674eb

File tree

7 files changed

+76
-17
lines changed

7 files changed

+76
-17
lines changed

.github/workflows/bc.yml

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
on:
2-
pull_request:
3-
push:
2+
- pull_request
3+
- push
44

55
name: backwards compatibility
6+
67
jobs:
78
roave_bc_check:
8-
name: Roave BC Check
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@master
12-
- name: fetch tags
13-
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
14-
- name: Roave BC Check
15-
uses: docker://nyholm/roave-bc-check-ga
9+
uses: yiisoft/actions/.github/workflows/bc.yml@master
10+
with:
11+
os: >-
12+
['ubuntu-latest']
13+
php: >-
14+
['8.0']

CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Yii Data Response Change Log
22

3-
## 1.0.2 under development
3+
## 2.0.0 under development
44

5-
- Chg #62: Update `yiisoft/http` dependency (devanych)
5+
- Chg #62: Update `yiisoft/http` dependency (@devanych)
6+
- Chg #71: Adapt configuration group names to Yii conventions (@vjik)
67

78
## 1.0.1 August 30, 2021
89

9-
- Chg: Use definitions from `yiisoft/definitions` in configuration (samdark)
10+
- Chg: Use definitions from `yiisoft/definitions` in configuration (@samdark)
1011

1112
## 1.0.0 June 21, 2021
1213

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"phpunit/phpunit": "^9.5",
3333
"roave/infection-static-analysis-plugin": "^1.16",
3434
"spatie/phpunit-watcher": "^1.23",
35-
"vimeo/psalm": "^4.30|^5.3"
35+
"vimeo/psalm": "^4.30|^5.3",
36+
"yiisoft/di": "^1.1"
3637
},
3738
"autoload": {
3839
"psr-4": {
@@ -50,7 +51,7 @@
5051
},
5152
"config-plugin": {
5253
"params": "params.php",
53-
"web": "web.php"
54+
"di-web": "di-web.php"
5455
}
5556
},
5657
"config": {

config/web.php config/di-web.php

File renamed without changes.

psalm.xml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0"?>
22
<psalm
33
errorLevel="1"
4+
findUnusedBaselineEntry="true"
5+
findUnusedCode="false"
46
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
57
xmlns="https://getpsalm.org/schema/config"
68
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"

tests/ConfigTest.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\DataResponse\Tests;
6+
7+
use Psr\Http\Message\ResponseFactoryInterface;
8+
use Psr\Http\Message\StreamFactoryInterface;
9+
use Yiisoft\DataResponse\DataResponseFactory;
10+
use Yiisoft\DataResponse\DataResponseFactoryInterface;
11+
use Yiisoft\DataResponse\DataResponseFormatterInterface;
12+
use Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter;
13+
use Yiisoft\DataResponse\Middleware\ContentNegotiator;
14+
use Yiisoft\Di\Container;
15+
use Yiisoft\Di\ContainerConfig;
16+
17+
final class ConfigTest extends \PHPUnit\Framework\TestCase
18+
{
19+
public function testDiWeb(): void
20+
{
21+
$container = $this->createContainer('web');
22+
23+
$dataResponseFormatter = $container->get(DataResponseFormatterInterface::class);
24+
$dataResponseFactory = $container->get(DataResponseFactoryInterface::class);
25+
$contentNegotiator = $container->get(ContentNegotiator::class);
26+
27+
$this->assertInstanceOf(HtmlDataResponseFormatter::class, $dataResponseFormatter);
28+
$this->assertInstanceOf(DataResponseFactory::class, $dataResponseFactory);
29+
$this->assertInstanceOf(ContentNegotiator::class, $contentNegotiator);
30+
}
31+
32+
private function createContainer(?string $postfix = null): Container
33+
{
34+
return new Container(
35+
ContainerConfig::create()->withDefinitions(
36+
$this->getDiConfig($postfix)
37+
+
38+
[
39+
ResponseFactoryInterface::class => $this->createMock(ResponseFactoryInterface::class),
40+
StreamFactoryInterface::class => $this->createMock(StreamFactoryInterface::class),
41+
]
42+
)
43+
);
44+
}
45+
46+
private function getDiConfig(?string $postfix = null): array
47+
{
48+
$params = $this->getParams();
49+
return require dirname(__DIR__) . '/config/di' . ($postfix !== null ? '-' . $postfix : '') . '.php';
50+
}
51+
52+
private function getParams(): array
53+
{
54+
return require dirname(__DIR__) . '/config/params.php';
55+
}
56+
}

tests/Middleware/ContentNegotiatorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testNotExistsFormatter(): void
7575
public function testWrongContentFormattersInConstructor(): void
7676
{
7777
$this->expectException(RuntimeException::class);
78-
$this->expectErrorMessage(
78+
$this->expectExceptionMessage(
7979
'Invalid formatter. A "Yiisoft\DataResponse\DataResponseFormatterInterface"'
8080
. ' instance is expected, "stdClass" is received.'
8181
);
@@ -88,7 +88,7 @@ public function testWrongContentFormattersInConstructor(): void
8888
public function testWrongContentFormattersInSetter(): void
8989
{
9090
$this->expectException(RuntimeException::class);
91-
$this->expectErrorMessage('Invalid formatter content type. A string is expected, "integer" is received.');
91+
$this->expectExceptionMessage('Invalid formatter content type. A string is expected, "integer" is received.');
9292
$middleware = new ContentNegotiator($this->getContentFormatters());
9393
$middleware->withContentFormatters([
9494
'text/html' => new HtmlDataResponseFormatter(),

0 commit comments

Comments
 (0)