-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functional test for simple config (no DI)
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |