be($this->user());
$this->call('GET', route('categories.create'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('
');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', route('categories.delete', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::destroy
*/
public function testDestroy()
{
$this->session(['categories.delete.url' => 'http://localhost']);
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$this->be($this->user());
$this->call('post', route('categories.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', route('categories.edit', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::index
*/
public function testIndex()
{
$this->be($this->user());
$this->call('GET', route('categories.index'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategory
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testNoCategory(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('categories.no-category'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::show
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShow(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('categories.show', [1]));
$this->assertResponseStatus(200);
$this->see('');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::showByDate
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShowByDate(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('categories.show', [1, '2015-01-01']));
$this->assertResponseStatus(200);
$this->see('');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::store
*/
public function testStore()
{
$this->session(['categories.create.url' => 'http://localhost']);
$data = [
'name' => 'New Category ' . rand(1000, 9999),
];
$this->be($this->user());
$this->call('post', route('categories.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// must be in list
$this->be($this->user());
$this->call('GET', route('categories.index'));
$this->assertResponseStatus(200);
$this->see('');
$this->see($data['name']);
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::update
*/
public function testUpdate()
{
$this->session(['categories.edit.url' => 'http://localhost']);
$data = [
'name' => 'Updated Category ' . rand(1000, 9999),
'active' => 1,
];
$this->be($this->user());
$this->call('post', route('categories.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// must be in list
$this->be($this->user());
$this->call('GET', route('categories.index'));
$this->assertResponseStatus(200);
$this->see('');
$this->see($data['name']);
}
}