Add favorite characters to user page, see #27

This commit is contained in:
Timothy Warren 2017-03-31 14:15:29 -04:00
parent 82c86b7b47
commit ca402bd826
4 changed files with 50 additions and 67 deletions

View File

@ -6,6 +6,9 @@
<br /> <br />
<br /> <br />
<table class="media_details"> <table class="media_details">
<tr>
<th colspan="2">General</th>
</tr>
<tr> <tr>
<td>Location</td> <td>Location</td>
<td><?= $attributes['location'] ?></td> <td><?= $attributes['location'] ?></td>
@ -18,7 +21,7 @@
<tr> <tr>
<td><?= $escape->html($attributes['waifuOrHusbando']) ?></td> <td><?= $escape->html($attributes['waifuOrHusbando']) ?></td>
<td> <td>
<?php <?php
$character = $relationships['waifu']['attributes']; $character = $relationships['waifu']['attributes'];
echo $helper->a( echo $helper->a(
$url->generate('character', ['slug' => $character['slug']]), $url->generate('character', ['slug' => $character['slug']]),
@ -28,6 +31,21 @@
</td> </td>
</tr> </tr>
<?php endif ?> <?php endif ?>
<tr>
<th colspan="2">User Stats</th>
</tr>
<tr>
<td># of Posts</td>
<td><?= $attributes['postsCount'] ?></td>
</tr>
<tr>
<td># of Comments</td>
<td><?= $attributes['commentsCount'] ?></td>
</tr>
<tr>
<td># of Media Rated</td>
<td><?= $attributes['ratingsCount'] ?></td>
</tr>
</table> </table>
</div> </div>
<div> <div>
@ -35,9 +53,30 @@
<dt>About:</dt> <dt>About:</dt>
<dd><?= $escape->html($attributes['bio']) ?></dd> <dd><?= $escape->html($attributes['bio']) ?></dd>
</dl> </dl>
<?php /* <pre><?= json_encode($attributes, \JSON_PRETTY_PRINT) ?></pre> <?php if ( ! empty($favorites)): ?>
<pre><?= json_encode($relationships, \JSON_PRETTY_PRINT) ?></pre> <h3>Favorites:</h3>
<pre><?= json_encode($included, \JSON_PRETTY_PRINT) ?></pre> */ ?> <?php if ( ! empty($favorites['characters'])): ?>
<section>
<h4>Characters</h4>
<div class="flex flex-wrap">
<?php foreach($favorites['characters'] as $char): ?>
<?php if ( ! empty($char['image']['original'])): ?>
<div class="small_character">
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
<?= $helper->a($link, $char['name']); ?>
<br />
<a href="<?= $link ?>">
<?= $helper->img($char['image']['original'], [
'width' => '225'
]) ?>
</a>
</div>
<?php endif ?>
<?php endforeach ?>
</div>
</section>
<?php endif ?>
<?php endif ?>
</div> </div>
</section> </section>
</main> </main>

View File

@ -80,31 +80,12 @@ class ControllerTest extends AnimeClientTestCase {
$this->assertTrue(is_object($this->BaseController)); $this->assertTrue(is_object($this->BaseController));
} }
public function dataGet() public function testFormatTitle()
{ {
return [ $this->assertEquals(
'response' => [ $this->BaseController->formatTitle('foo', 'bar', 'baz'),
'key' => 'response', 'foo &middot; bar &middot; baz'
], );
'config' => [
'key' => 'config',
]
];
}
/**
* @dataProvider dataGet
*/
public function testGet($key)
{
$result = $this->BaseController->__get($key);
$this->assertEquals($this->container->get($key), $result);
}
public function testGetNull()
{
$result = $this->BaseController->__get('foo');
$this->assertNull($result);
} }
} }

View File

@ -1,39 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2017 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests;
use Aviat\AnimeClient\ControllerTrait;
class ControllerTraitTest extends AnimeClientTestCase {
public function setUp()
{
parent::setUp();
$this->controller = new class {
use ControllerTrait;
};
}
public function testFormatTitle()
{
$this->assertEquals(
$this->controller->formatTitle('foo', 'bar', 'baz'),
'foo &middot; bar &middot; baz'
);
}
}

View File

@ -229,6 +229,7 @@ class DispatcherTest extends AnimeClientTestCase {
'manga' => 'Aviat\AnimeClient\Controller\Manga', 'manga' => 'Aviat\AnimeClient\Controller\Manga',
'collection' => 'Aviat\AnimeClient\Controller\Collection', 'collection' => 'Aviat\AnimeClient\Controller\Collection',
'character' => 'Aviat\AnimeClient\Controller\Character', 'character' => 'Aviat\AnimeClient\Controller\Character',
'index' => 'Aviat\AnimeClient\Controller\Index',
] ]
], ],
'empty_controller_list' => [ 'empty_controller_list' => [
@ -249,6 +250,7 @@ class DispatcherTest extends AnimeClientTestCase {
'manga' => 'Aviat\AnimeClient\Controller\Manga', 'manga' => 'Aviat\AnimeClient\Controller\Manga',
'collection' => 'Aviat\AnimeClient\Controller\Collection', 'collection' => 'Aviat\AnimeClient\Controller\Collection',
'character' => 'Aviat\AnimeClient\Controller\Character', 'character' => 'Aviat\AnimeClient\Controller\Character',
'index' => 'Aviat\AnimeClient\Controller\Index',
] ]
] ]
]; ];