Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace calderawp\CalderaFormsQuery\Tests\Integration\Features;
use calderawp\CalderaFormsQuery\QueriesEntries;
use calderawp\CalderaFormsQuery\Tests\Integration\IntegrationTestCase;
use calderawp\CalderaFormsQuery\Tests\Traits\CanCreateEntryWithEmailField;
class QueryByUserIdTest extends IntegrationTestCase
{
use CanCreateEntryWithEmailField;
/**
* Test selecting by entry ID
*
* @covers QueriesEntries::selectByUserId()
*/
public function testByUserId()
{
$email = 'nom@noms.noms';
//Create an entry for a known user.
$userId = $this->factory()->user->create(
[ 'user_email' => $email ]
);
wp_set_current_user( $userId );
$entryId = $this->createEntryWithEmail( $email );
$queries = $this->entryQueriesFactory();
$results = $queries->selectByUserId( $userId );
$this->assertEquals( $entryId, $results[0]['entry']->id);
$this->assertEquals( $entryId, $results[0]['entry']->id);
$found = false;
foreach ( $results[0]['values'] as $entryValue )
{
if( $entryValue->slug === $this->getEmailFieldSlug() ){
$this->assertSame( $email, $entryValue->value );
$found = true;
}
}
$this->assertTrue( $found );
}
}