Ejemplo n.º 1
0
 public function testPjaxAndFullpageResponses()
 {
     $this->mockRequest->shouldReceive('wantsJson')->andReturn(false);
     View::shouldReceive('make')->with('view', [], [])->once()->andReturn('view');
     $this->respondable->respond('view');
     $this->assertEquals('whatever', $this->respondable->layout->main);
 }
Ejemplo n.º 2
0
 public function testIndex()
 {
     $this->markTestIncomplete('This test has not been implemented yet.');
     View::shouldReceive('make')->once()->with('cabinet::admin.index')->andReturn('admin index!');
     $response = $this->action('GET', self::$wardrobeControllers . 'AdminController@index');
     $this->assertSame('admin index!', $response->original);
 }
 public function testAssertViewIs()
 {
     View::shouldReceive('make')->once()->with('foo');
     $this->response->shouldReceive('getOriginalContent')->once()->andReturn(Mockery::mock(['getName' => 'foo']));
     $this->controller->show();
     $this->assertViewis('foo');
 }
Ejemplo n.º 4
0
 public function testGetViewReturnsDefaultViewWithNoView()
 {
     $template = new Template();
     View::shouldReceive('exists')->with(\Mockery::any())->andReturn(false);
     View::shouldReceive('make')->with('boomcms::templates.default');
     $template->getView();
 }
Ejemplo n.º 5
0
 public function testPjaxRequest()
 {
     $this->mockRequest->shouldReceive('wantsJson')->andReturn(false);
     $this->mockRequest->shouldReceive('header')->with('X-PJAX')->twice()->andReturn('true');
     View::shouldReceive('make')->with('shift::layouts.pjax', [], [])->once();
     $this->controller->setup();
 }
Ejemplo n.º 6
0
 public function testRender()
 {
     View::shouldReceive('make')->once()->with('datatable::template', \Mockery::any())->andReturn(true);
     $this->table->setUrl('fooBar');
     $table1 = $this->table->addColumn('foo')->render();
     $this->assertEquals(array('options' => '{ "sPaginationType":"full_numbers",' . PHP_EOL . '"bProcessing":false,' . PHP_EOL . '"sAjaxSource":"fooBar",' . PHP_EOL . '"bServerSide":true }', 'values' => array(), 'data' => array(), 'columns' => array(1 => 'foo'), 'noScript' => false, 'class' => $this->table->getClass(), 'id' => $this->table->getId()), $this->table->getViewParameters());
     $this->assertTrue($table1);
 }
Ejemplo n.º 7
0
 public function testViewUsesNamespaceOfActivePageTemplate()
 {
     $template = new Template(['theme' => 'test']);
     $page = $this->getMock(Page::class, ['getTemplate']);
     $page->expects($this->once())->method('getTemplate')->will($this->returnValue($template));
     Editor::shouldReceive('getActivePage')->andReturn($page);
     View::shouldReceive('make')->with('test::name', [])->andReturn('view');
     $this->assertEquals('view', Helpers::view('name'));
 }
 /**
  * Specs for RouteGenerator::execute()
  */
 public function testExecuteMethod()
 {
     $class = $this->prepareSpecify();
     $this->specify('renders if one class name is passed.', function () use($class) {
         View::shouldReceive('make->render')->once()->andReturn('test output');
         $params = ['element' => 'test'];
         expect($class->execute($params))->equals('test output');
     });
 }
Ejemplo n.º 9
0
 public function testSendSMSNotification()
 {
     $twilioClient = new stdClass();
     $twilioClient->account = new stdClass();
     $messageService = Mockery::mock('stdClass');
     $twilioClient->account->sms_messages = $messageService;
     $messageService->shouldReceive('create')->once()->with('1234', 'fooUser', 'renderedContent');
     $viewContent = Mockery::mock('stdClass');
     $viewContent->shouldReceive('render')->once()->andReturn('renderedContent');
     $sms = new \Skovachev\Notifier\Notifiers\SMSNotifier($twilioClient);
     Config::shouldReceive('get')->once()->with('notifier::sms.enabled')->andReturn(true);
     Config::shouldReceive('get')->once()->with('notifier::sms.getter_phone')->andReturn(function ($user) {
         return $user;
     });
     Config::shouldReceive('get')->once()->with('notifier::sms.twilio.phone_number')->andReturn('1234');
     Config::shouldReceive('get')->once()->with('notifier::views_folder')->andReturn('foobar');
     View::shouldReceive('make')->once()->with('foobar.sms.fooView', array('foo' => 'bar', 'user' => 'fooUser'))->andReturn($viewContent);
     $sms->notify('fooUser', 'fooView', array('foo' => 'bar'));
 }
Ejemplo n.º 10
0
 /**
  * Specs for Generator::execute()
  */
 public function testExecuteMethod()
 {
     $class = $this->prepareSpecify();
     $this->specify('renders if one class name is passed.', function () use($class) {
         View::shouldReceive('make->render')->once()->andReturn('test output');
         File::shouldReceive('exists')->twice()->with('/\\.php$/')->andReturn(false);
         File::shouldReceive('put')->once()->with('/\\.php$/', 'test output')->andReturn(true);
         $params = ['classes' => ['test' => []]];
         expect($class->execute($params))->greaterThan(0);
     });
     $this->specify('does not count failed views.', function () use($class) {
         View::shouldReceive('make->render')->once()->andReturn('test output');
         File::shouldReceive('exists')->twice()->with('/\\.php$/')->andReturn(false);
         File::shouldReceive('put')->once()->with('/\\.php$/', 'test output')->andReturn(false);
         $params = ['classes' => ['test' => []]];
         expect($class->execute($params))->equals(0);
     });
     $this->specify('keeps overridden view.', function () use($class) {
         View::shouldReceive('make')->once()->with('test::view', Mockery::type('array'));
         View::shouldReceive('make->render')->once()->andReturn('test output');
         File::shouldReceive('exists')->twice()->with('/\\.php$/')->andReturn(false);
         File::shouldReceive('put')->once()->with('/\\.php$/', 'test output')->andReturn(true);
         $params = ['classes' => ['test' => []]];
         expect($class->execute($params))->greaterThan(0);
     });
 }
Ejemplo n.º 11
0
 public function testRemindForm()
 {
     View::shouldReceive('make')->once()->with('cabinet::admin.auth.forgot')->andReturn('forgot my password');
     $response = $this->action('GET', self::$wardrobeControllers . 'LoginController@remindForm');
     $this->assertSame('forgot my password', $response->original);
 }
Ejemplo n.º 12
0
 public function testLinkWithPermissionsAllowed()
 {
     $this->mockPermissonsService->shouldReceive('permits')->once()->with(['User' => 'write'])->andReturn(true);
     View::shouldReceive('make')->with('shift::html.buttons.link', ['title' => 'Edit user', 'url' => 'users/edit/1', 'icon' => '', 'iconClass' => '', 'size' => 'big', 'type' => ''])->once()->andReturn('permitted button');
     $this->assertEquals('permitted button', $this->buttonBuilder->link('users/edit/1', 'Edit user', ['permissions' => ['User' => 'write']]));
 }