Beispiel #1
0
 public function testCreationWithDefaultCategories()
 {
     $p = new Project($this->container);
     $c = new Config($this->container);
     $cat = new Category($this->container);
     // Multiple categories correctly formatted
     $this->assertTrue($c->save(array('project_categories' => 'Test1, Test2')));
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(1);
     $this->assertNotEmpty($categories);
     $this->assertEquals(2, count($categories));
     $this->assertEquals('Test1', $categories[0]['name']);
     $this->assertEquals('Test2', $categories[1]['name']);
     // Single category
     $this->assertTrue($c->save(array('project_categories' => 'Test1')));
     $this->container['memoryCache']->flush();
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(2);
     $this->assertNotEmpty($categories);
     $this->assertEquals(1, count($categories));
     $this->assertEquals('Test1', $categories[0]['name']);
     // Multiple categories badly formatted
     $this->assertTrue($c->save(array('project_categories' => 'ABC, , DEF 3,  ')));
     $this->container['memoryCache']->flush();
     $this->assertEquals(3, $p->create(array('name' => 'UnitTest3')));
     $project = $p->getById(3);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(3);
     $this->assertNotEmpty($categories);
     $this->assertEquals(2, count($categories));
     $this->assertEquals('ABC', $categories[0]['name']);
     $this->assertEquals('DEF 3', $categories[1]['name']);
     // No default categories
     $this->assertTrue($c->save(array('project_categories' => '  ')));
     $this->container['memoryCache']->flush();
     $this->assertEquals(4, $p->create(array('name' => 'UnitTest4')));
     $project = $p->getById(4);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(4);
     $this->assertEmpty($categories);
 }
 public function testCloneProjectWithCategories()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pd = new ProjectDuplication($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 1)));
     $this->assertEquals(3, $c->create(array('name' => 'C3', 'project_id' => 1)));
     $this->assertEquals(2, $pd->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $categories = $c->getAll(2);
     $this->assertNotempty($categories);
     $this->assertEquals(3, count($categories));
     $this->assertEquals(4, $categories[0]['id']);
     $this->assertEquals('C1', $categories[0]['name']);
     $this->assertEquals(5, $categories[1]['id']);
     $this->assertEquals('C2', $categories[1]['name']);
     $this->assertEquals(6, $categories[2]['id']);
     $this->assertEquals('C3', $categories[2]['name']);
 }
Beispiel #3
0
 public function testCreateDefaultCategories()
 {
     $projectModel = new Project($this->container);
     $categoryModel = new Category($this->container);
     $configModel = new Config($this->container);
     $this->assertTrue($configModel->save(array('project_categories' => 'C1, C2, C3')));
     $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
     $this->assertTrue($categoryModel->createDefaultCategories(1));
     $categories = $categoryModel->getAll(1);
     $this->assertCount(3, $categories);
     $this->assertEquals('C1', $categories[0]['name']);
     $this->assertEquals('C2', $categories[1]['name']);
     $this->assertEquals('C3', $categories[2]['name']);
 }