<commit_before><?php
/**
 * ownCloud - Notes
 *
 * 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\Notes\Controller;

use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\App;
use Test\TestCase;


class NotesApiControllerTest extends TestCase {

    private $controller;
    private $mapper;
    private $userId = 'test';
    private $fs;

    public function setUp() {
        parent::setUp();

        $app = new App('notes');
        $container = $app->getContainer();
        $container->registerService('UserId', function($c) {
            return $this->userId;
        });
        $this->controller = $container->query(
            'OCA\Notes\Controller\NotesApiController'
        );

        $this->fs = $this->controller = $container->query(
            'OCP\Files\IRootFolder'
        );
    }


    public function testUpdate() {
        $note = $this->controller->create('test')->getData();
        $this->assertEquals('test', $note->getContent());

        $note2 = $this->controller->update($note->getId(), 'test2')->getData();
        $this->assertEquals('test2', $note2->getContent());
        $this->assertEquals($note->getId(), $note2->getId());

        $notes = $this->controller->index()->getData();

        $this->assertCount(1, $notes);
        $this->assertEquals('test2', $notes[0]->getContent());

        $file = $this->fs->get('/' . $userId . '/notes/test2.txt');

        $this->assertTrue($file instanceof OCP\Files\File);
    }


}<commit_msg>use import<commit_after><?php
/**
 * ownCloud - Notes
 *
 * 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\Notes\Controller;

use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\App;
use OCP\Files\File;
use Test\TestCase;

class NotesApiControllerTest extends TestCase {

    private $controller;
    private $mapper;
    private $userId = 'test';
    private $fs;

    public function setUp() {
        parent::setUp();

        $app = new App('notes');
        $container = $app->getContainer();
        $container->registerService('UserId', function($c) {
            return $this->userId;
        });
        $this->controller = $container->query(
            'OCA\Notes\Controller\NotesApiController'
        );

        $this->fs = $this->controller = $container->query(
            'OCP\Files\IRootFolder'
        );
    }


    public function testUpdate() {
        $note = $this->controller->create('test')->getData();
        $this->assertEquals('test', $note->getContent());

        $note2 = $this->controller->update($note->getId(), 'test2')->getData();
        $this->assertEquals('test2', $note2->getContent());
        $this->assertEquals($note->getId(), $note2->getId());

        $notes = $this->controller->index()->getData();

        $this->assertCount(1, $notes);
        $this->assertEquals('test2', $notes[0]->getContent());

        $file = $this->fs->get('/' . $userId . '/notes/test2.txt');

        $this->assertTrue($file instanceof File);
    }


}
{'fraction_non_alphanumeric': 0.17612584824182603, 'fraction_numerical': 0.00863664404688464, 'mean_word_length': 2.7753201396973224, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 73, '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': '1689269', 'n_tokens_mistral': 969, 'n_tokens_neox': 950, 'n_words': 193}