public function testRequirementSuccess()
 {
     $requirement = FactoryMuffin::create('Requirement');
     $requirement->load('parameter');
     $this->assertInstanceOf('Parameter', $requirement->parameter);
     $this->assertInstanceOf('Protocol', $requirement->protocol);
 }
예제 #2
0
 public function testCanHaveCategories()
 {
     $badge = FactoryMuffin::create('DMA\\Friends\\Models\\Badge');
     $category = FactoryMuffin::create('DMA\\Friends\\Models\\Category');
     $this->assertInstanceOf('DMA\\Friends\\Models\\Category', $category);
     $badge->categories()->save($category);
 }
예제 #3
0
 /**
  * test status can't be set to something weird.
  */
 public function testInvalidStatus()
 {
     /** @var Endpoint $instance */
     $instance = FactoryMuffin::instance('WebservicesNl\\Common\\Endpoint\\Endpoint', ['status' => Endpoint::STATUS_DISABLED]);
     $instance->setStatus('fake');
     self::assertEquals(Endpoint::STATUS_DISABLED, $instance->getStatus());
 }
예제 #4
0
 /**
  * @covers FireflyIII\Models\Category::firstOrCreateEncrypted
  */
 public function testFirstOrCreateEncryptedNew()
 {
     $category = FactoryMuffin::create('FireflyIII\\Models\\Category');
     $search = ['name' => 'Some category name', 'user_id' => $category->user_id];
     $result = Category::firstOrCreateEncrypted($search);
     $this->assertNotEquals($result->id, $category->id);
 }
 /**
  * @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOutSummarized
  */
 public function testYearInOutSummarizedShared()
 {
     $user = FactoryMuffin::create('FireflyIII\\User');
     $this->be($user);
     $this->call('GET', '/chart/report/in-out-sum/2015/shared');
     $this->assertResponseOk();
 }
 /**
  * @throws \WebservicesNl\Common\Exception\Client\InputException
  * @throws \InvalidArgumentException
  * @throws \WebservicesNl\Common\Exception\Server\NoServerAvailableException
  */
 public function testInstance()
 {
     /** @var \WebservicesNl\Platform\Webservices\PlatformConfig $platFormConfig */
     $platFormConfig = FactoryMuffin::create('WebservicesNl\\Platform\\Webservices\\PlatformConfig');
     static::assertTrue(class_exists($platFormConfig->getClassName(true)));
     static::assertEquals($platFormConfig->getPlatformName(), $platFormConfig::PLATFORM_NAME);
     static::assertTrue(is_array($platFormConfig->toArray()));
 }
 public function testCombinationSuccess()
 {
     $combination = FactoryMuffin::create('Combination');
     $combination->load('power_generator');
     $this->assertInstanceOf('Needle', $combination->needle);
     $this->assertInstanceOf('PowerGenerator', $combination->power_generator);
     $this->assertInstanceOf('Protocol', $combination->protocol);
 }
 public function testRelationships()
 {
     $object_types = [FactoryMuffin::create('DMA\\Friends\\Models\\Activity'), FactoryMuffin::create('DMA\\Friends\\Models\\Badge'), FactoryMuffin::create('DMA\\Friends\\Models\\Reward'), FactoryMuffin::create('DMA\\Friends\\Models\\Step')];
     foreach ($object_types as $object) {
         $activityLog = FactoryMuffin::create('DMA\\Friends\\Models\\ActivityLog');
         $object->activityLogs()->save($activityLog);
     }
 }
예제 #9
0
 /**
  * @covers FireflyIII\Models\Tag::save
  */
 public function testSave()
 {
     $tag = FactoryMuffin::create('FireflyIII\\Models\\Tag');
     // connect some transaction journals to the tag:
     $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal');
     $journal->tags()->save($tag);
     $tag->save();
     $journal = TransactionJournal::find($journal->id);
     $this->assertEquals(1, $journal->tag_count);
 }
예제 #10
0
 /**
  * No such route.
  *
  * @covers FireflyIII\Http\Controllers\HelpController::show
  */
 public function testGetHelpTextNoRoute()
 {
     // login
     $user = FactoryMuffin::create('FireflyIII\\User');
     $this->be($user);
     // mock some stuff.
     $interface = $this->mock('FireflyIII\\Helpers\\Help\\HelpInterface');
     $interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(false);
     $this->call('GET', '/help/accounts.index');
     $this->assertResponseOk();
 }
예제 #11
0
 public function testTimeRestrictionsAreSerialized()
 {
     $activity = FactoryMuffin::create('DMA\\Friends\\Models\\Activity');
     $timeRestrictionData = ['start_time' => '11:00AM', 'end_time' => '12:00PM', 'days' => [1 => true, 2 => false, 3 => true, 4 => false, 5 => true, 6 => false]];
     $activity->time_restriction_data = $timeRestrictionData;
     $activity->save();
     // Load a new reference to the model
     $newActivity = Activity::find($activity->id);
     // Compare time_restriction_data to ensure that attributes are serialized/unserialized properly
     $this->assertEquals($newActivity->time_restriction_data, $timeRestrictionData);
 }
 public function setUp()
 {
     $this->logger = new Logger(__CLASS__);
     $this->testHandler = new TestHandler();
     $streamHandler = new StreamHandler('/tmp/test.log', LogLevel::INFO);
     $this->logger->setHandlers([$streamHandler, $this->testHandler]);
     /** @var SoapSettings $settings */
     $this->settings = FactoryMuffin::instance('WebservicesNl\\Protocol\\Soap\\Client\\SoapSettings');
     $this->manager = new Manager();
     $this->manager->createEndpoint('https://ws1.webservices.nl/soap_doclit');
 }
 /**
  * @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::year
  */
 public function testYear()
 {
     $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]);
     }
     $data = $this->object->year($budgets, $entries);
     $this->assertCount(5, $data['rows']);
     $this->assertCount(6, $data['cols']);
 }
 /**
  *
  */
 public function testConfigArrayIsBorked()
 {
     /** @var \WebservicesNl\Platform\Webservices\PlatformConfig $platformConfig */
     $platformConfig = FactoryMuffin::instance('\\WebservicesNl\\Platform\\Webservices\\PlatformConfig', ['userName' => function () {
         return null;
     }]);
     /** @var \WebservicesNl\Protocol\Soap\Config\Platform\Webservices\Config $soapConfig */
     $soapConfig = WebservicesConfig::configure($platformConfig);
     $resultArray = $soapConfig->toArray();
     static::assertArrayNotHasKey('username', $resultArray);
     static::assertNull($soapConfig->getUserName());
     static::assertCount(7, $resultArray);
 }
 /**
  * @covers FireflyIII\Http\Controllers\Chart\CategoryController::year
  */
 public function testYearShared()
 {
     $user = FactoryMuffin::create('FireflyIII\\User');
     $this->be($user);
     $categories = new Collection([FactoryMuffin::create('FireflyIII\\Models\\Category')]);
     // mock!
     $repository = $this->mock('FireflyIII\\Repositories\\Category\\CategoryRepositoryInterface');
     // fake!
     $repository->shouldReceive('getCategories')->andReturn($categories);
     $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0);
     $this->call('GET', '/chart/category/year/2015/shared');
     $this->assertResponseOk();
 }
예제 #16
0
 public function testPostIndex()
 {
     $user = FactoryMuffin::create('FireflyIII\\User');
     $currency = FactoryMuffin::create('FireflyIII\\Models\\TransactionCurrency');
     $account = FactoryMuffin::create('FireflyIII\\Models\\Account');
     $repository = $this->mock('FireflyIII\\Repositories\\Account\\AccountRepositoryInterface');
     $this->be($user);
     $data = ['_token' => 'replaceMe', 'bank_name' => 'Some Bank', 'bank_balance' => '100', 'balance_currency_id' => $currency->id, 'savings_balance' => '100', 'credit_card_limit' => '100'];
     $repository->shouldReceive('store')->andReturn($account);
     $this->call('POST', '/new-user/submit', $data);
     $this->assertResponseStatus(302);
     $this->assertRedirectedToRoute('index');
 }
 public function testEmptyInstance()
 {
     /** @var PlatformConfig $platFormConfig */
     $platFormConfig = FactoryMuffin::create('WebservicesNl\\Platform\\Webservices\\PlatformConfig');
     $soapConfig = new SoapConfig($platFormConfig);
     static::assertFalse($soapConfig->hasConverter());
     static::assertEmpty($soapConfig->getSoapHeaders());
     static::assertEquals($platFormConfig, $soapConfig->getPlatformConfig());
     static::assertAttributeInstanceOf('WebservicesNl\\Platform\\Webservices\\PlatformConfig', 'platformConfig', $soapConfig);
     static::assertEquals($soapConfig::getEndPoints(), SoapConfig::getEndPoints());
     static::assertCount(5, $soapConfig->toArray());
     $static = SoapConfig::configure($platFormConfig);
     static::assertEquals($static, $soapConfig);
 }
 /**
  * @covers FireflyIII\Generator\Chart\Bill\GoogleBillChartGenerator::single
  */
 public function testSingle()
 {
     $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['rows']);
     $this->assertCount(4, $data['cols']);
     $this->assertEquals(100, $data['rows'][0]['c'][3]['v']);
 }
예제 #19
0
 /**
  * @covers FireflyIII\Http\Controllers\SearchController::index
  */
 public function testSearch()
 {
     $user = FactoryMuffin::create('FireflyIII\\User');
     $this->be($user);
     $words = ['Something'];
     // mock!
     $repository = $this->mock('FireflyIII\\Support\\Search\\SearchInterface');
     $repository->shouldReceive('searchTransactions')->with($words)->once()->andReturn([]);
     $repository->shouldReceive('searchAccounts')->with($words)->once()->andReturn([]);
     $repository->shouldReceive('searchCategories')->with($words)->once()->andReturn([]);
     $repository->shouldReceive('searchBudgets')->with($words)->once()->andReturn([]);
     $repository->shouldReceive('searchTags')->with($words)->once()->andReturn([]);
     $this->call('GET', '/search?q=Something');
     $this->assertResponseOk();
 }
예제 #20
0
파일: Call.php 프로젝트: kr85/SpartaPark
 /**
  * Generate, and return the attribute.
  *
  * @throws \League\FactoryMuffin\Exceptions\MethodNotFoundException
  *
  * @return mixed
  */
 public function generate()
 {
     $method = substr($this->kind, 5);
     $args = array();
     if (strstr($method, '|')) {
         $parts = explode('|', $method);
         $method = array_shift($parts);
         if ($parts[0] === 'factory' && count($parts) > 1) {
             $args[] = $this->factory($parts[1]);
         } else {
             $args[] = FactoryMuffin::generateAttr(implode('|', $parts), $this->object);
         }
     }
     return $this->execute($method, $args);
 }
 /**
  * @covers FireflyIII\Http\Controllers\Chart\PiggyBankController::history
  */
 public function testHistory()
 {
     $piggy = FactoryMuffin::create('FireflyIII\\Models\\PiggyBank');
     $this->be($piggy->account->user);
     // data:
     $obj = new stdClass();
     $obj->sum = 100;
     $obj->date = '2015-01-01';
     $set = [$obj];
     // mock!
     $repository = $this->mock('FireflyIII\\Repositories\\PiggyBank\\PiggyBankRepositoryInterface');
     // fake!
     $repository->shouldReceive('getEventSummarySet')->andReturn($set);
     $this->call('GET', '/chart/piggyBank/' . $piggy->id);
     $this->assertResponseOk();
 }
 /**
  * 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']);
 }
 /**
  * Checking getter and setter (might be a silly test).
  */
 public function testMappingToArray()
 {
     /** @var \WebservicesNl\Protocol\Soap\Client\SoapSettings $settings */
     $settings = FactoryMuffin::create('WebservicesNl\\Protocol\\Soap\\Client\\SoapSettings');
     $array = $settings->toArray();
     // accessing private properties ...
     array_walk($array, function ($value, $key) use($settings, $array) {
         $name = 'get' . ucfirst($key);
         if (!method_exists($settings, $name)) {
             $name = 'has' . ucfirst($key);
         }
         if (!method_exists($settings, $name)) {
             $name = 'is' . ucfirst($key);
         }
         static::assertEquals($settings->{$name}(), $value, "SoapSetting should have {$key} value");
     });
 }
 /**
  * @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']);
 }
예제 #25
0
 public function testCanHaveAndRemovePoints()
 {
     $incrementVal = 10;
     $user = FactoryMuffin::create('RainLab\\User\\Models\\User');
     $points = $user->points;
     $points_this_week = $user->points_this_week;
     $userExtend = new UserExtend($user);
     // Add points
     $userExtend->addPoints($incrementVal);
     $points += $incrementVal;
     $points_this_week += $incrementVal;
     $this->assertEquals($user->points, $points);
     $this->assertEquals($user->points_this_week, $points_this_week);
     // Remove Points
     $userExtend->removePoints($incrementVal);
     $points -= $incrementVal;
     $points_this_week -= $incrementVal;
     $this->assertEquals($user->points, $points);
     $this->assertEquals($user->points_this_week, $points_this_week);
 }
 /**
  * @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]);
 }
 /**
  * @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.
 }
 /**
  * @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']);
 }
예제 #29
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 public function setUp()
 {
     parent::setUp();
     // if the database copy does not exist, call migrate.
     $copy = __DIR__ . '/../storage/database/testing-copy.db';
     $original = __DIR__ . '/../storage/database/testing.db';
     FactoryMuffin::loadFactories(__DIR__ . '/factories');
     if (!file_exists($copy)) {
         touch($original);
         Artisan::call('migrate');
         // create EUR currency
         /** @var TransactionCurrency $currency */
         $currency = FactoryMuffin::create('FireflyIII\\Models\\TransactionCurrency');
         $currency->code = 'EUR';
         $currency->save();
         copy($original, $copy);
     } else {
         if (file_exists($copy)) {
             copy($copy, $original);
         }
     }
     // if the database copy does exists, copy back as original.
     $this->session(['start' => Carbon::now()->startOfMonth(), 'end' => Carbon::now()->endOfMonth(), 'first' => Carbon::now()->startOfYear()]);
 }
 /**
  * @covers FireflyIII\Generator\Chart\Account\GoogleAccountChartGenerator::single
  */
 public function testSingle()
 {
     // be somebody
     $user = FactoryMuffin::create('FireflyIII\\User');
     $this->be($user);
     /** @var Account $account */
     $account = FactoryMuffin::create('FireflyIII\\Models\\Account');
     // data for call:
     $start = Carbon::createFromDate(2015, 1, 1);
     $end = Carbon::createFromDate(2015, 1, 15);
     // mock Steam::balance
     Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
     $data = $this->object->single($account, $start, $end);
     $this->assertCount(3, $data['cols']);
     // account, date, certainty
     // fifteen days,
     $this->assertCount(15, $data['rows']);
     // 15 days
 }