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

MembershipApplicationInsertionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 0
loc 33
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNewMembershipApplicationCanBeInserted() 0 13 1
A testMembershipApplicationCanBeLoaded() 0 16 1
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