HummingBirdAnimeClient/tests/Model/AnimeCollectionModelTest.php

77 lines
1.8 KiB
PHP
Raw Normal View History

2015-10-01 16:02:51 -04:00
<?php
use Aviat\Ion\Config;
2015-10-01 16:02:51 -04:00
use Aviat\Ion\Friend;
2015-10-01 16:02:51 -04:00
use Aviat\AnimeClient\Model\AnimeCollection as AnimeCollectionModel;
class AnimeCollectionModelTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->container->setInstance('config', new Config([
2015-10-01 16:02:51 -04:00
'database' => [
'collection' => [
'type' => 'sqlite',
'host' => '',
'user' => '',
'pass' => '',
'port' => '',
'name' => 'default',
'database' => '',
'file' => ':memory:',
]
]
]));
$this->config = $this->container->get('config');
$this->collectionModel = new AnimeCollectionModel($this->container);
}
public function testSanity()
{
$friend = new Friend($this->collectionModel);
$this->assertInstanceOf('Aviat\Ion\Model\DB', $this->collectionModel);
2015-10-01 16:02:51 -04:00
$this->assertInstanceOf('Aviat\AnimeClient\Model\Anime', $friend->anime_model);
}
public function testInvalidDatabase()
{
$this->container->setInstance('config', new Config([
2015-10-01 16:02:51 -04:00
'database' => [
'collection' => [
'type' => 'sqlite',
'host' => '',
'user' => '',
'pass' => '',
'port' => '',
'name' => 'default',
'database' => '',
'file' => __FILE__,
]
]
]));
$collectionModel = new Friend(new AnimeCollectionModel($this->container));
$this->assertFalse($collectionModel->valid_database);
}
2015-10-21 15:43:51 -04:00
public function testNonExistentDatabase()
{
$this->container->setInstance('config', new Config([
2015-10-21 15:43:51 -04:00
'database' => [
'collection' => [
'type' => 'sqlite',
'host' => '',
'user' => '',
'pass' => '',
'port' => '',
'name' => 'default',
'database' => '',
'file' => '/foo/bar/baz/foobazbar.db',
]
]
]));
$collectionModel = new Friend(new AnimeCollectionModel($this->container));
$this->assertFalse($collectionModel->valid_database);
}
2015-10-01 16:02:51 -04:00
}