Yii2 url generation issue - yii2

In Yii2 Codeception acceptance test I am using PhantomJs as a browser.
Started server successfully
phantomjs --webdriver=4444
When running test with
codecept run
It isn't working as expected.
My code is:
class LoginCest
{
public function ensureThatLoginWorks(AcceptanceTester $I)
{
$I->amOnPage(Url::toRoute('/site/login'));
$I->see('Enq','b');
}
}
When changing it to
$I->amOnPage(Url::toRoute(['/../../../site/login']));
its works fine because it takes url as myApp/web/usr/local/bin/site/login
Its adding automatically usr/local/bin
is there any solution for this apart from this $I->amOnPage(Url::toRoute(['/../../../site/login']));

Worked fine whe replacing
$I->amOnPage(Url::toRoute(['/../../../site/login']));
with this
$I->amOnPage('/site/login');

Related

Angular 6 PWA -- The PWA functionality is interefering with Azure Adal Authentication, not sure how to bypass it

I have a PWA built with Angular 6 and the #angular/pwa npm package and authenticating using adal-angular4 npm package (but could just rebuild that from scratch if needed -- the issue isn't a bug in the package I think)
When attempting to authenticate, although it does work, users are very often greeted with this message of not found (screenshot of console but its the same).
This especially seems to be the case if you are already authenticated to another (or itself) Azure AD product. Where it normally should only load for a while and then let the user in.
Service worker error transcript:
Failed to load 'link.com/#LONGTOKEN' A serviceWorker passed a promise
to FetchEvent.respondWith() that rejected with 'Error: Response not Ok
(fetchAndCacheOnce): request for LINK.com/index.html returned response 404 Not Found'.
It seems that writing a function to check for new version of the PWA has cleaned up everything. Because it's a PWA, when replacing files with a new version -- the cache will still be there and shift+reloading won't necessarily clear it, causing a lot of unwanted behaviour.
The code for the cleanup looks like this:
First, inject in the constructor the following: updates: SwUpdate
import { SwUpdate } from "#angular/service-worker"
Then, inside ngOnInit, I have the following:
updates.available.subscribe(event => {
updates.activateUpdate().then(() => document.location.reload());
})
It will force a complete refresh 2-3 seconds in if there's a new version available but all works well afterwards.

Grunt doesn't run json_server task from grunt-json-server

I am using the configuration the npm page gives an example for, yet when I try to run the task using either grunt.run.task (['json_server']) or in concurrent: { server: { tasks [ 'json_server'] } }, grunt doesn't even print out the task name in the console. It doesn't even give me an error if I remove the db file it tries to point to.
See: https://github.com/tfiwm/grunt-json-server/issues/4
The library uses registerMultiTask; when changed to registerTask, it worked fine for me.

MVC - JSON.stringify not working when publishing app to IIS7

During my debugging phase everything with JSON.stringify(editedRows) was working fine on my local development server. I deployed my app to an IIS7 server and JSON.stringify(editedRows) stopped working when I browsed to the site. When I logged onto the server to launch the app from IIS, JSON.stringify(editedRows) worked. I looked over some posts, but nothing seem to solve this issue. Has anyone run into this issue? Thank you.
$('#SaveJobs').on('click', function () {
var editedRows = getEditedRows(); // get rows from a grid
alert('Before JSON'); // I see this alert
var json = JSON.stringify(editedRows);
alert('After JSON'); // I do not see this alert and my browser keeps waiting
});
well I added a reference to the json2.js script, which I did not have in my library of scripts and it worked. I am still confused on why it was working on my dev machine and when I logged onto the server without this library. I am using IE 10 and my other JS libraries are below. If somebody with more knowledge on this subject know please post it below. Thank you!
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/json2.js",
"~/Scripts/jquery.event.drag.js"

why adding razorformat breaks web services in servicestack latest 3.9.45.0

I am breaking my head today why after upgrading to latest servicestack and servicestack.razor my routing in web services stops working. So I did the following test.
created a new empty web project in vs.net 2012
added web.config file from rockstar
added servicestack and razor through nuget
added apphost and global.asa
in my configure() i did not add anything - no plugins.
added a simple echoservice with route specified
at this point point all works fine, i click the routed url and get my echo result back
added the line to config to add RazorFormat plugin
Now the route does not work, I am getting 404 (file not found) after return from the service with echo data. I can create a view for that service and then all fine, but what happened to default display?
Thanks
Mark
I tried to do the same with servicestack out of the box example and get the same result
Took a sample from servicestack – RootPath40 + Common and included them in separate solution
Compiled and it works
Current version of servicestack used by example is 3.9.11.0
Ran the following to update servicestack and install razor on both projects in the solution
so i get latest 3.9.45
install-package servicestack
install-package servicestack.razor
Tested – works fine!!!. I am testing specifically Hello service using the route Hello ->
localhost/RootPath40/hello
Added 1 line to Global.asax.cs – Configure function
public override void Configure(Container container)
{
container.Register(new TodoRepository());
**Plugins.Add(new RazorFormat());**
}
Now the route hello do not work anymore because I get error 404 not found.
I am using vs.net 2012 and windows 8
I am sure I am missing something very trivial, anyone knows...
Thanks
After struggling a little more I see that if I add reference to System.Web.Razor.Unofficial.dll then razor pages are served but routed web services stop working, the minute I remove the reference the web service routing urls are fine but razor pages are not served.
What am I missing?
Finally i figured out the problem.
The new version of servicestack (3.9.45.0) appears to have a bug in IF condition.
In HtmlFormat.cs
public void SerializeToStream(IRequestContext requestContext, object response, IHttpResponse httpRes)
{
var httpReq = requestContext.Get<IHttpRequest>();
if (httpReq != null && AppHost.ViewEngines.Any(x => x.ProcessRequest(httpReq, httpRes, response))) return;
...
...
The "NOT" ! (exclamation mark) is missing, but it should only return if none of the ViewEngines executed request. I added the NOT and walla, all works.
if (httpReq != null && **!**AppHost.ViewEngines.Any(x => x.ProcessRequest(httpReq, httpRes, response))) return;
Thanks
Mark
This was a bug with the new Razor support that was identified in this issue and fixed in v3.9.46+ of ServiceStack.Razor.

How to solve the "error 500" issue of Symfony PHP framework with Webkit browsers?

I'm having an issue with the visualization of my site on Google Chrome and Safari (both using Webkit rendering engine), the site is built upon Symfony framework, version 1.1 (unmaintained version).
When navigating to the site, this shows an error 500 when loading a page, I read somewhere that it might be related to Symfony caching but I don't know how to solve it and turning off caching is not a solution.
Thankyou in advance.
This ticket fixes the problem, so you can patch your sfWebRequest class code.
You can see the actual problem by browsing via "dev" controller. It's called by default: yourAppName_dev.php
So if you have a "frontend" app, it's:
http://domain.tld/frontend_dev.php
Yes, most of the cases for error 500 is the cache. You can clear the cache by navigating to your project root directory and type:
symfony cc
or
./symfony cc
or
php symfony cc
which depends of you environment and setup.
Also you can delete the content of the cache directory located in your project root manually.
Hope this helps.
See this: http://forum.symfony-project.org/index.php/m/75225/
To fix, change your config/ProjectConfiguration.class.php to include the following:
public function setup()
{
// keep current code here and then add...
$this->dispatcher->connect('request.filter_parameters', array($this, 'filterRequestParameters'));
}
public function filterRequestParameters(sfEvent $event, $parameters)
{
$request = $event->getSubject();
if (preg_match('|Safari/([0-9\.]+)|', $request->getHttpHeader('User-Agent')))
{
$request->setRequestFormat('html');
}
return $parameters;
}