Skip to content

Commit

Permalink
added functional test for simple config (no DI)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Feb 8, 2017
1 parent 045478b commit 8d26e37
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" bootstrap="tests/_bootstrap.php">
<testsuites>
<testsuite name="Functional Test Suite">
<directory>./tests/functional/</directory>
</testsuite>
<testsuite name="Unit Test Suite">
<directory>./tests/unit/</directory>
</testsuite>
Expand Down
47 changes: 47 additions & 0 deletions tests/functional/SimpleConfigTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace hiqdev\hiart\tests\functional;

use hiqdev\hiart\curl\Request;
use hiqdev\hiart\rest\Connection;
use Yii;
use yii\console\Application;

class SimpleConfigTest extends \PHPUnit\Framework\TestCase
{
protected $simpleConfig = [
'id' => 'hiart-simple-config',
'basePath' => __DIR__,
'components' => [
'hiart' => [
'class' => Connection::class,
'requestClass' => Request::class,
'baseUri' => 'https://site.com/api/v3/',
],
],
];

private $app;
private $container;

public function setUp()
{
$this->app = Yii::$app;
$this->container = Yii::$container;
Yii::$app = new Application($this->simpleConfig);
Yii::$container = new yii\di\Container();
}

public function tearDown()
{
Yii::$app = $this->app;
Yii::$container = $this->container;
}

public function testGetDb()
{
$db = Connection::getDb();
$this->assertInstanceOf(Connection::class, $db);
$this->assertSame(Request::class, $db->requestClass);
}
}

0 comments on commit 8d26e37

Please sign in to comment.