Completed
Pull Request — master (#143)
by wiese
04:00
created

testNewMembershipApplicationCanBeInserted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Store\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use WMDE\Fundraising\Entities\MembershipApplication;
9
10
/**
11
 * @covers \WMDE\Fundraising\Entities\MembershipApplication
12
 */
13
class MembershipApplicationInsertionTest extends TestCase {
14
15
	public function testNewMembershipApplicationCanBeInserted(): void {
16
		$entityManager = TestEnvironment::newDefault()->getFactory()->getEntityManager();
17
		$entityManager->persist( new MembershipApplication() );
18
		$entityManager->flush();
19
20
		$count = $entityManager->createQueryBuilder()
21
			->select( 'COUNT(r.id)' )
22
			->from( MembershipApplication::class, 'r' )
23
			->getQuery()
24
			->getSingleScalarResult();
25
26
		$this->assertSame( '1', $count );
27
	}
28
29
	public function testMembershipApplicationCanBeLoaded(): void {
30
		$entityManager = TestEnvironment::newDefault()->getFactory()->getEntityManager();
31
32
		$application = new MembershipApplication();
33
		$application->setDonationReceipt( true );
34
35
		$entityManager->persist( $application );
36
		$entityManager->flush();
37
38
		/**
39
		 * @var MembershipApplication $application
40
		 */
41
		$application = $entityManager->getRepository( MembershipApplication::class )->find( $application->getId() );
42
43
		$this->assertTrue( $application->getDonationReceipt() );
0 ignored issues
show
Bug introduced by
It seems like $application->getDonationReceipt() targeting WMDE\Fundraising\Entitie...n::getDonationReceipt() can also be of type null; however, PHPUnit\Framework\Assert::assertTrue() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
44
	}
45
}
46