<commit_before><?php
/**
 * ownCloud - ownbackup
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2015
 */

namespace OCA\OwnBackup\Controller;

use OCP\Security\ISecureRandom;
use PHPUnit_Framework_TestCase;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\TemplateResponse;


class AdminControllerTest extends PHPUnit_Framework_TestCase {

	private $controller;

	public function setUp() {
		$request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock();
		$backupService = $this->getMockBuilder('OCA\OwnBackup\Service\BackupService')->disableOriginalConstructor()->getMock();

		// generate a random user name
		$userId = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(20,
			ISecureRandom::CHAR_LOWER. ISecureRandom::CHAR_UPPER.
			ISecureRandom::CHAR_DIGITS);

		$this->controller = new AdminController( 'ownbackup', $request, $backupService, $userId );
	}

	public function testIndex() {
		$result = $this->controller->index();

		$this->assertEquals(['backupDateHash' => NULL], $result->getParams());
		$this->assertEquals('main', $result->getTemplateName());
		$this->assertTrue($result instanceof TemplateResponse);
	}

	public function testDoRestoreTables() {
		$timestamp = time();
		$tables = ["some_table"];

		$result = $this->controller->doRestoreTables( $timestamp, $tables );

		$this->assertEquals(['message' => '1 table(s) have been restored.'], $result->getData());
		$this->assertTrue($result instanceof DataResponse);

		$result = $this->controller->doRestoreTables( $timestamp, array() );
		$this->assertEquals(['message' => 'No table have been restored.'], $result->getData());
	}

	public function testDoFetchTables() {<commit_msg>fixed an other test error<commit_after><?php
/**
 * ownCloud - ownbackup
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2015
 */

namespace OCA\OwnBackup\Controller;

use OCP\Security\ISecureRandom;
use PHPUnit_Framework_TestCase;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\TemplateResponse;


class AdminControllerTest extends PHPUnit_Framework_TestCase {

	private $controller;

	public function setUp() {
		$request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock();
		$backupService = $this->getMockBuilder('OCA\OwnBackup\Service\BackupService')->disableOriginalConstructor()->getMock();

		// generate a random user name
		$userId = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(20,
			ISecureRandom::CHAR_LOWER. ISecureRandom::CHAR_UPPER.
			ISecureRandom::CHAR_DIGITS);

		$this->controller = new AdminController( 'ownbackup', $request, $backupService, $userId );
	}

	public function testIndex() {
		$result = $this->controller->index();

		$this->assertEquals(['backupDateHash' => NULL], $result->getParams());
		$this->assertEquals('admin', $result->getTemplateName());
		$this->assertTrue($result instanceof TemplateResponse);
	}

	public function testDoRestoreTables() {
		$timestamp = time();
		$tables = ["some_table"];

		$result = $this->controller->doRestoreTables( $timestamp, $tables );

		$this->assertEquals(['message' => '1 table(s) have been restored.'], $result->getData());
		$this->assertTrue($result instanceof DataResponse);

		$result = $this->controller->doRestoreTables( $timestamp, array() );
		$this->assertEquals(['message' => 'No table have been restored.'], $result->getData());
	}

	public function testDoFetchTables() {
{'fraction_non_alphanumeric': 0.15526102245063564, 'fraction_numerical': 0.004327833378414931, 'mean_word_length': 5.810313075506445, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3945684', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1072, 'n_words': 234}