mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-21 09:00:07 +00:00
make sure randomly selected journals match prerequisites.
This commit is contained in:
@@ -1321,10 +1321,15 @@ class TransactionControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testShowDeposit()
|
public function testShowDeposit()
|
||||||
{
|
{
|
||||||
|
do {
|
||||||
|
// this is kind of cheating but OK.
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
|
$journal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 2)->whereNull('deleted_at')->first();
|
||||||
|
$count = $journal->transactions()->count();
|
||||||
|
} while ($count !== 2);
|
||||||
$transaction = $journal->transactions()->first();
|
$transaction = $journal->transactions()->first();
|
||||||
|
|
||||||
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$accountRepos->shouldReceive('setUser');
|
$accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('getAccountsByType')
|
$accountRepos->shouldReceive('getAccountsByType')
|
||||||
@@ -1381,8 +1386,12 @@ class TransactionControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testShowWithdrawal()
|
public function testShowWithdrawal()
|
||||||
{
|
{
|
||||||
|
do {
|
||||||
|
// this is kind of cheating but OK.
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 1)->first();
|
$journal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->whereNull('deleted_at')->first();
|
||||||
|
$count = $journal->transactions()->count();
|
||||||
|
} while ($count !== 2);
|
||||||
$transaction = $journal->transactions()->first();
|
$transaction = $journal->transactions()->first();
|
||||||
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|||||||
@@ -36,12 +36,11 @@ class HasAttachmentTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered()
|
public function testTriggered()
|
||||||
{
|
{
|
||||||
$count = 0;
|
do {
|
||||||
while($count === 0) {
|
|
||||||
// this is kind of cheating but OK.
|
// this is kind of cheating but OK.
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
$count = $journal->attachments()->count();
|
$count = $journal->attachments()->count();
|
||||||
}
|
} while($count !== 0);
|
||||||
|
|
||||||
$attachment = $journal->user->attachments()->first();
|
$attachment = $journal->user->attachments()->first();
|
||||||
$journal->attachments()->save($attachment);
|
$journal->attachments()->save($attachment);
|
||||||
@@ -57,12 +56,11 @@ class HasAttachmentTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredFalse()
|
public function testTriggeredFalse()
|
||||||
{
|
{
|
||||||
$count = 0;
|
do {
|
||||||
while ($count === 0) {
|
|
||||||
// this is kind of cheating but OK.
|
// this is kind of cheating but OK.
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
$count = $journal->attachments()->count();
|
$count = $journal->attachments()->count();
|
||||||
}
|
} while($count !== 0);
|
||||||
|
|
||||||
$this->assertEquals(0, $journal->attachments()->count());
|
$this->assertEquals(0, $journal->attachments()->count());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user