public function test_it_can_register_user() { $groupId = 2; $input = ['_token' => 'someFooToken', 'name' => 'Foo Name', 'email' => '*****@*****.**', 'username' => 'foo_user', 'password' => 'foo_pass', 'password_confirmation' => 'foo_pass']; $output = $this->UserManager->registerUser($input, $groupId); assertInstanceOf('DvsUser', $output); }
public function test_it_can_retrieve_current_user() { $this->Framework->Auth->shouldReceive('id')->andReturn(1); $output = $this->UsersRepository->retrieveCurrentUser(); assertInstanceOf('DvsUser', $output); assertEquals(1, count($output)); }
/** * @dataProvider providerCreatesAppropriateFileReader * * @param string $extension * @param string $fileReaderClass */ public function testCreatesAppropriateFileReader($extension, $fileReaderClass) { $filename = 'test' . $extension; $this->createTestFile($filename); $reader = $this->factory->create($this->getTestPath($filename)); assertInstanceOf($fileReaderClass, $reader); }
public function testExistingChildren() { // --- test load $this->createModels(CustomerDetail::class, []); $this->createModels(Customer::class, [['name' => 'Frank', 'surname' => 'Sinatra']]); $details = new CustomerDetail(); $source = Datasource::make(new CustomerDetail()); $source['id'] = 1; $source['biography'] = 'A nice life!'; $source['accepts_cookies'] = 0; $source['customer_id'] = 1; $details->id = 1; $details->biography = 'A nice life!'; $details->accepts_cookies = 0; $details->customer_id = 1; $source->save(); assertTrue(isset($source['customer'])); assertInstanceOf(Customer::class, $source['customer']); assertModelArrayEqual(Customer::all()->toArray(), [$source['customer']->toArray()]); // compare with how eloquent behaves: $this->createModels(CustomerDetail::class, []); $details->save(); assertFalse(isset($details->customer)); // always false! assertInstanceOf(Customer::class, $details->customer); }
public function testInitializingObject() { $configurations = ['default' => 'AwsS3', 'url' => 'https://s3.amazonaws.com', 'threshold' => 10, 'providers' => ['aws' => ['s3' => ['region' => 'us-standard', 'version' => 'latest', 'buckets' => ['my-bucket-name' => '*'], 'acl' => 'public-read', 'cloudfront' => ['use' => false, 'cdn_url' => null], 'metadata' => [], 'expires' => gmdate('D, d M Y H:i:s T', strtotime('+5 years')), 'cache-control' => 'max-age=2628000', 'version' => null]]]]; $this->setupNonCloudfrontTest(); $awsS3Provider_obj = $this->p_awsS3Provider->init($configurations); assertInstanceOf('Publiux\\laravelcdn\\Providers\\AwsS3Provider', $awsS3Provider_obj); }
public function test_it_can_login_using_username() { $this->Framework->Auth->shouldReceive('attempt')->once()->andReturn(true); $this->UsersRepository->shouldReceive('findByUsername')->once()->andReturn($this->DvsUser); $input = ['uname_or_email' => 'deviseadmin', 'password' => 'secret']; $output = $this->SessionsRepository->login($input); assertInstanceOf('DvsUser', $output); }
public function testAddExistingField() { $source = []; $e = new Endpoint($source); $field = $e->string('name'); assertInstanceOf(Field::class, $field); assertSame($field, $e['name']); }
public function testHydrateDateTime() { $dob = new \DateTime('1989-01-01'); $data = array('dob' => $dob->format('U')); $hydratedPerson = $this->hydrator->hydrate($this->person, $data, $this->metadata); assertInstanceOf('DateTime', $hydratedPerson->dob); assertEquals('1989-01-01', $hydratedPerson->dob->format('Y-m-d')); }
public function test_it_creates_new_page() { $this->RoutesGenerator->shouldReceive('cacheRoutes')->once(); $this->PageVersionManager->shouldReceive('createDefaultPageVersion')->times(1)->andReturn(new \DvsPageVersion()); $page = $this->ApiPagesManager->createNewPage(['title' => 'Some page title', 'slug' => '/some-page-title', 'http_verb' => 'get', 'response_path' => 'some.path', 'response_params' => 'param1,param2']); assertNotFalse($page); assertInstanceOf('DvsPageVersion', $page->version); assertEquals($page->title, 'Some page title'); }
/** * @Given /^a set of chart objects with options$/ */ public function aSetOfChartObjectsWithOptions() { $obj1 = new DummyChart(); assertInstanceOf('GoogleChartGenerator\\Mock\\DummyChart', $obj1->setTitle('Dummy Chart #1')); $this->mockObjects['obj1'] = $obj1; $this->expectedOptions['obj1'] = ["title" => "Dummy Chart #1"]; $this->mockObjects['obj2'] = new DummyChart(['title' => 'Dummy Chart #2']); $this->expectedOptions['obj2'] = ['title' => 'Dummy Chart #2']; }
public function test_it_creates_pristine_section() { $parser = new DeviseParser(); $traverser = new NodeTraverser(); $traverser->addVisitor(new CreatePristineSection($parser)); $nodes = $parser->parse($this->fixture('devise-views.interpret3')); $nodes = $traverser->traverse($nodes); assertCount(1, $nodes); assertInstanceOf('PhpParser\\Node\\Stmt\\If_', $nodes[0]); }
public function test_it_creates_new_page_for_spanish_language() { $this->PageVersionManager->shouldReceive('createDefaultPageVersion')->times(1)->andReturn(new \DvsPageVersion()); $this->RoutesGenerator->shouldReceive('cacheRoutes')->once(); $page = $this->PageManager->createNewPage(['title' => 'Some page title', 'slug' => '/some-page-title', 'http_verb' => 'get', 'view' => 'some.view.path', 'language_id' => 163]); assertNotFalse($page); assertInstanceOf('DvsPageVersion', $page->version); assertEquals($page->title, 'Some page title'); assertEquals($page->route_name, 'es-some-page-title'); }
public function test_it_can_search_thru_items() { $mockedResult = new MockedSearchResult(); $item1 = m::mock('Devise\\Search\\Searchable'); $item1->shouldReceive('search')->andReturn($mockedResult); $this->search->register($item1); $outcome = $this->search->search('asdf'); assertInstanceOf('Devise\\Search\\Pagination', $outcome); assertCount(1, $outcome->toArray()['items']); }
public function testSetState() { $data = array('id' => 1, 'prefix' => 'some_', 'indexes' => array('index1', 'index2'), 'sortedIndexes' => array('sortedIndex1', 'sortedIndex2'), 'propertyMappings' => array(array('name' => 'property', 'type' => 'string'))); $metadata = Metadata::__set_state($data); assertInstanceOf('Tystr\\RedisOrm\\Metadata\\Metadata', $metadata); assertEquals($data['id'], $metadata->getId()); assertEquals($data['prefix'], $metadata->getPrefix()); assertEquals($data['indexes'], $metadata->getIndexes()); assertEquals($data['sortedIndexes'], $metadata->getSortedIndexes()); assertEquals($data['propertyMappings'], $metadata->getPropertyMappings()); }
public function testReadReturnCorrectDataType() { $asset_holder = new \Vinelab\Cdn\Asset(); $asset_holder->init(array('include' => ['directories' => [__DIR__]])); $console_output = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput'); $console_output->shouldReceive('writeln')->atLeast(1); $finder = new \Vinelab\Cdn\Finder($console_output); $result = $finder->read($asset_holder); assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $result->first()); assertEquals($result, new Collection($result->all())); }
public function test_it_renames_devise_tags() { $parser = new DeviseParser(); $traverser = new NodeTraverser(); $traverser->addVisitor(new RegisterDeviseTags($parser)); $nodes = $parser->parse($this->fixture('devise-views.interpret3')); $nodes = $traverser->traverse($nodes); assertContains('<body>', $nodes[9]->value); assertInstanceOf('PhpParser\\Node\\Stmt\\Foreach_', $nodes[10]); assertContains('<div data-devise-<?php echo devise_tag_cid(\'key1\', "field", null, "key1", "type", "Human name 1", null, null, null, null, null) ?>="key1">Hello there #1</div>', $nodes[10]->stmts[0]->value); assertContains('<div data-devise-<?php echo devise_tag_cid(\'key2\', "field", null, "key2", "type", "Human name 2", null, null, null, null, null) ?>="key2">Hello there #2</div>', $nodes[10]->stmts[1]->stmts[0]->value); assertContains('<p data-devise-<?php echo devise_tag_cid(\'outside\', "field", null, "outside", "type", "Outside Key", null, null, null, null, null) ?>="outside">', $nodes[11]->value); }
public function testUnset() { $this->createModels(Order::class, $array = [['code' => 'a1', 'shipping' => 'home', 'customer_id' => 1], ['code' => 'b1', 'shipping' => 'office', 'customer_id' => 1]]); $collection = Order::all(); $source = DataSource::make($collection); assertInstanceOf(Order::class, $source[0]); assertInstanceOf(Order::class, $source[1]); assertInstanceOf(Order::class, $collection[0]); assertInstanceOf(Order::class, $collection[1]); unset($source[0]); assertNull($source[0]); assertInstanceOf(Order::class, $source[1]); assertTrue(!isset($collection[0])); assertInstanceOf(Order::class, $collection[1]); unset($source[1]); assertNull($source[1]); assertTrue(!isset($collection[1])); }
public function test_it_validates_fields_on_update() { $page = ['page_version_id' => 50, 'page_id' => 42, 'language_id' => 45]; $fields = [['id' => 1, 'model_id' => 1, 'model_type' => 'DvsTestModel', 'mapping' => 'Name', 'json_value' => '{}', 'values' => ['foo' => 'bar']]]; $this->addSomeTestModelFields(); try { $this->ModelManager->updateFields($fields, $page); } catch (ModelFieldValidationFailedException $e) { $field = \DvsModelField::find(1); $model = \DvsTestModel::find(1); assertEquals(1, $model->page_version_id); assertEquals('Some name here', $model->name); assertEquals('{}', $field->json_value); assertInstanceOf('Illuminate\\Support\\MessageBag', $e->getErrors()); assertEquals('The name field is required.', $e->getErrors()->first('name')); return; } throw new \Exception("We should not reach this line unless the model validation exception was not thrown..."); }
public function testExistingChildren() { // --- test load $this->createModels(Customer::class, []); $this->createModels(Order::class, [['code' => 'a1', 'shipping' => 'home', 'customer_id' => 1], ['code' => 'b1', 'shipping' => 'office', 'customer_id' => 1]]); $customer = new Customer(); $source = Datasource::make(new Customer()); $source['id'] = 1; $source['name'] = 'Frank'; $source['surname'] = 'Sinatra'; $source->save(); // this is how eloquent behaves (always false) assertFalse(isset($customer->orders)); // this is how datasource behaves (always true) assertTrue(isset($source['orders'])); assertInstanceOf(Collection::class, $customer->orders); assertInstanceOf(Collection::class, $source['orders']); assertModelArrayEqual(Order::all(), $source['orders']); // don't do this at home, folks :) assertSame('Frank', $source['orders.0.customer.name']); assertSame('Frank', $source['orders.0.customer.orders.0.customer.name']); }
public function testExistingChildren() { // --- test load $this->createModels(Order::class, []); $this->createModels(Book::class, [['title' => 'Happiness'], ['title' => 'Delight']]); $this->createPivot('book_order', [['book_id' => 1, 'order_id' => 1], ['book_id' => 2, 'order_id' => 1]]); $order = new Order(); $source = Datasource::make(new Order()); $source['id'] = 1; $source['code'] = 'a1'; $source['shipping'] = 'home'; $source['customer_id'] = 1; $source->save(); // this is how eloquent behaves (always false) assertFalse(isset($order->books)); // this is how datasource behaves (always true) assertTrue(isset($source['books'])); assertInstanceOf(Collection::class, $order->books); assertInstanceOf(Collection::class, $source['books']); assertModelArrayEqual(Book::all()->toArray(), $source['books']->toArray()); // don't do this at home, folks :) assertSame('Happiness', $source['books.0.orders.0.books.0.title']); assertSame('Happiness', $source['books.0.orders.0.books.0.orders.0.books.0.orders.0.books.0.title']); }
function testSleepAndWakeUp() { $faber = F::instance('test'); $faber['foo'] = function () { return new Stub(); }; $faber['bar'] = 'baz'; $faber->protect('hello', function () { return 'Hello'; }); $foo = $faber['foo']; $bar = $faber['bar']; $hello = $faber['hello']; $sleep = serialize($faber); $wakeup = unserialize($sleep); $foo2 = $wakeup['foo']; $bar2 = $wakeup['bar']; $hello2 = $wakeup['hello']; assertInstanceOf('GM\\Faber\\Tests\\Stub', $foo); assertInstanceOf('Closure', $hello); assertTrue($foo === $foo2); assertTrue($bar === $bar2); assertTrue($hello === $hello2); }
public function testItIsADomainException() { assertInstanceOf(DomainException::class, new UnknownSettingException()); }
public function testItIsALogicException() { assertInstanceOf(LogicException::class, new NoMatchingFilesException()); }
public function testMake() { assertInstanceOf(EloquentModelDataSource::class, DataSource::make(new Customer())); }
/** * @BeforeScenario * * Checks that we have access to main context (FeatureContext). */ public function checkThatWeHaveMainContext() { assertInstanceOf('FeatureContext', $this->getMainContext()); assertEquals('Hello, zet', $this->getMainContext()->getSubcontext('support')->hello('zet')); }
/** * @test * @covers Mobileka\ScopeApplicator\Laravel\Repository::getLogger */ public function returns_logger_instance() { $repository = new Stubs\Repository(); assertInstanceOf('Mobileka\\ScopeApplicator\\Contracts\\LoggerInterface', $repository->getLogger()); }
public function test_it_can_get_all_templates_paginated_with_invalid_param() { assertInstanceOf('Illuminate\\Pagination\\LengthAwarePaginator', $this->TemplatesRepository->allTemplatesPaginated('abc')); }
public function test_it_overrides_new_query() { $pages = new \DvsPage(); $builder = $pages->newQuery(); assertInstanceOf('Devise\\Support\\Sortable\\EloquentBuilder', $builder); }
/** * @Then there should be :count car */ public function iThereShouldBeCarReturned($count) { assertCount($count, $this->cars); assertInstanceOf('Tystr\\RedisOrm\\Test\\Model\\Car', $this->cars[0]); }
public function test_it_finds_menu_by_name() { $this->createMenu(); assertInstanceOf('DvsMenu', $this->MenusRepository->findMenuByName("Name")); }