summaryrefslogtreecommitdiff
path: root/tests/units/FileTest.php
blob: 5e882fdbced5d9d820ff1e4065d7f1504ef7d5f3 (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
<?php

require_once __DIR__.'/Base.php';

use Model\Task;
use Model\File;
use Model\TaskCreation;
use Model\Project;

class FileTest extends Base
{
    public function testCreationFileNameTooLong()
    {
        $p = new Project($this->container);
        $f = new File($this->container);
        $tc = new TaskCreation($this->container);

        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));

        $this->assertTrue($f->create(1, 'test', '/tmp/foo', false, 10));
        $this->assertTrue($f->create(1, str_repeat('a', 1000), '/tmp/foo', false, 10));

        $files = $f->getAll(1);
        $this->assertNotEmpty($files);
        $this->assertCount(2, $files);

        $this->assertEquals(str_repeat('a', 255), $files[0]['name']);
        $this->assertEquals('test', $files[1]['name']);
    }
}