Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure buiid script #96

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Controller/Web/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function post()
setcookie('userId', $response->getUserId(), time() + (86400 * 30), "/");
setcookie('authToken', $response->getAuthToken(), time() + (86400 * 30), "/");
$app = \Slim\Slim::getInstance('developer');
$app->redirect("/notes");
$app->redirect("./notes");
}
} catch (\InvalidArgumentException $error) {
$response = $error->getMessage();
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Web/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function post()
$response = $userService->create($input);
if ($response instanceof UserModel) {
$app = \Slim\Slim::getInstance('developer');
$app->redirect("/login");
$app->redirect("./login");
}
} catch (\InvalidArgumentException $error) {
$response = $error->getMessage();
Expand Down
44 changes: 35 additions & 9 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Notes" default="build" xmlns:flyway="antlib:org.flywaydb.ant">
<target name="build" depends="copy-config,replace-config-dbname,migrate-db,prepare,composer,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpunit,phpdox"/>

<target name="build" depends="copy-config,print,replace-config-dbname,migrate-db,prepare,start-selenium-server,composer,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpunit,stop-selenium-server,phpdox"/>
<target name="print">
<property environment="env"/>
<echo>${env.JOB_NAME}</echo>

</target>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/coverage"/>
Expand All @@ -16,24 +20,30 @@
</target>

<target name="copy-config" depends="clean">
<property environment="env.APP_ENV"/>
<property environment="env"/>
<condition property="env.APP_ENV" value="${env.APP_ENV}" else="dev">
<isset property="env.APP_ENV" />
</condition>
<property name="env.APP_ENV" value="dev"/>
<property name="env" value="dev"/>
<echo message="Configuring app environment to ${env.APP_ENV}."/>
<copy file="${basedir}/app/Config/config_${env.APP_ENV}.json" tofile="${basedir}/app/Config/config.json"/>

</target>


<target name="replace-config-dbname" depends="copy-config">
<property environment="env.GIT_BRANCH"/>
<property environment="env"/>
<condition property="env.GIT_BRANCH" value="${env.GIT_BRANCH}" else="master">
<isset property="env.GIT_BRANCH" />
</condition>
<property name="" value="master"/>
<echo message="Using database name notes-${env.GIT_BRANCH} for this build."/>
<replace file="${basedir}/app/Config/config.json" token="@GIT_BRANCH" value="${env.GIT_BRANCH}"/>

<condition property="env.JOB_NAME" value="${env.JOB_NAME}" else="">
<isset property="env.JOB_NAME" />
</condition>
<echo message="Using Job name ${env.JOB_NAME} for this build."/>
<replace file="${basedir}/build/phpunit.xml" token="@JOB_NAME" value="${env.JOB_NAME}"/>
</target>

<target name="migrate-db" depends="replace-config-dbname" unless="migrate-db.done" description="Cleanup db and build from scratch">
Expand All @@ -57,13 +67,25 @@
</target>

<target name="composer" depends="clean" unless="composer.noupdate" description="Run composer install">
<exec executable="php">
<exec executable="php">
<arg value="${basedir}/build/tools/composer.phar"/>
<arg value="install"/>
<arg value="--profile"/>
</exec>
</target>

<target name="start-selenium-server" depends="clean" description="selenium-server-starts">

<exec executable="xvfb-run" spawn="true">
<arg value="java"/>
<arg value="-jar"/>
<arg value="${basedir}/build/tools/selenium-server-standalone-2.45.0.jar"/>
<arg value="-log"/>
<arg value="${basedir}/build/logs/selenium-server-start.log"/>
<arg value="&amp;"/>
</exec>
</target>

<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/coverage"/>
Expand Down Expand Up @@ -178,8 +200,12 @@
</exec>
</target>

<target name="phpdox" depends="phploc-ci,phpcs-ci,phpmd-ci" description="Generate API documentation using phpDox">
<target name="stop-selenium-server" description="selenium-server-stop">
<get taskname="selenium-shutdown" dest="${basedir}/build/logs/selenium-server-stop.log" ignoreerrors="true"
src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"/>
</target>

<target name="phpdox" depends="phploc-ci,phpcs-ci,phpmd-ci,stop-selenium-server" description="Generate API documentation using phpDox">
<exec executable="${basedir}/build/tools/phpdox.phar" dir="${basedir}/build"/>
</target>
</project>

7 changes: 6 additions & 1 deletion build/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
bootstrap="../vendor/autoload.php"
strict="true"
verbose="true"
timeoutForSmallTests="10">
timeoutForSmallTests="10"
timeoutForLargeTests="50">
<testsuites>
<testsuite name="Notes">
<directory suffix="Test.php">../tests</directory>
Expand All @@ -24,5 +25,9 @@
<directory suffix=".php">../app</directory>
</whitelist>
</filter>
<php>
<env name="JobName" value="@JOB_NAME" />
</php>

</phpunit>

Binary file added build/tools/3EE67F3D0FF405B2.gpg
Binary file not shown.
Binary file added build/tools/selenium-server-standalone-2.45.0.jar
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/AcceptanceTest/LoginTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

class LoginTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setHost('localhost');
$this->setBrowser('firefox');
$this->setBrowserUrl('http://localhost/');
}

/**
* @large
**/
public function testTitle()
{
$name=getenv("JobName");
$this->url("$name/public/index.php/login");
$this->assertEquals('Login', $this->title());

$this->byName('email')->value("[email protected]");
$this->byName('password')->value("Gauri@12");
$this->byCssSelector('form')->submit();
$welcom=$this->byCssSelector('div');
$this->assertEquals('Login', $this->title());
//$this->assertEquals('Html', $welcom);

}
}
50 changes: 50 additions & 0 deletions tests/AcceptanceTest/googleChromeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

class googleTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setHost('localhost');
$this->setBrowser('google-chrome');
$this->setBrowserUrl('http://localhost/');
}
/**
* @large
**/
public function testHomeTitle()
{
$name=getenv("JobName");
$this->url("$name/public/index.php/register");
$this->byName('firstName')->value("jonh");
$this->byName('lastName')->value("Mock");
$this->byName('email')->value("[email protected]");
$this->byName('password')->value("Mock@1234");
$this->byCssSelector('form')->submit();
$this->assertEquals('Login', $this->title());
$this->byName('email')->value("[email protected]");
$this->byName('password')->value("Mock@1234");
$this->byCssSelector('form')->submit();
$this->assertEquals('Notes | Home', $this->title());



}
/**
* @large
**/

public function testLoginTitle()
{
$name=getenv("JobName");
$this->url("$name/public/index.php/login");
$this->assertEquals('Login', $this->title());

$this->byName('email')->value("[email protected]");
$this->byName('password')->value("Gauri@12");
$this->byCssSelector('form')->submit();
$this->assertEquals('Login', $this->title());


}

}
4 changes: 2 additions & 2 deletions tests/Routes/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function loginpage_should_be_loaded_after_user_registration()
$client->post('/register' ,$parameters);

$this->assertEquals(302, $client->response->status());
$this->assertEquals('/login', $client->response->getIterator()["Location"]);
$this->assertEquals('./login', $client->response->getIterator()["Location"]);

}

Expand Down Expand Up @@ -105,7 +105,7 @@ public function loginpage_should_be_loaded_after_user_logged_in()
$client->post('/login', $parameters);

$this->assertEquals(302, $client->response->status());
$this->assertEquals('/notes', $client->response->getIterator()["Location"]);
$this->assertEquals('./notes', $client->response->getIterator()["Location"]);
}

/**
Expand Down