Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NewContentContainerTest.php « unit « tests - github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 69df627759537c4531c6e987b711f361992b8d4e (plain)
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
47
48
49
50
51
52
53
54
55
<?php

namespace OCA\OJSXC;

use OCA\OJSXC\Db\Message;
use OCA\OJSXC\Db\Stanza;
//use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

class NewContentContainerTest extends TestCase
{

	/**
	 * @var NewContentContainer $newContentContainer
	 */
	private $newContentContainer;

	public function setUp()
	{
		$this->newContentContainer = new NewContentContainer();
	}

	public function datatestProvider()
	{
		$stanza1 = new Stanza();
		$stanza1->setFrom('test@own.dev');
		$stanza1->setTo('adsffdsst@own.dev');

		$stanza2 = new Message();
		$stanza2->setFrom('test@own.dev');
		$stanza2->setTo('addsf@own.dev');
		$stanza2->setType('chat');
		$stanza2->setValue('abc');
		return [
			[
				[$stanza1, $stanza2],
				2
			]
		];
	}

	/**
	 * @dataProvider datatestProvider
	 */
	public function test($stanzas, $count)
	{
		foreach ($stanzas as $stanza) {
			$this->newContentContainer->addStanza($stanza);
		}
		$this->assertEquals($count, $this->newContentContainer->getCount());

		$result = $this->newContentContainer->getStanzas();
		$this->assertEquals(sort($stanzas), sort($result));
	}
}