本文整理汇总了PHP中Preferences::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Preferences::shouldReceive方法的具体用法?PHP Preferences::shouldReceive怎么用?PHP Preferences::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::shouldReceive方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testYearInOut
/**
* FireflyIII\Generator\Chart\Report\ChartJsReportChartGenerator::yearInOut
*/
public function testYearInOut()
{
$preference = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$preference->data = 'en';
$preference->save();
// mock language preference:
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
// make set:
$collection = new Collection();
for ($i = 0; $i < 5; $i++) {
$collection->push([new Carbon(), 200, 100]);
}
$data = $this->object->yearInOut($collection);
$this->assertEquals(200, $data['datasets'][0]['data'][0]);
$this->assertEquals(100, $data['datasets'][1]['data'][0]);
$this->assertCount(5, $data['labels']);
}
示例2: testIndexNoAccounts
public function testIndexNoAccounts()
{
$user = FactoryMuffin::create('FireflyIII\\User');
$repository = $this->mock('FireflyIII\\Repositories\\Account\\AccountRepositoryInterface');
$this->be($user);
// mock ALL THE THINGS!
$repository->shouldReceive('countAccounts')->once()->andReturn(3);
// language preference:
$language = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$language->data = 'en';
$language->save();
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
$lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
$this->call('GET', '/new-user');
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('index');
}
示例3: testYear
/**
* @covers FireflyIII\Generator\Chart\Budget\ChartJsBudgetChartGenerator::year
*/
public function testYear()
{
$preference = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$preference->data = 'en';
$preference->save();
$budgets = new Collection();
$entries = new Collection();
// make some budgets:
for ($i = 0; $i < 5; $i++) {
$budgets->push(FactoryMuffin::create('FireflyIII\\Models\\Budget'));
$entries->push([new Carbon(), 100, 100, 100]);
}
// mock language preference:
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
$data = $this->object->year($budgets, $entries);
$this->assertCount(5, $data['labels']);
$this->assertCount(5, $data['datasets']);
$this->assertCount(3, $data['datasets'][0]['data']);
}
示例4: testSingle
/**
* @covers FireflyIII\Generator\Chart\Bill\ChartJsBillChartGenerator::single
*/
public function testSingle()
{
$preference = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$preference->data = 'en';
$preference->save();
// mock language preference:
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
$bill = FactoryMuffin::create('FireflyIII\\Models\\Bill');
$entries = new Collection();
for ($i = 0; $i < 5; $i++) {
$obj = new stdClass();
$obj->amount = 100;
$obj->date = new Carbon();
$entries->push($obj);
}
$data = $this->object->single($bill, $entries);
$this->assertCount(5, $data['labels']);
$this->assertCount(5, $data['datasets'][1]['data']);
$this->assertEquals(100, $data['datasets'][1]['data'][0]);
// see if first is equal.
}
示例5: testHistory
/**
* @covers FireflyIII\Generator\Chart\PiggyBank\ChartJsPiggyBankChartGenerator::history
*/
public function testHistory()
{
$preference = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$preference->data = 'en';
$preference->save();
// mock language preference:
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
// create a set
$set = new Collection();
for ($i = 0; $i < 5; $i++) {
$obj = new stdClass();
$obj->date = new Carbon();
$obj->sum = 100;
$set->push($obj);
}
$data = $this->object->history($set);
$this->assertCount(5, $data['labels']);
$this->assertCount(5, $data['datasets'][0]['data']);
$this->assertEquals(100, $data['datasets'][0]['data'][0]);
$this->assertEquals(500, $data['datasets'][0]['data'][4]);
}
示例6: testSingle
/**
* @covers FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator::single
*/
public function testSingle()
{
// be somebody
$user = FactoryMuffin::create('FireflyIII\\User');
$this->be($user);
$preference = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$preference->data = 'en';
$preference->save();
// mock language preference:
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
// mock Steam::balance
Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
// data for call:
$start = Carbon::createFromDate(2015, 1, 1);
$end = Carbon::createFromDate(2015, 1, 15);
$account = FactoryMuffin::create('FireflyIII\\Models\\Account');
// call
$result = $this->object->single($account, $start, $end);
// test
$this->assertCount(15, $result['labels']);
$this->assertEquals($account->name, $result['datasets'][0]['label']);
$this->assertCount(15, $result['datasets'][0]['data']);
}
示例7: testCreate
/**
* @covers FireflyIII\Http\Controllers\AccountController::create
*/
public function testCreate()
{
$pref = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$pref->data = '1M';
$this->be($pref->user);
Preferences::shouldReceive('get')->withArgs(['viewRange', '1M'])->andReturn($pref);
$language = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$language->data = 'en';
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language);
// CURRENCY:
$currency = FactoryMuffin::create('FireflyIII\\Models\\TransactionCurrency');
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
$this->call('GET', '/accounts/create/asset');
$this->assertResponseOk();
$this->assertViewHas('subTitle', 'Create a new asset account');
$this->assertViewHas('subTitleIcon', 'fa-money');
$this->assertViewHas('what', 'asset');
}
示例8: testGetCurrencyCodeNoSuchCurrency
/**
* @covers FireflyIII\Support\Amount::getCurrencyCode
*/
public function testGetCurrencyCodeNoSuchCurrency()
{
$user = FactoryMuffin::create('FireflyIII\\User');
$this->be($user);
// delete any currency preferences:
Preference::where('user_id', $user->id)->delete();
// delete transaction currencies:
foreach (TransactionCurrency::get() as $c) {
$c->delete();
}
$preference = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$preference->user_id = $user->id;
$preference->name = 'currencyPreference';
$preference->data = 'SOM';
$preference->save();
Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->andReturn($preference);
$code = $this->object->getCurrencyCode();
$this->assertEquals('EUR', $code);
}
示例9: testPostIndex
/**
* @covers FireflyIII\Http\Controllers\PreferencesController::postIndex
*/
public function testPostIndex()
{
$user = FactoryMuffin::create('FireflyIII\\User');
$this->be($user);
$data = ['frontPageAccounts' => [1, 2, 3], '_token' => 'replaceMe', 'viewRange' => '1M', 'language' => 'en'];
// language preference:
$language = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$language->data = 'en';
$language->save();
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
Preferences::shouldReceive('set')->once()->withArgs(['frontPageAccounts', [1, 2, 3]]);
Preferences::shouldReceive('set')->once()->withArgs(['viewRange', '1M']);
Preferences::shouldReceive('set')->once()->withArgs(['budgetMaximum', 0]);
Preferences::shouldReceive('set')->once()->withArgs(['language', 'en']);
Preferences::shouldReceive('mark')->once()->andReturn(true);
// language preference:
$language = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$language->data = 'en';
$language->save();
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
$lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
$this->call('POST', '/preferences', $data);
$this->assertResponseStatus(302);
}
示例10: testUpdateIncome
/**
* @covers FireflyIII\Http\Controllers\BudgetController::updateIncome
*/
public function testUpdateIncome()
{
// a budget:
$budget = FactoryMuffin::create('FireflyIII\\Models\\Budget');
$this->be($budget->user);
$date = Carbon::now()->format('FY');
$pref = FactoryMuffin::create('FireflyIII\\Models\\Preference');
Preferences::shouldReceive('get')->withArgs(['budgetIncomeTotal' . $date, 1000])->andReturn($pref);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
// language preference:
$language = FactoryMuffin::create('FireflyIII\\Models\\Preference');
$language->data = 'en';
$language->save();
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
$this->call('GET', '/budgets/income');
$this->assertResponseOk();
$this->assertViewHas('amount');
}