Skip to content
Snippets Groups Projects
Commit 54ff6f77 authored by Tobias Gross-Vogt's avatar Tobias Gross-Vogt
Browse files

first version with linter fixes

parent 2224026f
No related branches found
No related tags found
No related merge requests found
Pipeline #86044 failed
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Service;
use Dbp\Relay\CourseBundle\Entity\Course;
class ExternalApi implements CourseProviderInterface
{
private $courses;
public function __construct(MyCustomService $service)
{
// Make phpstan happy
$service = $service;
$this->courses = [];
$course1 = new Course();
$course1->setIdentifier('graz');
$course1->setName('Graz');
$course2 = new Course();
$course2->setIdentifier('vienna');
$course2->setName('Vienna');
$this->courses[] = $course1;
$this->courses[] = $course2;
}
public function getCourseById(string $identifier): ?Course
{
foreach ($this->courses as $course) {
if ($course->getIdentifier() === $identifier) {
return $course;
}
}
return null;
}
public function getCourses(): array
{
return $this->courses;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Service;
class MyCustomService
{
private $someConfig;
public function __construct(string $someConfig)
{
$this->$someConfig = $someConfig;
}
}
...@@ -4,23 +4,15 @@ declare(strict_types=1); ...@@ -4,23 +4,15 @@ declare(strict_types=1);
namespace Dbp\Relay\CourseBundle\Tests\Service; namespace Dbp\Relay\CourseBundle\Tests\Service;
use Dbp\Relay\CourseBundle\Service\ExternalApi;
use Dbp\Relay\CourseBundle\Service\MyCustomService;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ExternalApiTest extends WebTestCase class ExternalApiTest extends WebTestCase
{ {
private $api;
protected function setUp(): void protected function setUp(): void
{ {
$service = new MyCustomService('test-42');
$this->api = new ExternalApi($service);
} }
public function test() public function test()
{ {
$this->assertTrue(true);
$this->assertNotNull($this->api);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment