firefly-iii/tests/models/TagModelTest.php

78 lines
1.7 KiB
PHP
Raw Normal View History

2015-05-24 03:01:00 -05:00
<?php
2015-05-24 04:13:46 -05:00
use FireflyIII\Models\Tag;
use League\FactoryMuffin\Facade as FactoryMuffin;
2015-05-24 03:01:00 -05:00
/**
* Class TagModelTest
*/
class TagModelTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
parent::tearDown();
}
2015-05-24 04:13:46 -05:00
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
2015-05-25 12:58:13 -05:00
public function testFirstOrCreateEncrypted()
2015-05-24 04:13:46 -05:00
{
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$search = [
'tagMode' => 'something',
2015-05-25 12:58:13 -05:00
'tag' => $tag->tag,
2015-05-24 04:13:46 -05:00
'user_id' => $tag->user_id,
];
$result = Tag::firstOrCreateEncrypted($search);
2015-05-25 12:58:13 -05:00
$this->assertEquals($tag->id, $result->id);
2015-05-24 04:13:46 -05:00
}
2015-05-24 03:01:00 -05:00
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
2015-05-25 12:58:13 -05:00
public function testFirstOrCreateEncryptedNew()
2015-05-24 03:01:00 -05:00
{
2015-05-24 04:13:46 -05:00
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$search = [
'tagMode' => 'something',
2015-05-25 12:58:13 -05:00
'tag' => 'Something else',
2015-05-24 04:13:46 -05:00
'user_id' => $tag->user_id,
];
$result = Tag::firstOrCreateEncrypted($search);
2015-05-25 12:58:13 -05:00
$this->assertNotEquals($tag->id, $result->id);
2015-05-24 03:01:00 -05:00
}
2015-05-24 08:18:19 -05:00
}