`, and ``.
@font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace;
@font-family-base: @font-family-sans-serif;
@font-size-base: 14px;
@font-size-large: ceil((@font-size-base * 1.25)); // ~18px
@font-size-small: ceil((@font-size-base * 0.85)); // ~12px
@font-size-h1: floor((@font-size-base * 2.6)); // ~36px
@font-size-h2: floor((@font-size-base * 2.15)); // ~30px
@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px
@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px
@font-size-h5: @font-size-base;
@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px
//** Unit-less `line-height` for use in components like buttons.
@line-height-base: 1.428571429; // 20/14
//** Computed "line-height" (`font-size` * `line-height`) for use with `margin`, `padding`, etc.
@line-height-computed: floor((@font-size-base * @line-height-base)); // ~20px
//** By default, this inherits from the ``.
@headings-font-family: inherit;
@headings-font-weight: 500;
@headings-line-height: 1.1;
@headings-color: inherit;
//== Iconography
//
//## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower.
//** Load fonts from this directory.
@icon-font-path: "../fonts/";
//** File name for all font files.
@icon-font-name: "glyphicons-halflings-regular";
//** Element ID within SVG icon file.
@icon-font-svg-id: "glyphicons_halflingsregular";
//== Components
//
//## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start).
@padding-base-vertical: 6px;
@padding-base-horizontal: 12px;
@padding-large-vertical: 10px;
@padding-large-horizontal: 16px;
@padding-small-vertical: 5px;
@padding-small-horizontal: 10px;
@padding-xs-vertical: 1px;
@padding-xs-horizontal: 5px;
@line-height-large: 1.33;
@line-height-small: 1.5;
@border-radius-base: 4px;
@border-radius-large: 6px;
@border-radius-small: 3px;
//** Global color for active items (e.g., navs or dropdowns).
@component-active-color: #fff;
//** Global background color for active items (e.g., navs or dropdowns).
@component-active-bg: @brand-primary;
//** Width of the `border` for generating carets that indicator dropdowns.
@caret-width-base: 4px;
//** Carets increase slightly in size for larger components.
@caret-width-large: 5px;
//== Tables
//
//## Customizes the `.table` component with basic values, each used across all table variations.
//** Padding for `| `s and ` | `s.
@table-cell-padding: 8px;
//** Padding for cells in `.table-condensed`.
@table-condensed-cell-padding: 5px;
//** Default background color used for all tables.
@table-bg: transparent;
//** Background color used for `.table-striped`.
@table-bg-accent: #f9f9f9;
//** Background color used for `.table-hover`.
@table-bg-hover: #f5f5f5;
@table-bg-active: @table-bg-hover;
//** Border color for table and cell borders.
@table-border-color: #ddd;
//== Buttons
//
//## For each of Bootstrap's buttons, define text, background and border color.
@btn-font-weight: normal;
@btn-default-color: #333;
@btn-default-bg: #fff;
@btn-default-border: #ccc;
@btn-primary-color: #fff;
@btn-primary-bg: @brand-primary;
@btn-primary-border: darken(@btn-primary-bg, 5%);
@btn-success-color: #fff;
@btn-success-bg: @brand-success;
@btn-success-border: darken(@btn-success-bg, 5%);
@btn-info-color: #fff;
@btn-info-bg: @brand-info;
@btn-info-border: darken(@btn-info-bg, 5%);
@btn-warning-color: #fff;
@btn-warning-bg: @brand-warning;
@btn-warning-border: darken(@btn-warning-bg, 5%);
@btn-danger-color: #fff;
@btn-danger-bg: @brand-danger;
@btn-danger-border: darken(@btn-danger-bg, 5%);
@btn-link-disabled-color: @gray-light;
//== Forms
//
//##
//** `` background color
@input-bg: #fff;
//** `` background color
@input-bg-disabled: @gray-lighter;
//** Text color for ``s
@input-color: @gray;
//** `` border color
@input-border: #ccc;
// TODO: Rename `@input-border-radius` to `@input-border-radius-base` in v4
//** Default `.form-control` border radius
@input-border-radius: @border-radius-base;
//** Large `.form-control` border radius
@input-border-radius-large: @border-radius-large;
//** Small `.form-control` border radius
@input-border-radius-small: @border-radius-small;
//** Border color for inputs on focus
@input-border-focus: #66afe9;
//** Placeholder text color
@input-color-placeholder: #999;
//** Default `.form-control` height
@input-height-base: (@line-height-computed + (@padding-base-vertical * 2) + 2);
//** Large `.form-control` height
@input-height-large: (ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + 2);
//** Small `.form-control` height
@input-height-small: (floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + 2);
@legend-color: @gray-dark;
@legend-border-color: #e5e5e5;
//** Background color for textual input addons
@input-group-addon-bg: @gray-lighter;
//** Border color for textual input addons
@input-group-addon-border-color: @input-border;
//** Disabled cursor for form controls and buttons.
@cursor-disabled: not-allowed;
//== Dropdowns
//
//## Dropdown menu container and contents.
//** Background for the dropdown menu.
@dropdown-bg: #fff;
//** Dropdown menu `border-color`.
@dropdown-border: rgba(0,0,0,.15);
//** Dropdown menu `border-color` **for IE8**.
@dropdown-fallback-border: #ccc;
//** Divider color for between dropdown items.
@dropdown-divider-bg: #e5e5e5;
//** Dropdown link text color.
@dropdown-link-color: @gray-dark;
//** Hover color for dropdown links.
@dropdown-link-hover-color: darken(@gray-dark, 5%);
//** Hover background for dropdown links.
@dropdown-link-hover-bg: #f5f5f5;
//** Active dropdown menu item text color.
@dropdown-link-active-color: @component-active-color;
//** Active dropdown menu item background color.
@dropdown-link-active-bg: @component-active-bg;
//** Disabled dropdown menu item background color.
@dropdown-link-disabled-color: @gray-light;
//** Text color for headers within dropdown menus.
@dropdown-header-color: @gray-light;
//** Deprecated `@dropdown-caret-color` as of v3.1.0
@dropdown-caret-color: #000;
//-- Z-index master list
//
// Warning: Avoid customizing these values. They're used for a bird's eye view
// of components dependent on the z-axis and are designed to all work together.
//
// Note: These variables are not generated into the Customizer.
@zindex-navbar: 1000;
@zindex-dropdown: 1000;
@zindex-popover: 1060;
@zindex-tooltip: 1070;
@zindex-navbar-fixed: 1030;
@zindex-modal: 1040;
//== Media queries breakpoints
//
//## Define the breakpoints at which your layout will change, adapting to different screen sizes.
// Extra small screen / phone
//** Deprecated `@screen-xs` as of v3.0.1
@screen-xs: 480px;
//** Deprecated `@screen-xs-min` as of v3.2.0
@screen-xs-min: @screen-xs;
//** Deprecated `@screen-phone` as of v3.0.1
@screen-phone: @screen-xs-min;
// Small screen / tablet
//** Deprecated `@screen-sm` as of v3.0.1
@screen-sm: 768px;
@screen-sm-min: @screen-sm;
//** Deprecated `@screen-tablet` as of v3.0.1
@screen-tablet: @screen-sm-min;
// Medium screen / desktop
//** Deprecated `@screen-md` as of v3.0.1
@screen-md: 992px;
@screen-md-min: @screen-md;
//** Deprecated `@screen-desktop` as of v3.0.1
@screen-desktop: @screen-md-min;
// Large screen / wide desktop
//** Deprecated `@screen-lg` as of v3.0.1
@screen-lg: 1200px;
@screen-lg-min: @screen-lg;
//** Deprecated `@screen-lg-desktop` as of v3.0.1
@screen-lg-desktop: @screen-lg-min;
// So media queries don't overlap when required, provide a maximum
@screen-xs-max: (@screen-sm-min - 1);
@screen-sm-max: (@screen-md-min - 1);
@screen-md-max: (@screen-lg-min - 1);
//== Grid system
//
//## Define your custom responsive grid.
//** Number of columns in the grid.
@grid-columns: 12;
//** Padding between columns. Gets divided in half for the left and right.
@grid-gutter-width: 30px;
// Navbar collapse
//** Point at which the navbar becomes uncollapsed.
@grid-float-breakpoint: @screen-sm-min;
//** Point at which the navbar begins collapsing.
@grid-float-breakpoint-max: (@grid-float-breakpoint - 1);
//== Container sizes
//
//## Define the maximum width of `.container` for different screen sizes.
// Small screen / tablet
@container-tablet: (720px + @grid-gutter-width);
//** For `@screen-sm-min` and up.
@container-sm: @container-tablet;
// Medium screen / desktop
@container-desktop: (940px + @grid-gutter-width);
//** For `@screen-md-min` and up.
@container-md: @container-desktop;
// Large screen / wide desktop
@container-large-desktop: (1140px + @grid-gutter-width);
//** For `@screen-lg-min` and up.
@container-lg: @container-large-desktop;
//== Navbar
//
//##
// Basics of a navbar
@navbar-height: 50px;
@navbar-margin-bottom: @line-height-computed;
@navbar-border-radius: @border-radius-base;
@navbar-padding-horizontal: floor((@grid-gutter-width / 2));
@navbar-padding-vertical: ((@navbar-height - @line-height-computed) / 2);
@navbar-collapse-max-height: 340px;
@navbar-default-color: #777;
@navbar-default-bg: #f8f8f8;
@navbar-default-border: darken(@navbar-default-bg, 6.5%);
// Navbar links
@navbar-default-link-color: #777;
@navbar-default-link-hover-color: #333;
@navbar-default-link-hover-bg: transparent;
@navbar-default-link-active-color: #555;
@navbar-default-link-active-bg: darken(@navbar-default-bg, 6.5%);
@navbar-default-link-disabled-color: #ccc;
@navbar-default-link-disabled-bg: transparent;
// Navbar brand label
@navbar-default-brand-color: @navbar-default-link-color;
@navbar-default-brand-hover-color: darken(@navbar-default-brand-color, 10%);
@navbar-default-brand-hover-bg: transparent;
// Navbar toggle
@navbar-default-toggle-hover-bg: #ddd;
@navbar-default-toggle-icon-bar-bg: #888;
@navbar-default-toggle-border-color: #ddd;
// Inverted navbar
// Reset inverted navbar basics
@navbar-inverse-color: lighten(@gray-light, 15%);
@navbar-inverse-bg: #222;
@navbar-inverse-border: darken(@navbar-inverse-bg, 10%);
// Inverted navbar links
@navbar-inverse-link-color: lighten(@gray-light, 15%);
@navbar-inverse-link-hover-color: #fff;
@navbar-inverse-link-hover-bg: transparent;
@navbar-inverse-link-active-color: @navbar-inverse-link-hover-color;
@navbar-inverse-link-active-bg: darken(@navbar-inverse-bg, 10%);
@navbar-inverse-link-disabled-color: #444;
@navbar-inverse-link-disabled-bg: transparent;
// Inverted navbar brand label
@navbar-inverse-brand-color: @navbar-inverse-link-color;
@navbar-inverse-brand-hover-color: #fff;
@navbar-inverse-brand-hover-bg: transparent;
// Inverted navbar toggle
@navbar-inverse-toggle-hover-bg: #333;
@navbar-inverse-toggle-icon-bar-bg: #fff;
@navbar-inverse-toggle-border-color: #333;
//== Navs
//
//##
//=== Shared nav styles
@nav-link-padding: 10px 15px;
@nav-link-hover-bg: @gray-lighter;
@nav-disabled-link-color: @gray-light;
@nav-disabled-link-hover-color: @gray-light;
//== Tabs
@nav-tabs-border-color: #ddd;
@nav-tabs-link-hover-border-color: @gray-lighter;
@nav-tabs-active-link-hover-bg: @body-bg;
@nav-tabs-active-link-hover-color: @gray;
@nav-tabs-active-link-hover-border-color: #ddd;
@nav-tabs-justified-link-border-color: #ddd;
@nav-tabs-justified-active-link-border-color: @body-bg;
//== Pills
@nav-pills-border-radius: @border-radius-base;
@nav-pills-active-link-hover-bg: @component-active-bg;
@nav-pills-active-link-hover-color: @component-active-color;
//== Pagination
//
//##
@pagination-color: @link-color;
@pagination-bg: #fff;
@pagination-border: #ddd;
@pagination-hover-color: @link-hover-color;
@pagination-hover-bg: @gray-lighter;
@pagination-hover-border: #ddd;
@pagination-active-color: #fff;
@pagination-active-bg: @brand-primary;
@pagination-active-border: @brand-primary;
@pagination-disabled-color: @gray-light;
@pagination-disabled-bg: #fff;
@pagination-disabled-border: #ddd;
//== Pager
//
//##
@pager-bg: @pagination-bg;
@pager-border: @pagination-border;
@pager-border-radius: 15px;
@pager-hover-bg: @pagination-hover-bg;
@pager-active-bg: @pagination-active-bg;
@pager-active-color: @pagination-active-color;
@pager-disabled-color: @pagination-disabled-color;
//== Jumbotron
//
//##
@jumbotron-padding: 30px;
@jumbotron-color: inherit;
@jumbotron-bg: @gray-lighter;
@jumbotron-heading-color: inherit;
@jumbotron-font-size: ceil((@font-size-base * 1.5));
//== Form states and alerts
//
//## Define colors for form feedback states and, by default, alerts.
@state-success-text: #3c763d;
@state-success-bg: #dff0d8;
@state-success-border: darken(spin(@state-success-bg, -10), 5%);
@state-info-text: #31708f;
@state-info-bg: #d9edf7;
@state-info-border: darken(spin(@state-info-bg, -10), 7%);
@state-warning-text: #8a6d3b;
@state-warning-bg: #fcf8e3;
@state-warning-border: darken(spin(@state-warning-bg, -10), 5%);
@state-danger-text: #a94442;
@state-danger-bg: #f2dede;
@state-danger-border: darken(spin(@state-danger-bg, -10), 5%);
//== Tooltips
//
//##
//** Tooltip max width
@tooltip-max-width: 200px;
//** Tooltip text color
@tooltip-color: #fff;
//** Tooltip background color
@tooltip-bg: #000;
@tooltip-opacity: .9;
//** Tooltip arrow width
@tooltip-arrow-width: 5px;
//** Tooltip arrow color
@tooltip-arrow-color: @tooltip-bg;
//== Popovers
//
//##
//** Popover body background color
@popover-bg: #fff;
//** Popover maximum width
@popover-max-width: 276px;
//** Popover border color
@popover-border-color: rgba(0,0,0,.2);
//** Popover fallback border color
@popover-fallback-border-color: #ccc;
//** Popover title background color
@popover-title-bg: darken(@popover-bg, 3%);
//** Popover arrow width
@popover-arrow-width: 10px;
//** Popover arrow color
@popover-arrow-color: @popover-bg;
//** Popover outer arrow width
@popover-arrow-outer-width: (@popover-arrow-width + 1);
//** Popover outer arrow color
@popover-arrow-outer-color: fadein(@popover-border-color, 5%);
//** Popover outer arrow fallback color
@popover-arrow-outer-fallback-color: darken(@popover-fallback-border-color, 20%);
//== Labels
//
//##
//** Default label background color
@label-default-bg: @gray-light;
//** Primary label background color
@label-primary-bg: @brand-primary;
//** Success label background color
@label-success-bg: @brand-success;
//** Info label background color
@label-info-bg: @brand-info;
//** Warning label background color
@label-warning-bg: @brand-warning;
//** Danger label background color
@label-danger-bg: @brand-danger;
//** Default label text color
@label-color: #fff;
//** Default text color of a linked label
@label-link-hover-color: #fff;
//== Modals
//
//##
//** Padding applied to the modal body
@modal-inner-padding: 15px;
//** Padding applied to the modal title
@modal-title-padding: 15px;
//** Modal title line-height
@modal-title-line-height: @line-height-base;
//** Background color of modal content area
@modal-content-bg: #fff;
//** Modal content border color
@modal-content-border-color: rgba(0,0,0,.2);
//** Modal content border color **for IE8**
@modal-content-fallback-border-color: #999;
//** Modal backdrop background color
@modal-backdrop-bg: #000;
//** Modal backdrop opacity
@modal-backdrop-opacity: .5;
//** Modal header border color
@modal-header-border-color: #e5e5e5;
//** Modal footer border color
@modal-footer-border-color: @modal-header-border-color;
@modal-lg: 900px;
@modal-md: 600px;
@modal-sm: 300px;
//== Alerts
//
//## Define alert colors, border radius, and padding.
@alert-padding: 15px;
@alert-border-radius: @border-radius-base;
@alert-link-font-weight: bold;
@alert-success-bg: @state-success-bg;
@alert-success-text: @state-success-text;
@alert-success-border: @state-success-border;
@alert-info-bg: @state-info-bg;
@alert-info-text: @state-info-text;
@alert-info-border: @state-info-border;
@alert-warning-bg: @state-warning-bg;
@alert-warning-text: @state-warning-text;
@alert-warning-border: @state-warning-border;
@alert-danger-bg: @state-danger-bg;
@alert-danger-text: @state-danger-text;
@alert-danger-border: @state-danger-border;
//== Progress bars
//
//##
//** Background color of the whole progress component
@progress-bg: #f5f5f5;
//** Progress bar text color
@progress-bar-color: #fff;
//** Variable for setting rounded corners on progress bar.
@progress-border-radius: @border-radius-base;
//** Default progress bar color
@progress-bar-bg: @brand-primary;
//** Success progress bar color
@progress-bar-success-bg: @brand-success;
//** Warning progress bar color
@progress-bar-warning-bg: @brand-warning;
//** Danger progress bar color
@progress-bar-danger-bg: @brand-danger;
//** Info progress bar color
@progress-bar-info-bg: @brand-info;
//== List group
//
//##
//** Background color on `.list-group-item`
@list-group-bg: #fff;
//** `.list-group-item` border color
@list-group-border: #ddd;
//** List group border radius
@list-group-border-radius: @border-radius-base;
//** Background color of single list items on hover
@list-group-hover-bg: #f5f5f5;
//** Text color of active list items
@list-group-active-color: @component-active-color;
//** Background color of active list items
@list-group-active-bg: @component-active-bg;
//** Border color of active list elements
@list-group-active-border: @list-group-active-bg;
//** Text color for content within active list items
@list-group-active-text-color: lighten(@list-group-active-bg, 40%);
//** Text color of disabled list items
@list-group-disabled-color: @gray-light;
//** Background color of disabled list items
@list-group-disabled-bg: @gray-lighter;
//** Text color for content within disabled list items
@list-group-disabled-text-color: @list-group-disabled-color;
@list-group-link-color: #555;
@list-group-link-hover-color: @list-group-link-color;
@list-group-link-heading-color: #333;
//== Panels
//
//##
@panel-bg: #fff;
@panel-body-padding: 15px;
@panel-heading-padding: 10px 15px;
@panel-footer-padding: @panel-heading-padding;
@panel-border-radius: @border-radius-base;
//** Border color for elements within panels
@panel-inner-border: #ddd;
@panel-footer-bg: #f5f5f5;
@panel-default-text: @gray-dark;
@panel-default-border: #ddd;
@panel-default-heading-bg: #f5f5f5;
@panel-primary-text: #fff;
@panel-primary-border: @brand-primary;
@panel-primary-heading-bg: @brand-primary;
@panel-success-text: @state-success-text;
@panel-success-border: @state-success-border;
@panel-success-heading-bg: @state-success-bg;
@panel-info-text: @state-info-text;
@panel-info-border: @state-info-border;
@panel-info-heading-bg: @state-info-bg;
@panel-warning-text: @state-warning-text;
@panel-warning-border: @state-warning-border;
@panel-warning-heading-bg: @state-warning-bg;
@panel-danger-text: @state-danger-text;
@panel-danger-border: @state-danger-border;
@panel-danger-heading-bg: @state-danger-bg;
//== Thumbnails
//
//##
//** Padding around the thumbnail image
@thumbnail-padding: 4px;
//** Thumbnail background color
@thumbnail-bg: @body-bg;
//** Thumbnail border color
@thumbnail-border: #ddd;
//** Thumbnail border radius
@thumbnail-border-radius: @border-radius-base;
//** Custom text color for thumbnail captions
@thumbnail-caption-color: @text-color;
//** Padding around the thumbnail caption
@thumbnail-caption-padding: 9px;
//== Wells
//
//##
@well-bg: #f5f5f5;
@well-border: darken(@well-bg, 7%);
//== Badges
//
//##
@badge-color: #fff;
//** Linked badge text color on hover
@badge-link-hover-color: #fff;
@badge-bg: @gray-light;
//** Badge text color in active nav link
@badge-active-color: @link-color;
//** Badge background color in active nav link
@badge-active-bg: #fff;
@badge-font-weight: bold;
@badge-line-height: 1;
@badge-border-radius: 10px;
//== Breadcrumbs
//
//##
@breadcrumb-padding-vertical: 8px;
@breadcrumb-padding-horizontal: 15px;
//** Breadcrumb background color
@breadcrumb-bg: #f5f5f5;
//** Breadcrumb text color
@breadcrumb-color: #ccc;
//** Text color of current page in the breadcrumb
@breadcrumb-active-color: @gray-light;
//** Textual separator for between breadcrumb elements
@breadcrumb-separator: "/";
//== Carousel
//
//##
@carousel-text-shadow: 0 1px 2px rgba(0,0,0,.6);
@carousel-control-color: #fff;
@carousel-control-width: 15%;
@carousel-control-opacity: .5;
@carousel-control-font-size: 20px;
@carousel-indicator-active-bg: #fff;
@carousel-indicator-border-color: #fff;
@carousel-caption-color: #fff;
//== Close
//
//##
@close-font-weight: bold;
@close-color: #000;
@close-text-shadow: 0 1px 0 #fff;
//== Code
//
//##
@code-color: #c7254e;
@code-bg: #f9f2f4;
@kbd-color: #fff;
@kbd-bg: #333;
@pre-bg: #f5f5f5;
@pre-color: @gray-dark;
@pre-border-color: #ccc;
@pre-scrollable-max-height: 340px;
//== Type
//
//##
//** Horizontal offset for forms and lists.
@component-offset-horizontal: 180px;
//** Text muted color
@text-muted: @gray-light;
//** Abbreviations and acronyms border color
@abbr-border-color: @gray-light;
//** Headings small color
@headings-small-color: @gray-light;
//** Blockquote small color
@blockquote-small-color: @gray-light;
//** Blockquote font size
@blockquote-font-size: (@font-size-base * 1.25);
//** Blockquote border color
@blockquote-border-color: @gray-lighter;
//** Page header border color
@page-header-border-color: @gray-lighter;
//** Width of horizontal description list titles
@dl-horizontal-offset: @component-offset-horizontal;
//** Horizontal line color.
@hr-border: @gray-lighter;
================================================
FILE: resources/assets/less/bootstrap/wells.less
================================================
//
// Wells
// --------------------------------------------------
// Base class
.well {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: @well-bg;
border: 1px solid @well-border;
border-radius: @border-radius-base;
.box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
blockquote {
border-color: #ddd;
border-color: rgba(0,0,0,.15);
}
}
// Sizes
.well-lg {
padding: 24px;
border-radius: @border-radius-large;
}
.well-sm {
padding: 9px;
border-radius: @border-radius-small;
}
================================================
FILE: resources/assets/less/webloyer/bootstrap.less
================================================
@import "code.less";
@import "forms.less";
@import "list-group.less";
@import "helpers.less";
================================================
FILE: resources/assets/less/webloyer/code.less
================================================
.ansi_box {
background-color: black;
overflow: auto;
padding: 10px 15px;
font-family: monospace;
}
================================================
FILE: resources/assets/less/webloyer/forms.less
================================================
.form-group.required .control-label:after {
content: "*";
color: red;
}
================================================
FILE: resources/assets/less/webloyer/helpers.less
================================================
.margin-bottom-xs {
margin-bottom: 3px !important;
}
.margin-bottom-sm {
margin-bottom: 6px !important;
}
.margin-bottom-md {
margin-bottom: 15px !important;
}
.margin-bottom-lg {
margin-bottom: 30px !important;
}
.green {
color: #5cb85c;
}
.red {
color: #d9534f;
}
.gray {
color: gray;
}
================================================
FILE: resources/assets/less/webloyer/list-group.less
================================================
.list-group-item.selected {
font-weight: bold;
}
.list-group-item.selected:before {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 2px;
content: "";
background-color: #d26911;
}
================================================
FILE: resources/lang/en/pagination.php
================================================
'« Previous',
'next' => 'Next »',
];
================================================
FILE: resources/lang/en/passwords.php
================================================
"Passwords must be at least six characters and match the confirmation.",
"user" => "We can't find a user with that e-mail address.",
"token" => "This password reset token is invalid.",
"sent" => "We have e-mailed your password reset link!",
"reset" => "Your password has been reset!",
];
================================================
FILE: resources/lang/en/validation.php
================================================
"The :attribute must be accepted.",
"active_url" => "The :attribute is not a valid URL.",
"after" => "The :attribute must be a date after :date.",
"alpha" => "The :attribute may only contain letters.",
"alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.",
"alpha_num" => "The :attribute may only contain letters and numbers.",
"array" => "The :attribute must be an array.",
"before" => "The :attribute must be a date before :date.",
"between" => [
"numeric" => "The :attribute must be between :min and :max.",
"file" => "The :attribute must be between :min and :max kilobytes.",
"string" => "The :attribute must be between :min and :max characters.",
"array" => "The :attribute must have between :min and :max items.",
],
"boolean" => "The :attribute field must be true or false.",
"confirmed" => "The :attribute confirmation does not match.",
"date" => "The :attribute is not a valid date.",
"date_format" => "The :attribute does not match the format :format.",
"different" => "The :attribute and :other must be different.",
"digits" => "The :attribute must be :digits digits.",
"digits_between" => "The :attribute must be between :min and :max digits.",
"email" => "The :attribute must be a valid email address.",
"filled" => "The :attribute field is required.",
"exists" => "The selected :attribute is invalid.",
"image" => "The :attribute must be an image.",
"in" => "The selected :attribute is invalid.",
"integer" => "The :attribute must be an integer.",
"ip" => "The :attribute must be a valid IP address.",
"max" => [
"numeric" => "The :attribute may not be greater than :max.",
"file" => "The :attribute may not be greater than :max kilobytes.",
"string" => "The :attribute may not be greater than :max characters.",
"array" => "The :attribute may not have more than :max items.",
],
"mimes" => "The :attribute must be a file of type: :values.",
"min" => [
"numeric" => "The :attribute must be at least :min.",
"file" => "The :attribute must be at least :min kilobytes.",
"string" => "The :attribute must be at least :min characters.",
"array" => "The :attribute must have at least :min items.",
],
"not_in" => "The selected :attribute is invalid.",
"numeric" => "The :attribute must be a number.",
"regex" => "The :attribute format is invalid.",
"required" => "The :attribute field is required.",
"required_if" => "The :attribute field is required when :other is :value.",
"required_with" => "The :attribute field is required when :values is present.",
"required_with_all" => "The :attribute field is required when :values is present.",
"required_without" => "The :attribute field is required when :values is not present.",
"required_without_all" => "The :attribute field is required when none of :values are present.",
"same" => "The :attribute and :other must match.",
"size" => [
"numeric" => "The :attribute must be :size.",
"file" => "The :attribute must be :size kilobytes.",
"string" => "The :attribute must be :size characters.",
"array" => "The :attribute must contain :size items.",
],
"unique" => "The :attribute has already been taken.",
"url" => "The :attribute format is invalid.",
"timezone" => "The :attribute must be a valid zone.",
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/
'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
],
],
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
'attributes' => [],
];
================================================
FILE: resources/lang/en/webloyer.php
================================================
'Please enter your Webloyer URL ("http://webloyer.local" for example)',
'enter_admin_name' => 'Please enter admin name',
'enter_admin_email' => 'Please enter admin email',
'enter_admin_password' => 'Please enter admin password',
'enter_db_system' => 'Please enter your DB system',
'enter_db_host' => 'Please enter your DB host',
'enter_db_name' => 'Please enter your DB name',
'enter_db_name_sqlite' => 'Please enter your DB file',
'enter_db_username' => 'Please enter your DB username',
'enter_db_password' => 'Please enter your DB password',
];
================================================
FILE: resources/views/app.blade.php
================================================
Webloyer
{!! Breadcrumbs::renderIfExists() !!}
@yield('content')
================================================
FILE: resources/views/auth/login.blade.php
================================================
@extends('app')
@section('content')
Login
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
@endsection
================================================
FILE: resources/views/auth/password.blade.php
================================================
@extends('app')
@section('content')
Reset Password
@if (session('status'))
{{ session('status') }}
@endif
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
@endsection
================================================
FILE: resources/views/auth/register.blade.php
================================================
@extends('app')
@section('content')
Register
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
@endsection
================================================
FILE: resources/views/auth/reset.blade.php
================================================
@extends('app')
@section('content')
Reset Password
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
@endsection
================================================
FILE: resources/views/deployments/index.blade.php
================================================
@extends('app')
@section('content')
@if (Session::has('status'))
{!! Session::get('status') !!}
@endif
{!! Form::open(['route' => ['projects.deployments.store', $project], 'method' => 'post', 'style' => 'display:inline']) !!}
{!! Form::hidden('task', 'deploy') !!}
{!! Form::submit('Deploy', ['class' => 'btn btn-primary btn-lg']) !!}
{!! Form::close() !!}
{!! Form::open(['route' => ['projects.deployments.store', $project], 'method' => 'post', 'style' => 'display:inline']) !!}
{!! Form::hidden('task', 'rollback') !!}
{!! Form::submit('Rollback', ['class' => 'btn btn-danger btn-lg']) !!}
{!! Form::close() !!}
|
# |
Task |
Started At |
Finished At |
Executed By |
|
@foreach ($deployments as $deployment)
| {!! $deployment->status() !!} |
{{ $deployment->number }} |
{{ $deployment->task }} |
{{ $deployment->created_at }} |
{{ $deployment->updated_at }} |
{{ is_null($deployment->user) ? '' : $deployment->user->email }} |
{!! link_to_route('projects.deployments.show', 'Show', [$project, $deployment->number], ['class' => 'btn btn-default']) !!}
|
@endforeach
{!! $deployments->render() !!}
@stop
================================================
FILE: resources/views/deployments/show.blade.php
================================================
@extends('app')
@section('content')
| # |
{{ $deployment->number }} |
| Task |
{{ $deployment->task }} |
| Status |
{{ $deployment->statusText() }} |
| Message |
{!! $deployment->message() !!}
|
| Started At |
{{ $deployment->created_at }} |
| Finished At |
{{ $deployment->updated_at }} |
| Executed By |
{{ is_null($deployment->user) ? '' : $deployment->user->email }} |
{!! link_to_route('projects.deployments.index', 'Back', [$deployment->project_id], ['class' => 'btn btn-danger']) !!}
@stop
================================================
FILE: resources/views/emails/notification.blade.php
================================================
Deployment of {{ $project->name }} #{{ $deployment->number }} finished
Task: {{ $deployment->task }}
Status: {{ $deployment->statusText() }}
Started At: {{ $deployment->created_at }}
Finished At: {{ $deployment->updated_at }}
Executed By: {{ is_null($deployment->user) ? '' : $deployment->user->email }}
Deployment URL: {{ route('projects.deployments.show', [$project->id, $deployment->number]) }}
Log:
{!! $deployment->messageText() !!}
================================================
FILE: resources/views/emails/password.blade.php
================================================
Click here to reset your password: {{ url('password/reset/'.$token) }}
================================================
FILE: resources/views/errors/503.blade.php
================================================
================================================
FILE: resources/views/home.blade.php
================================================
@extends('app')
@section('content')
@endsection
================================================
FILE: resources/views/projects/create.blade.php
================================================
@extends('app')
@section('content')
Create Project
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => 'projects.store', 'method' => 'post', 'role' => 'form','class' => 'form-horizontal']) !!}
Overriding Server Definition
E-Mail Notification
Discard Old Deployments
GitHub Webhook
{!! Form::hidden('recipe_id_order', null, ['id' => 'recipe_id_order']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/projects/edit.blade.php
================================================
@extends('app')
@section('content')
Edit Project
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['projects.update', $project->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
Overriding Server Definition
E-Mail Notification
Discard Old Deployments
GitHub Webhook
{!! Form::hidden('recipe_id_order', implode(',', $projectRecipe), ['id' => 'recipe_id_order']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/projects/index.blade.php
================================================
@extends('app')
@section('content')
@if (Auth::user()->can('create.project'))
{!! link_to_route('projects.create', 'Create', [], ['class' => 'btn btn-primary btn-lg']) !!}
@endif
|
Name |
Last Deployment |
Created At |
Updated At |
|
@foreach ($projects as $project)
|
@if (!empty($project->getLastDeployment()))
{!! $project->getLastDeployment()->getPresenter()->status() !!}
@endif
|
{{ $project->name }} |
@if (!empty($project->getLastDeployment()))
{{ $project->getLastDeployment()->updated_at }}
({!! link_to_route('projects.deployments.show', "#{$project->getLastDeployment()->number}", [$project->id, $project->getLastDeployment()->number]) !!})
@endif
|
{{ $project->created_at }} |
{{ $project->updated_at }} |
{!! link_to_route('projects.deployments.index', 'Deployments', [$project->id], ['class' => 'btn btn-default']) !!}
{!! link_to_route('projects.show', 'Show', [$project->id], ['class' => 'btn btn-default']) !!}
@if (Auth::user()->can('edit.project'))
{!! link_to_route('projects.edit', 'Edit', [$project->id], ['class' => 'btn btn-default']) !!}
@endif
@if (Auth::user()->can('delete.project'))
{!! Form::open(['route' => ['projects.destroy', $project->id], 'method' => 'delete', 'style' => 'display:inline']) !!}
{!! Form::submit('Destroy', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
@endif
|
@endforeach
{!! $projects->render() !!}
@stop
================================================
FILE: resources/views/projects/show.blade.php
================================================
@extends('app')
@section('content')
| Project Name |
{{ $project->name }} |
@foreach ($projectRecipe as $i => $recipe)
@if ($i === 0)
| Recipe |
@endif
{{ $recipe['name'] }} |
@endforeach
| Server |
{{ $projectServer->name }} |
| Repository URL |
{{ $project->repository }} |
| Stage |
{{ $project->stage }} |
| Deploy Path |
{{ $project->attributes->getDeployPath() }} |
| E-Mail Notification Recipient |
{{ $project->email_notification_recipient }} |
| Days To Keep Deployments |
{{ $project->days_to_keep_deployments }} |
| Keep Last Deployment |
{{ $project->keep_last_deployment }} |
| Max # Of Deployments To Keep |
{{ $project->max_number_of_deployments_to_keep }} |
| GitHub Webhook Secret |
{{ $project->github_webhook_secret }} |
| GitHub Webhook Execute By |
{{ is_null($project->getGithubWebhookUser()) ? '' : $project->getGithubWebhookUser()->email }} |
{!! link_to_route('projects.index', 'Back', [], ['class' => 'btn btn-danger']) !!}
@if (Auth::user()->can('update.project'))
{!! link_to_route('projects.edit', 'Edit', [$project->id], ['class' => 'btn btn-primary']) !!}
@endif
@stop
================================================
FILE: resources/views/recipes/create.blade.php
================================================
@extends('app')
@section('content')
Create Recipe
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => 'recipes.store', 'method' => 'post', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/recipes/edit.blade.php
================================================
@extends('app')
@section('content')
Edit Recipe
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['recipes.update', $recipe->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/recipes/index.blade.php
================================================
@extends('app')
@section('content')
@if (Auth::user()->can('create.recipe'))
{!! link_to_route('recipes.create', 'Create', [], ['class' => 'btn btn-primary btn-lg']) !!}
@endif
Name |
Users |
Created At |
Updated At |
|
@foreach ($recipes as $recipe)
| {{ $recipe->name }} |
{{ number_format(count($recipe->getProjects())) }} |
{{ $recipe->created_at }} |
{{ $recipe->updated_at }} |
{!! link_to_route('recipes.show', 'Show', [$recipe->id], ['class' => 'btn btn-default']) !!}
@if (Auth::user()->can('update.recipe'))
{!! link_to_route('recipes.edit', 'Edit', [$recipe->id], ['class' => 'btn btn-default']) !!}
@endif
@if (Auth::user()->can('delete.recipe'))
{!! Form::open(['route' => ['recipes.destroy', $recipe->id], 'method' => 'delete', 'style' => 'display:inline']) !!}
{!! Form::submit('Destroy', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
@endif
|
@endforeach
{!! $recipes->render() !!}
@stop
================================================
FILE: resources/views/recipes/show.blade.php
================================================
@extends('app')
@section('content')
| Name |
{{ $recipe->name }} |
| Description |
{{ $recipe->description }} |
| Body |
{{ $recipe->body }}
|
@if (count($recipeProject) === 0)
| Used By |
|
@else
@foreach ($recipeProject as $i => $project)
@if ($i === 0)
| Used By |
@endif
{!! link_to_route('projects.show', $project['name'], $project['id']) !!} |
@endforeach
@endif
{!! link_to_route('recipes.index', 'Back', [], ['class' => 'btn btn-danger']) !!}
@if (Auth::user()->can('update.recipe'))
{!! link_to_route('recipes.edit', 'Edit', [$recipe->id], ['class' => 'btn btn-primary']) !!}
@endif
@stop
================================================
FILE: resources/views/servers/create.blade.php
================================================
@extends('app')
@section('content')
Create Server
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => 'servers.store', 'method' => 'post', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/servers/edit.blade.php
================================================
@extends('app')
@section('content')
Edit Server
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['servers.update', $server->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/servers/index.blade.php
================================================
@extends('app')
@section('content')
@if (Auth::user()->can('create.server'))
{!! link_to_route('servers.create', 'Create', [], ['class' => 'btn btn-primary btn-lg']) !!}
@endif
Name |
Created At |
Updated At |
|
@foreach ($servers as $server)
| {{ $server->name }} |
{{ $server->created_at }} |
{{ $server->updated_at }} |
{!! link_to_route('servers.show', 'Show', [$server->id], ['class' => 'btn btn-default']) !!}
@if (Auth::user()->can('update.server'))
{!! link_to_route('servers.edit', 'Edit', [$server->id], ['class' => 'btn btn-default']) !!}
@endif
@if (Auth::user()->can('delete.server'))
{!! Form::open(['route' => ['servers.destroy', $server->id], 'method' => 'delete', 'style' => 'display:inline']) !!}
{!! Form::submit('Destroy', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
@endif
|
@endforeach
{!! $servers->render() !!}
@stop
================================================
FILE: resources/views/servers/show.blade.php
================================================
@extends('app')
@section('content')
| Name |
{{ $server->name }} |
| Description |
{{ $server->description }} |
| Body |
{{ $server->body }}
|
{!! link_to_route('servers.index', 'Back', [], ['class' => 'btn btn-danger']) !!}
@if (Auth::user()->can('update.server'))
{!! link_to_route('servers.edit', 'Edit', [$server->id], ['class' => 'btn btn-primary']) !!}
@endif
@stop
================================================
FILE: resources/views/settings/email.blade.php
================================================
@extends('app')
@section('content')
{!! link_to_route('settings.email', 'E-Mail Settings', [], ['class' => 'list-group-item selected']) !!}
E-Mail Settings
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['settings.email'], 'method' => 'post', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/users/change_password.blade.php
================================================
@extends('app')
@section('content')
{!! link_to_route('users.edit', 'Edit User', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.password.change', 'Change Password', [$user->id], ['class' => 'list-group-item selected']) !!}
{!! link_to_route('users.role.edit', 'Edit Role', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.api_token.edit', 'Edit API Token', [$user->id], ['class' => 'list-group-item']) !!}
Change Password
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['users.password.update', $user->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/users/create.blade.php
================================================
@extends('app')
@section('content')
Create User
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => 'users.store', 'method' => 'post', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/users/edit.blade.php
================================================
@extends('app')
@section('content')
{!! link_to_route('users.edit', 'Edit User', [$user->id], ['class' => 'list-group-item selected']) !!}
{!! link_to_route('users.password.change', 'Change Password', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.role.edit', 'Edit Role', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.api_token.edit', 'Edit API Token', [$user->id], ['class' => 'list-group-item']) !!}
Edit User
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['users.update', $user->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/users/edit_api_token.blade.php
================================================
@extends('app')
@section('content')
{!! link_to_route('users.edit', 'Edit User', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.password.change', 'Change Password', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.role.edit', 'Edit Role', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.api_token.edit', 'Edit API Token', [$user->id], ['class' => 'list-group-item selected']) !!}
Edit API Token
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['users.api_token.regenerate', $user->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/users/edit_role.blade.php
================================================
@extends('app')
@section('content')
{!! link_to_route('users.edit', 'Edit User', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.password.change', 'Change Password', [$user->id], ['class' => 'list-group-item']) !!}
{!! link_to_route('users.role.edit', 'Edit Role', [$user->id], ['class' => 'list-group-item selected']) !!}
{!! link_to_route('users.api_token.edit', 'Edit API Token', [$user->id], ['class' => 'list-group-item']) !!}
Edit Role
@if (count($errors) > 0)
Whoops! There were some problems with your input.
@foreach ($errors->all() as $error)
- {{ $error }}
@endforeach
@endif
{!! Form::open(['route' => ['users.role.update', $user->id], 'method' => 'put', 'role' => 'form','class' => 'form-horizontal']) !!}
{!! Form::close() !!}
@stop
================================================
FILE: resources/views/users/index.blade.php
================================================
@extends('app')
@section('content')
{!! link_to_route('users.create', 'Create', [], ['class' => 'btn btn-primary btn-lg']) !!}
Name |
Created At |
Updated At |
|
@foreach ($users as $user)
| {{ $user->name }} |
{{ $user->created_at }} |
{{ $user->updated_at }} |
{!! link_to_route('users.edit', 'Edit', [$user->id], ['class' => 'btn btn-default']) !!}
{!! Form::open(['route' => ['users.destroy', $user->id], 'method' => 'delete', 'style' => 'display:inline']) !!}
{!! Form::submit('Destroy', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
|
@endforeach
{!! $users->render() !!}
@stop
================================================
FILE: resources/views/vendor/.gitkeep
================================================
================================================
FILE: resources/views/welcome.blade.php
================================================
Laravel
Laravel 5
{{ Inspiring::quote() }}
================================================
FILE: server.php
================================================
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' and file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
================================================
FILE: storage/.gitignore
================================================
laravel.log
================================================
FILE: storage/app/.gitignore
================================================
*
!.gitignore
================================================
FILE: storage/framework/.gitignore
================================================
config.php
routes.php
schedule-*
compiled.php
services.json
events.scanned.php
routes.scanned.php
================================================
FILE: storage/framework/cache/.gitignore
================================================
*
!.gitignore
================================================
FILE: storage/framework/sessions/.gitignore
================================================
*
!.gitignore
================================================
FILE: storage/framework/views/.gitignore
================================================
*
!.gitignore
================================================
FILE: storage/logs/.gitignore
================================================
*
!.gitignore
================================================
FILE: tests/Entities/Setting/AppSettingEntityTest.php
================================================
setUrl('http://example.com');
$url = $appSettingEntity->getUrl();
$this->assertEquals('http://example.com', $url);
}
}
================================================
FILE: tests/Entities/Setting/DbSettingEntityTest.php
================================================
setDriver('mysql');
$driver = $dbSettingEntity->getDriver();
$this->assertEquals('mysql', $driver);
}
public function test_Should_SetAndGetHost()
{
$dbSettingEntity = new DbSettingEntity;
$dbSettingEntity->setHost('localhost');
$retHost = $dbSettingEntity->getHost();
$this->assertEquals('localhost', $retHost);
}
public function test_Should_SetAndGetDatabase()
{
$dbSettingEntity = new DbSettingEntity;
$dbSettingEntity->setDatabase('webloyer');
$database = $dbSettingEntity->getDatabase();
$this->assertEquals('webloyer', $database);
}
public function test_Should_SetAndGetUsername()
{
$dbSettingEntity = new DbSettingEntity;
$dbSettingEntity->setUsername('username');
$username = $dbSettingEntity->getUsername();
$this->assertEquals('username', $username);
}
public function test_Should_SetAndGetPassword()
{
$dbSettingEntity = new DbSettingEntity;
$dbSettingEntity->setPassword('password');
$password = $dbSettingEntity->getPassword();
$this->assertEquals('password', $password);
}
}
================================================
FILE: tests/Entities/Setting/MailSettingEntityTest.php
================================================
setDriver('smtp');
$driver = $mailSettingEntity->getDriver();
$this->assertEquals('smtp', $driver);
}
public function test_Should_SetAndGetFrom()
{
$mailSettingEntity = new MailSettingEntity;
$from['address'] = 'from_address@example.com';
$from['name'] = 'from_name';
$mailSettingEntity->setFrom($from);
$retFrom = $mailSettingEntity->getFrom();
$this->assertEquals($from, $retFrom);
}
public function test_Should_SetAndGetSmtpHost()
{
$mailSettingEntity = new MailSettingEntity;
$mailSettingEntity->setSmtpHost('localhost');
$smtpHost = $mailSettingEntity->getSmtpHost();
$this->assertEquals('localhost', $smtpHost);
}
public function test_Should_SetAndGetSmtpPort()
{
$mailSettingEntity = new MailSettingEntity;
$mailSettingEntity->setSmtpPort(587);
$smtpPort = $mailSettingEntity->getSmtpPort();
$this->assertEquals(587, $smtpPort);
}
public function test_Should_SetAndGetSmtpEncryption()
{
$mailSettingEntity = new MailSettingEntity;
$mailSettingEntity->setSmtpEncryption('tls');
$smtpEncryption = $mailSettingEntity->getSmtpEncryption();
$this->assertEquals('tls', $smtpEncryption);
}
public function test_Should_SetAndGetSmtpUsername()
{
$mailSettingEntity = new MailSettingEntity;
$mailSettingEntity->setSmtpUsername('username@example.com');
$smtpUsername = $mailSettingEntity->getSmtpUsername();
$this->assertEquals('username@example.com', $smtpUsername);
}
public function test_Should_SetAndGetSmtpPassword()
{
$mailSettingEntity = new MailSettingEntity;
$mailSettingEntity->setSmtpPassword('password');
$smtpPassword = $mailSettingEntity->getSmtpPassword();
$this->assertEquals('password', $smtpPassword);
}
public function test_Should_SetAndGetSendmailPath()
{
$mailSettingEntity = new MailSettingEntity;
$mailSettingEntity->setSendmailPath('/usr/sbin/sendmail -bs');
$sendmailPath = $mailSettingEntity->getSendmailPath();
$this->assertEquals('/usr/sbin/sendmail -bs', $sendmailPath);
}
}
================================================
FILE: tests/Http/Controllers/DeploymentsControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockDeploymentForm = $this->mock('App\Services\Form\Deployment\DeploymentForm');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockDeploymentModel = $this->mockPartial('App\Models\Deployment');
}
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested()
{
$deployments = Factory::buildList('App\Models\Deployment', [
['id' => 1, 'project_id' => 1, 'number' => 1, 'task' => 'deploy', 'user_id' => 1, 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon, 'user' => new App\Models\User],
['id' => 2, 'project_id' => 1, 'number' => 2, 'task' => 'deploy', 'user_id' => 1, 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon, 'user' => new App\Models\User],
['id' => 3, 'project_id' => 1, 'number' => 3, 'task' => 'deploy', 'user_id' => 1, 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon, 'user' => new App\Models\User],
]);
$perPage = 10;
$project = $this->mockProjectModel
->shouldReceive('getDeploymentsByPage')
->once()
->andReturn(new Illuminate\Pagination\Paginator($deployments, $perPage))
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->get('projects/1/deployments');
$this->assertResponseOk();
$this->assertViewHas('deployments');
$this->assertViewHas('project');
}
public function test_Should_RedirectToIndexPage_When_StoreProcessSucceeds()
{
$project = $this->mockProjectModel
->shouldReceive('getLastDeployment')
->once()
->andReturn($this->mockDeploymentModel)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(true);
$params = [
'project_id' => 1,
'user_id' => 1,
];
$this->post('projects/1/deployments', $params);
$this->assertRedirectedToRoute('projects.deployments.index', [$project]);
}
public function test_Should_RedirectToIndexPage_When_StoreProcessFails()
{
$project = Factory::build('App\Models\Project', [
'id' => 1,
'name' => 'Project 1',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockDeploymentForm
->shouldReceive('errors')
->once()
->andReturn([]);
$params = [
'project_id' => 1,
'user_id' => 1,
];
$this->post('projects/1/deployments', $params);
$this->assertRedirectedToRoute('projects.deployments.index', [$project]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayShowPage_When_ShowPageIsRequestedAndResourceIsFound()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$project = $this->mockProjectModel
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn($deployment)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->get('projects/1/deployments/1');
$this->assertResponseOk();
$this->assertViewHas('deployment');
}
public function test_Should_DisplayNotFoundPage_When_ShowPageIsRequestedAndResourceIsNotFound()
{
$project = $this->mockProjectModel
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn(null)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->get('projects/1/deployments/1');
$this->assertResponseStatus(404);
}
}
================================================
FILE: tests/Http/Controllers/ProjectsControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockProjectForm = $this->mock('App\Services\Form\Project\ProjectForm');
$this->mockRecipeRepository = $this->mock('App\Repositories\Recipe\RecipeInterface');
$this->mockServerRepository = $this->mock('App\Repositories\Server\ServerInterface');
$this->mockUserRepository = $this->mock('App\Repositories\User\UserInterface');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockProjectAttributeEntity = $this->mock('App\Entities\ProjectAttribute\ProjectAttributeEntity');
}
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested()
{
$project = $this->mockProjectModel
->shouldReceive('getLastDeployment')
->times(2)
->andReturn([])
->mock();
$projects = [
$project,
];
$perPage = 10;
$this->mockProjectRepository
->shouldReceive('byPage')
->once()
->andReturn(new Illuminate\Pagination\Paginator($projects, $perPage));
$this->get('projects');
$this->assertResponseOk();
$this->assertViewHas('projects');
}
public function test_Should_DisplayCreatePage_When_CreatePageIsRequested()
{
$this->mockRecipeRepository
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->mockServerRepository
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->mockUserRepository
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->get('projects/create');
$this->assertResponseOk();
}
public function test_Should_RedirectToIndexPage_When_StoreProcessSucceeds()
{
$this->mockProjectForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->post('projects');
$this->assertRedirectedToRoute('projects.index');
}
public function test_Should_RedirectToCreatePage_When_StoreProcessFails()
{
$this->mockProjectForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockProjectForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->post('projects');
$this->assertRedirectedToRoute('projects.create');
$this->assertSessionHasErrors();
}
public function test_Should_DisplayShowPage_When_ShowPageIsRequestedAndResourceIsFound()
{
$this->mockProjectAttributeEntity
->shouldReceive('getDeployPath')
->once();
$project = $this->mockProjectModel;
$project->shouldReceive('getRecipes')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$project->shouldReceive('getGithubWebhookUser')
->twice()
->andReturn(new App\Models\User);
$project->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockProjectAttributeEntity);
$server = Factory::build('App\Models\Server', [
'id' => 1,
'name' => 'Server 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($server);
$this->get('projects/1');
$this->assertResponseOk();
$this->assertViewHas('project');
}
public function test_Should_DisplayNotFoundPage_When_ShowPageIsRequestedAndResourceIsNotFound()
{
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('projects/1');
$this->assertResponseStatus(404);
}
public function test_Should_DisplayEditPage_When_EditPageIsRequestedAndResourceIsFound()
{
$this->mockProjectAttributeEntity
->shouldReceive('getDeployPath')
->once();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection)
->mock();
$project->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockProjectAttributeEntity);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockRecipeRepository
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->mockServerRepository
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->mockUserRepository
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->get('projects/1/edit');
$this->assertResponseOk();
$this->assertViewHas('project');
}
public function test_Should_DisplayNotFoundPage_When_EditPageIsRequestedAndResourceIsNotFound()
{
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('projects/1/edit');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_UpdateProcessSucceeds()
{
$project = Factory::build('App\Models\Project', [
'id' => 1,
'name' => 'Project 1',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockProjectForm
->shouldReceive('update')
->once()
->andReturn(true);
$this->put('projects/1');
$this->assertRedirectedToRoute('projects.index');
}
public function test_Should_RedirectToEditPage_When_UpdateProcessFails()
{
$project = Factory::build('App\Models\Project', [
'id' => 1,
'name' => 'Project 1',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockProjectForm
->shouldReceive('update')
->once()
->andReturn(false);
$this->mockProjectForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->put('projects/1');
$this->assertRedirectedToRoute('projects.edit', [$project]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayNotFoundPage_When_UpdateProcessIsRequestedAndResourceIsNotFound()
{
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->put('projects/1');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_DestroyProcessIsRequestedAndDestroyProcessSucceeds()
{
$project = Factory::build('App\Models\Project', [
'id' => 1,
'name' => 'Project 1',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockProjectRepository
->shouldReceive('delete')
->once();
$this->delete('projects/1');
$this->assertRedirectedToRoute('projects.index');
}
public function test_Should_DisplayNotFoundPage_When_DestroyProcessIsRequestedAndResourceIsNotFound()
{
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->delete('projects/1');
$this->assertResponseStatus(404);
}
}
================================================
FILE: tests/Http/Controllers/RecipesControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockRecipeRepository = $this->mock('App\Repositories\Recipe\RecipeInterface');
$this->mockRecipeForm = $this->mock('App\Services\Form\Recipe\RecipeForm');
$this->mockRecipeModel = $this->mockPartial('App\Models\Recipe');
}
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested()
{
$recipes[] = $this->mockRecipeModel
->shouldReceive('getProjects')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection)
->mock();
$recipes[] = $this->mockRecipeModel
->shouldReceive('getProjects')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection)
->mock();
$perPage = 10;
$this->mockRecipeRepository
->shouldReceive('byPage')
->once()
->andReturn(new Illuminate\Pagination\Paginator($recipes, $perPage));
$this->get('recipes');
$this->assertResponseOk();
$this->assertViewHas('recipes');
}
public function test_Should_DisplayCreatePage_When_CreatePageIsRequested()
{
$this->get('recipes/create');
$this->assertResponseOk();
}
public function test_Should_RedirectToIndexPage_When_StoreProcessSucceeds()
{
$this->mockRecipeForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->post('recipes');
$this->assertRedirectedToRoute('recipes.index');
}
public function test_Should_RedirectToCreatePage_When_StoreProcessFails()
{
$this->mockRecipeForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockRecipeForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->post('recipes');
$this->assertRedirectedToRoute('recipes.create');
$this->assertSessionHasErrors();
}
public function test_Should_DisplayShowPage_When_ShowPageIsRequestedAndResourceIsFound()
{
$recipe = $this->mockRecipeModel
->shouldReceive('getProjects')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection)
->mock();
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn($recipe);
$this->get('recipes/1');
$this->assertResponseOk();
$this->assertViewHas('recipe');
}
public function test_Should_DisplayNotFoundPage_When_ShowPageIsRequestedAndResourceIsNotFound()
{
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('recipes/1');
$this->assertResponseStatus(404);
}
public function test_Should_DisplayEditPage_When_EditPageIsRequestedAndResourceIsFound()
{
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn($recipe);
$this->get('recipes/1/edit');
$this->assertResponseOk();
$this->assertViewHas('recipe');
}
public function test_Should_DisplayNotFoundPage_When_EditPageIsRequestedAndResourceIsNotFound()
{
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('recipes/1/edit');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_UpdateProcessSucceeds()
{
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn($recipe);
$this->mockRecipeForm
->shouldReceive('update')
->once()
->andReturn(true);
$this->put('recipes/1');
$this->assertRedirectedToRoute('recipes.index');
}
public function test_Should_RedirectToEditPage_When_UpdateProcessFails()
{
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn($recipe);
$this->mockRecipeForm
->shouldReceive('update')
->once()
->andReturn(false);
$this->mockRecipeForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->put('recipes/1');
$this->assertRedirectedToRoute('recipes.edit', [$recipe]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayNotFoundPage_When_UpdateProcessIsRequestedAndResourceIsNotFound()
{
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->put('recipes/1');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_DestroyProcessIsRequestedAndDestroyProcessSucceeds()
{
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn($recipe);
$this->mockRecipeRepository
->shouldReceive('delete')
->once();
$this->delete('recipes/1');
$this->assertRedirectedToRoute('recipes.index');
}
public function test_Should_DisplayNotFoundPage_When_DestroyProcessIsRequestedAndResourceIsNotFound()
{
$this->mockRecipeRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->delete('recipes/1');
$this->assertResponseStatus(404);
}
}
================================================
FILE: tests/Http/Controllers/ServersControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockServerRepository = $this->mock('App\Repositories\Server\ServerInterface');
$this->mockServerForm = $this->mock('App\Services\Form\Server\ServerForm');
}
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested()
{
$servers = Factory::buildList('App\Models\Server', [
['id' => 1, 'name' => 'Server 1', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon],
['id' => 2, 'name' => 'Server 2', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon],
['id' => 3, 'name' => 'Server 3', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon],
]);
$perPage = 10;
$this->mockServerRepository
->shouldReceive('byPage')
->once()
->andReturn(new Illuminate\Pagination\Paginator($servers, $perPage));
$this->get('servers');
$this->assertResponseOk();
$this->assertViewHas('servers');
}
public function test_Should_DisplayCreatePage_When_CreatePageIsRequested()
{
$this->get('servers/create');
$this->assertResponseOk();
}
public function test_Should_RedirectToIndexPage_When_StoreProcessSucceeds()
{
$this->mockServerForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->post('servers');
$this->assertRedirectedToRoute('servers.index');
}
public function test_Should_RedirectToCreatePage_When_StoreProcessFails()
{
$this->mockServerForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockServerForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->post('servers');
$this->assertRedirectedToRoute('servers.create');
$this->assertSessionHasErrors();
}
public function test_Should_DisplayShowPage_When_ShowPageIsRequestedAndResourceIsFound()
{
$server = Factory::build('App\Models\Server', [
'id' => 1,
'name' => 'Server 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($server);
$this->get('servers/1');
$this->assertResponseOk();
$this->assertViewHas('server');
}
public function test_Should_DisplayNotFoundPage_When_ShowPageIsRequestedAndResourceIsNotFound()
{
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('servers/1');
$this->assertResponseStatus(404);
}
public function test_Should_DisplayEditPage_When_EditPageIsRequestedAndResourceIsFound()
{
$server = Factory::build('App\Models\Server', [
'id' => 1,
'name' => 'Server 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($server);
$this->get('servers/1/edit');
$this->assertResponseOk();
$this->assertViewHas('server');
}
public function test_Should_DisplayNotFoundPage_When_EditPageIsRequestedAndResourceIsNotFound()
{
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('servers/1/edit');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_UpdateProcessSucceeds()
{
$server = Factory::build('App\Models\Server', [
'id' => 1,
'name' => 'Server 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($server);
$this->mockServerForm
->shouldReceive('update')
->once()
->andReturn(true);
$this->put('servers/1');
$this->assertRedirectedToRoute('servers.index');
}
public function test_Should_RedirectToEditPage_When_UpdateProcessFails()
{
$server = Factory::build('App\Models\Server', [
'id' => 1,
'name' => 'Server 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($server);
$this->mockServerForm
->shouldReceive('update')
->once()
->andReturn(false);
$this->mockServerForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->put('servers/1');
$this->assertRedirectedToRoute('servers.edit', [$server]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayNotFoundPage_When_UpdateProcessIsRequestedAndResourceIsNotFound()
{
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->put('servers/1');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_DestroyProcessIsRequestedAndDestroyProcessSucceeds()
{
$server = Factory::build('App\Models\Server', [
'id' => 1,
'name' => 'Server 1',
'description' => '',
'body' => '',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($server);
$this->mockServerRepository
->shouldReceive('delete')
->once();
$this->delete('servers/1');
$this->assertRedirectedToRoute('servers.index');
}
public function test_Should_DisplayNotFoundPage_When_DestroyProcessIsRequestedAndResourceIsNotFound()
{
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->delete('servers/1');
$this->assertResponseStatus(404);
}
}
================================================
FILE: tests/Http/Controllers/SettingsControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockSettingRepository = $this->mock('App\Repositories\Setting\SettingInterface');
$this->mockMailSettingForm = $this->mock('App\Services\Form\Setting\MailSettingForm');
$this->mockSettingModel = $this->mockPartial('App\Models\Setting');
$this->mockMailSettingEntity = $this->mock('App\Entities\Setting\MailSettingEntity');
}
public function test_Should_DisplayEmailSettingPage()
{
$this->mockMailSettingEntity
->shouldReceive('getDriver')
->once()
->shouldReceive('getFrom')
->twice()
->shouldReceive('getSmtpHost')
->once()
->shouldReceive('getSmtpPort')
->once()
->shouldReceive('getSmtpEncryption')
->once()
->shouldReceive('getSmtpUsername')
->once()
->shouldReceive('getSmtpPassword')
->once()
->shouldReceive('getSendmailPath')
->once();
$this->mockSettingModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockMailSettingEntity);
$this->mockSettingRepository
->shouldReceive('byType')
->once()
->andReturn($this->mockSettingModel);
$this->get('settings/email');
$this->assertResponseOk();
$this->assertViewHas('settings');
}
public function test_Should_RedirectToEmailSettingPage_When_EmailSettingProcessIsRequestedAndEmailSettingProcessSucceeds()
{
$this->mockMailSettingForm
->shouldReceive('update')
->once()
->andReturn(true);
$this->post('settings/email');
$this->assertRedirectedToRoute('settings.email');
}
public function test_Should_RedirectToEmailSettingPage_When_EmailSettingProcessIsRequestedAndEmailSettingProcessFails()
{
$this->mockMailSettingForm
->shouldReceive('update')
->once()
->andReturn(false);
$this->mockMailSettingForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->post('settings/email');
$this->assertRedirectedToRoute('settings.email');
}
}
================================================
FILE: tests/Http/Controllers/UsersControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockUserRepository = $this->mock('App\Repositories\User\UserInterface');
$this->mockRoleRepsitory = $this->mock('App\Repositories\Role\RoleInterface');
$this->mockUserForm = $this->mock('App\Services\Form\User\UserForm');
}
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested()
{
$users = Factory::buildList('App\Models\User', [
['id' => 1, 'name' => 'User 1', 'email' => 'user1@example.com', 'password' => '12345678', 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon],
['id' => 2, 'name' => 'User 2', 'email' => 'user2@example.com', 'password' => '12345678', 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon],
['id' => 3, 'name' => 'User 3', 'email' => 'user3@example.com', 'password' => '12345678', 'created_at' => new Carbon\Carbon, 'updated_at' => new Carbon\Carbon],
]);
$perPage = 10;
$this->mockUserRepository
->shouldReceive('byPage')
->once()
->andReturn(new Illuminate\Pagination\Paginator($users, $perPage));
$this->get('users');
$this->assertResponseOk();
$this->assertViewHas('users');
}
public function test_Should_DisplayCreatePage_When_CreatePageIsRequested()
{
$this->mockRoleRepsitory
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->get('users/create');
$this->assertResponseOk();
}
public function test_Should_RedirectToIndexPage_When_StoreProcessSucceeds()
{
$this->mockUserForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->post('users');
$this->assertRedirectedToRoute('users.index');
}
public function test_Should_RedirectToCreatePage_When_StoreProcessFails()
{
$this->mockUserForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockUserForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->post('users');
$this->assertRedirectedToRoute('users.create');
$this->assertSessionHasErrors();
}
public function test_Should_RedirectToEditPage_When_ShowPageIsRequestedAndResourceIsFound()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->get('users/1');
$this->assertRedirectedToRoute('users.edit', [$user]);
}
public function test_Should_DisplayNotFoundPage_When_ShowPageIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('users/1');
$this->assertResponseStatus(404);
}
public function test_Should_DisplayEditPage_When_EditPageIsRequestedAndResourceIsFound()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->get('users/1/edit');
$this->assertResponseOk();
$this->assertViewHas('user');
}
public function test_Should_DisplayNotFoundPage_When_EditPageIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('users/1/edit');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_UpdateProcessSucceeds()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserForm
->shouldReceive('update')
->once()
->andReturn(true);
$this->put('users/1');
$this->assertRedirectedToRoute('users.index');
}
public function test_Should_RedirectToEditPage_When_UpdateProcessFails()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserForm
->shouldReceive('update')
->once()
->andReturn(false);
$this->mockUserForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->put('users/1');
$this->assertRedirectedToRoute('users.edit', [$user]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayNotFoundPage_When_UpdateProcessIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->put('users/1');
$this->assertResponseStatus(404);
}
public function test_Should_DisplayPasswordChangePage_When_PasswordChangePageIsRequestedAndResourceIsFound()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->get('users/1/password/change');
$this->assertResponseOk();
$this->assertViewHas('user');
}
public function test_Should_DisplayNotFoundPage_When_PasswordChangePageIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('users/1/password/change');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_PasswordUpdateProcessSucceeds()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserForm
->shouldReceive('updatePassword')
->once()
->andReturn(true);
$this->put('users/1/password');
$this->assertRedirectedToRoute('users.index');
}
public function test_Should_RedirectToPasswordChangePage_When_PasswordUpdateProcessFails()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserForm
->shouldReceive('updatePassword')
->once()
->andReturn(false);
$this->mockUserForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->put('users/1/password');
$this->assertRedirectedToRoute('users.password.change', [$user]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayNotFoundPage_When_PasswordUpdateProcessIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->put('users/1/password');
$this->assertResponseStatus(404);
}
public function test_Should_DisplayEditRolePage_When_EditRolePageIsRequestedAndResourceIsFound()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockRoleRepsitory
->shouldReceive('all')
->once()
->andReturn(new Illuminate\Database\Eloquent\Collection);
$this->get('users/1/role/edit');
$this->assertResponseOk();
$this->assertViewHas('user');
}
public function test_Should_DisplayNotFoundPage_When_EditRolePageIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->get('users/1/role/edit');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_RoleUpdateProcessSucceeds()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserForm
->shouldReceive('updateRole')
->once()
->andReturn(true);
$this->put('users/1/role');
$this->assertRedirectedToRoute('users.index');
}
public function test_Should_RedirectToEditRolePage_When_EditUpdateProcessFails()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserForm
->shouldReceive('updateRole')
->once()
->andReturn(false);
$this->mockUserForm
->shouldReceive('errors')
->once()
->andReturn([]);
$this->put('users/1/role');
$this->assertRedirectedToRoute('users.role.edit', [$user]);
$this->assertSessionHasErrors();
}
public function test_Should_DisplayNotFoundPage_When_RoleUpdateProcessIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->put('users/1/role');
$this->assertResponseStatus(404);
}
public function test_Should_RedirectToIndexPage_When_DestroyProcessIsRequestedAndDestroyProcessSucceeds()
{
$user = Factory::build('App\Models\User', [
'id' => 1,
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn($user);
$this->mockUserRepository
->shouldReceive('delete')
->once();
$this->delete('users/1');
$this->assertRedirectedToRoute('users.index');
}
public function test_Should_DisplayNotFoundPage_When_DestroyProcessIsRequestedAndResourceIsNotFound()
{
$this->mockUserRepository
->shouldReceive('byId')
->once()
->andReturn(null);
$this->delete('users/1');
$this->assertResponseStatus(404);
}
}
================================================
FILE: tests/Http/Controllers/Webhook/Github/V1/DeploymentsControllerTest.php
================================================
app->instance(\App\Http\Middleware\ApplySettings::class, new DummyMiddleware);
\Session::start();
$user = $this->mockPartial('App\Models\User');
$user->shouldReceive('can')
->andReturn(true);
$this->auth($user);
$this->mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockDeploymentForm = $this->mock('App\Services\Form\Deployment\DeploymentForm');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockDeploymentModel = $this->mockPartial('App\Models\Deployment');
}
public function test_Should_ReturnStatusCode200_When_StoreProcessSucceeds()
{
$project = $this->mockProjectModel
->shouldReceive('getLastDeployment')
->once()
->andReturn($this->mockDeploymentModel)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->post('webhook/github/v1/projects/1/deployments');
$this->assertResponseOK();
}
public function test_Should_ReturnStatusCode400_When_StoreProcessFails()
{
$project = Factory::build('App\Models\Project', [
'id' => 1,
'name' => 'Project 1',
'github_webhook_user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
]);
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockDeploymentForm
->shouldReceive('errors')
->once()
->andReturn(new \Illuminate\Support\MessageBag);
$this->post('webhook/github/v1/projects/1/deployments');
$this->assertResponseStatus(400);
}
}
================================================
FILE: tests/Jobs/DeployTest.php
================================================
mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockServerRepository = $this->mock('App\Repositories\Server\ServerInterface');
$this->mockProcessBuilder = $this->mock('Symfony\Component\Process\ProcessBuilder');
$this->mockProcess = $this->mockPartial('Symfony\Component\Process\Process');
$this->mockDeployerFileDirector = $this->mock('App\Services\Deployment\DeployerFileDirector');
$this->mockServerListFileBuilder = $this->mock('App\Services\Deployment\DeployerServerListFileBuilder');
$this->mockRecipeFileBuilder = $this->mock('App\Services\Deployment\DeployerRecipeFileBuilder');
$this->mockDeploymentFileBuilder = $this->mock('App\Services\Deployment\DeployerDeploymentFileBuilder');
$this->mockNotifier = $this->mock('App\Services\Notification\NotifierInterface');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockServerModel = $this->mockPartial('App\Models\Server');
$this->mockSettingRepositroy = $this->mock('App\Repositories\Setting\SettingInterface');
$this->mockMailSettingEntity = $this->mock('App\Entities\Setting\MailSettingEntity');
$this->mockSettingModel = $this->mockPartial('App\Models\Setting');
}
public function test_Should_Work_When_DeployerIsNormalEnd()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->once()
->andReturn(true);
$this->mockProcess
->shouldReceive('getOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Deploy($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
public function test_Should_Work_When_DeployerIsAbnormalEnd()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->once()
->andReturn(false);
$this->mockProcess
->shouldReceive('getErrorOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Deploy($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
public function test_Should_WorkAndSendNotification_When_DeployerIsNormalEndAndEmailNotificationRecipientIsSet()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$updatedDeployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
'stauts' => 0,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn($updatedDeployment)
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$project->email_notification_recipient = 'webloyer@example.com';
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->twice()
->andReturn(true);
$this->mockProcess
->shouldReceive('getOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockNotifier
->shouldReceive('to')
->once()
->andReturn($this->mockNotifier);
$this->mockNotifier
->shouldReceive('notify')
->once();
$this->mockMailSettingEntity
->shouldReceive('getDriver')
->once()
->shouldReceive('getFrom')
->twice()
->shouldReceive('getSmtpHost')
->once()
->shouldReceive('getSmtpPort')
->once()
->shouldReceive('getSmtpEncryption')
->once()
->shouldReceive('getSmtpUsername')
->once()
->shouldReceive('getSmtpPassword')
->once()
->shouldReceive('getSendmailPath')
->once();
$this->mockSettingModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockMailSettingEntity);
$this->mockSettingRepositroy
->shouldReceive('byType')
->once()
->andReturn($this->mockSettingModel);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Deploy($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
public function test_Should_WorkAndSendNotification_When_DeployerIsAbnormalEndAndEmailNotificationRecipientIsSet()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$updatedDeployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
'stauts' => 1,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn($updatedDeployment)
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$project->email_notification_recipient = 'webloyer@example.com';
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->twice()
->andReturn(false);
$this->mockProcess
->shouldReceive('getErrorOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockNotifier
->shouldReceive('to')
->once()
->andReturn($this->mockNotifier);
$this->mockNotifier
->shouldReceive('notify')
->once();
$this->mockMailSettingEntity
->shouldReceive('getDriver')
->once()
->shouldReceive('getFrom')
->twice()
->shouldReceive('getSmtpHost')
->once()
->shouldReceive('getSmtpPort')
->once()
->shouldReceive('getSmtpEncryption')
->once()
->shouldReceive('getSmtpUsername')
->once()
->shouldReceive('getSmtpPassword')
->once()
->shouldReceive('getSendmailPath')
->once();
$this->mockSettingModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockMailSettingEntity);
$this->mockSettingRepositroy
->shouldReceive('byType')
->once()
->andReturn($this->mockSettingModel);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Deploy($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
}
================================================
FILE: tests/Jobs/RollbackTest.php
================================================
mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockServerRepository = $this->mock('App\Repositories\Server\ServerInterface');
$this->mockProcessBuilder = $this->mock('Symfony\Component\Process\ProcessBuilder');
$this->mockProcess = $this->mockPartial('Symfony\Component\Process\Process');
$this->mockDeployerFileDirector = $this->mock('App\Services\Deployment\DeployerFileDirector');
$this->mockServerListFileBuilder = $this->mock('App\Services\Deployment\DeployerServerListFileBuilder');
$this->mockRecipeFileBuilder = $this->mock('App\Services\Deployment\DeployerRecipeFileBuilder');
$this->mockDeploymentFileBuilder = $this->mock('App\Services\Deployment\DeployerDeploymentFileBuilder');
$this->mockNotifier = $this->mock('App\Services\Notification\NotifierInterface');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockServerModel = $this->mockPartial('App\Models\Server');
$this->mockSettingRepositroy = $this->mock('App\Repositories\Setting\SettingInterface');
$this->mockMailSettingEntity = $this->mock('App\Entities\Setting\MailSettingEntity');
$this->mockSettingModel = $this->mockPartial('App\Models\Setting');
}
public function test_Should_Work_When_DeployerIsNormalEnd()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->once()
->andReturn(true);
$this->mockProcess
->shouldReceive('getOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Rollback($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
public function test_Should_Work_When_DeployerIsAbnormalEnd()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->once()
->andReturn(false);
$this->mockProcess
->shouldReceive('getErrorOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Rollback($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
public function test_Should_WorkAndSendNotification_When_DeployerIsNormalEndAndEmailNotificationRecipientIsSet()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$updatedDeployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
'status' => 0,
]);
$recipe = factory::build('app\models\recipe', [
'id' => 1,
'name' => 'recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn($updatedDeployment)
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$project->email_notification_recipient = 'webloyer@example.com';
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->twice()
->andReturn(true);
$this->mockProcess
->shouldReceive('getOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockNotifier
->shouldReceive('to')
->once()
->andReturn($this->mockNotifier);
$this->mockNotifier
->shouldReceive('notify')
->once();
$this->mockMailSettingEntity
->shouldReceive('getDriver')
->once()
->shouldReceive('getFrom')
->twice()
->shouldReceive('getSmtpHost')
->once()
->shouldReceive('getSmtpPort')
->once()
->shouldReceive('getSmtpEncryption')
->once()
->shouldReceive('getSmtpUsername')
->once()
->shouldReceive('getSmtpPassword')
->once()
->shouldReceive('getSendmailPath')
->once();
$this->mockSettingModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockMailSettingEntity);
$this->mockSettingRepositroy
->shouldReceive('byType')
->once()
->andReturn($this->mockSettingModel);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Rollback($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
public function test_Should_WorkAndSendNotification_When_DeployerIsAbnormalEndAndEmailNotificationRecipientIsSet()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
]);
$updatedDeployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon,
'user' => new \App\Models\User,
'stauts' => 1,
]);
$recipe = Factory::build('App\Models\Recipe', [
'id' => 1,
'name' => 'Recipe 1',
'desctiption' => '',
'body' => '',
]);
$project = $this->mockProjectModel
->shouldReceive('updateDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn($updatedDeployment)
->mock();
$project = $this->mockProjectModel
->shouldReceive('getRecipes')
->once()
->andReturn([$recipe])
->mock();
$project->email_notification_recipient = 'webloyer@example.com';
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockServerRepository
->shouldReceive('byId')
->once()
->andReturn($this->mockServerModel);
$mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile')
->shouldReceive('getFullPath')
->once()
->mock();
$this->mockDeployerFileDirector
->shouldReceive('construct')
->andReturn($mockDeployerFile)
->times(3);
$this->mockProcess
->shouldReceive('run')
->once();
$this->mockProcess
->shouldReceive('isSuccessful')
->twice()
->andReturn(false);
$this->mockProcess
->shouldReceive('getErrorOutput')
->once();
$this->mockProcess
->shouldReceive('getExitCode')
->once();
$this->mockProcessBuilder
->shouldReceive('add')
->times(7)
->andReturn($this->mockProcessBuilder);
$this->mockProcessBuilder
->shouldReceive('getProcess')
->once()
->andReturn($this->mockProcess);
$this->mockNotifier
->shouldReceive('to')
->once()
->andReturn($this->mockNotifier);
$this->mockNotifier
->shouldReceive('notify')
->once();
$this->mockMailSettingEntity
->shouldReceive('getDriver')
->once()
->shouldReceive('getFrom')
->twice()
->shouldReceive('getSmtpHost')
->once()
->shouldReceive('getSmtpPort')
->once()
->shouldReceive('getSmtpEncryption')
->once()
->shouldReceive('getSmtpUsername')
->once()
->shouldReceive('getSmtpPassword')
->once()
->shouldReceive('getSendmailPath')
->once();
$this->mockSettingModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockMailSettingEntity);
$this->mockSettingRepositroy
->shouldReceive('byType')
->once()
->andReturn($this->mockSettingModel);
$this->mockServerListFileBuilder
->shouldReceive('setServer')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockServerListFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockServerListFileBuilder);
$this->mockRecipeFileBuilder
->shouldReceive('setRecipe')
->once();
$this->mockDeploymentFileBuilder
->shouldReceive('setProject')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setServerListFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$this->mockDeploymentFileBuilder
->shouldReceive('setRecipeFile')
->once()
->andReturn($this->mockDeploymentFileBuilder);
$job = new Rollback($deployment);
$job->handle(
$this->mockProjectRepository,
$this->mockServerRepository,
$this->mockProcessBuilder,
$this->mockNotifier,
$this->mockSettingRepositroy
);
}
}
================================================
FILE: tests/Models/DeploymentPresenterTest.php
================================================
1,
'project_id' => 1,
'number' => 1,
'status' => 0,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$html = $deploymentPresenter->status();
$this->assertEquals('', $html);
}
public function test_Should_ConvertStatusToHtmlSnippet_When_StatusIsNg()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$html = $deploymentPresenter->status();
$this->assertEquals('', $html);
}
public function test_Should_ConvertStatusToHtmlSnippet_When_StatusIsUnknown()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => null,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$html = $deploymentPresenter->status();
$this->assertEquals('', $html);
}
public function test_Should_ConvertStatusToText_When_StatusIsOK()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => 0,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$text = $deploymentPresenter->statusText();
$this->assertEquals('success', $text);
}
public function test_Should_ConvertStatusToText_When_StatusIsNg()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => 1,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$text = $deploymentPresenter->statusText();
$this->assertEquals('failure', $text);
}
public function test_Should_ConvertStatusToText_When_StatusIsNotDetermined()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => null,
'task' => 'deploy',
'user_id' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$text = $deploymentPresenter->statusText();
$this->assertEquals('running', $text);
}
public function test_Should_ConvertMessageToHtmlSnippet()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => null,
'task' => 'deploy',
'user_id' => 1,
'message' => 'Message',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$html = $deploymentPresenter->message();
$this->assertEquals('Message', $html);
}
public function test_Should_ConvertMessageToText()
{
$deployment = Factory::build('App\Models\Deployment', [
'id' => 1,
'project_id' => 1,
'number' => 1,
'status' => null,
'task' => 'deploy',
'user_id' => 1,
'message' => 'Message',
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
'user' => new App\Models\User,
]);
$converter = new AnsiToHtmlConverter;
$deploymentPresenter = new DeploymentPresenter($deployment, $converter);
$html = $deploymentPresenter->messageText();
$this->assertEquals('Message', $html);
}
}
================================================
FILE: tests/Models/ProjectTest.php
================================================
$arrangedServer->id,
]);
$arrangedDeployments1 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 1,
'created_at' => Carbon::create(2016, 8, 16, 0, 0, 0),
]);
$arrangedDeployments2 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 2,
'created_at' => Carbon::create(2016, 8, 16, 23, 59, 59),
]);
$arrangedDeployments3 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 3,
'created_at' => Carbon::create(2016, 8, 17, 0, 0, 0),
]);
$arrangedDeployments4 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 4,
'created_at' => Carbon::create(2016, 8, 17, 23, 59, 59),
]);
$foundDeployments = $arrangedProject->getDeploymentsWhereCreatedAtBefore(Carbon::create(2016, 8, 17, 0, 0, 0));
$this->assertEquals($arrangedDeployments2, $foundDeployments[0]);
$this->assertEquals($arrangedDeployments1, $foundDeployments[1]);
}
public function test_Should_GetDeploymentsWhereNumberBefore()
{
$arrangedServer = Factory::create('App\Models\Server');
$arrangedProject = Factory::create('App\Models\Project', [
'server_id' => $arrangedServer->id,
]);
$arrangedDeployments1 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 1,
]);
$arrangedDeployments2 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 2,
]);
$arrangedDeployments3 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 3,
]);
$arrangedDeployments4 = Factory::create('App\Models\Deployment', [
'project_id' => $arrangedProject->id,
'number' => 4,
]);
$foundDeployments = $arrangedProject->getDeploymentsWhereNumberBefore(3);
$this->assertEquals($arrangedDeployments2, $foundDeployments[0]);
$this->assertEquals($arrangedDeployments1, $foundDeployments[1]);
}
}
================================================
FILE: tests/Repositories/Project/EloquentProjectTest.php
================================================
'Recipe 1',
'description' => '',
'body' => '',
]);
$arrangedProject = Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
$projectRepository = new EloquentProject(
new App\Models\Project,
new App\Models\MaxDeployment
);
$foundProject = $projectRepository->byId($arrangedProject->id);
$this->assertEquals('Project 1', $foundProject->name);
$this->assertEquals($arrangedProject->server_id, $foundProject->server_id);
$this->assertEquals('staging', $foundProject->stage);
}
public function test_Should_GetProjectsByPage()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
Factory::createList('App\Models\Project', [
['name' => 'Project 1', 'server_id' => $arrangedServer->id, 'stage' => 'staging'],
['name' => 'Project 2', 'server_id' => $arrangedServer->id, 'stage' => 'staging'],
['name' => 'Project 3', 'server_id' => $arrangedServer->id, 'stage' => 'staging'],
['name' => 'Project 4', 'server_id' => $arrangedServer->id, 'stage' => 'staging'],
['name' => 'Project 5', 'server_id' => $arrangedServer->id, 'stage' => 'staging'],
]);
$projectRepository = new EloquentProject(
new App\Models\Project,
new App\Models\MaxDeployment
);
$foundProjects = $projectRepository->byPage();
$this->assertCount(5, $foundProjects->items());
}
public function test_Should_CreateNewProject()
{
$projectRepository = new EloquentProject(
new App\Models\Project,
new App\Models\MaxDeployment
);
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$returnedProject = $projectRepository->create([
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
$project = new App\Models\Project;
$createdProject = $project->find($returnedProject->id);
$this->assertEquals('Project 1', $createdProject->name);
$this->assertEquals($arrangedServer->id, $createdProject->server_id);
$this->assertEquals('staging', $createdProject->stage);
}
public function test_Should_UpdateExistingProject()
{
$arrangedRecipe = Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$arrangedProject = Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
$arrangedProject->recipes()->sync([
$arrangedRecipe->id => [
'recipe_order' => 1,
]
]);
$projectRepository = new EloquentProject(
new App\Models\Project,
new App\Models\MaxDeployment
);
$arrangedServer2 = Factory::create('App\Models\Server', [
'name' => 'Server 2 ',
'description' => '',
'body' => '',
]);
$projectRepository->update([
'id' => $arrangedProject->id,
'name' => 'Project 2',
'server_id' => $arrangedServer2->id,
'stage' => 'production',
]);
$project = new App\Models\Project;
$updatedProject = $project->find($arrangedProject->id);
$this->assertEquals('Project 2', $updatedProject->name);
$this->assertEquals($arrangedRecipe->id, $updatedProject->recipes->first()->id);
$this->assertEquals($arrangedServer2->id, $updatedProject->server_id);
$this->assertEquals('production', $updatedProject->stage);
}
public function test_Should_DeleteExistingProject()
{
$arrangedRecipe = Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$arrangedProject = Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
$arrangedProject->recipes()->sync([
$arrangedRecipe->id => [
'recipe_order' => 1,
]
]);
$projectRepository = new EloquentProject(
new App\Models\Project,
new App\Models\MaxDeployment
);
$projectRepository->delete($arrangedProject->id);
$project = new App\Models\Project;
$deletedProject = $project->find($arrangedProject->id);
$this->assertNull($deletedProject);
$updatedProjectRecipes = $arrangedProject->recipes;
$this->assertEmpty($updatedProjectRecipes);
}
}
================================================
FILE: tests/Repositories/Recipe/EloquentRecipeTest.php
================================================
'Recipe 1',
'description' => '',
'body' => '',
]);
$recipeRepository = new EloquentRecipe(new App\Models\Recipe);
$foundRecipe = $recipeRepository->byId($arrangedRecipe->id);
$this->assertEquals('Recipe 1', $foundRecipe->name);
$this->assertEquals('', $foundRecipe->description);
$this->assertEquals('', $foundRecipe->body);
}
public function test_Should_GetRecipesByPage()
{
Factory::createList('App\Models\Recipe', [
['name' => 'Recipe 1', 'description' => '', 'body' => ''],
['name' => 'Recipe 2', 'description' => '', 'body' => ''],
['name' => 'Recipe 3', 'description' => '', 'body' => ''],
['name' => 'Recipe 4', 'description' => '', 'body' => ''],
['name' => 'Recipe 5', 'description' => '', 'body' => ''],
]);
$recipeRepository = new EloquentRecipe(new App\Models\Recipe);
$foundRecipes = $recipeRepository->byPage();
$this->assertCount(5, $foundRecipes->items());
}
public function test_Should_CreateNewRecipe()
{
$recipeRepository = new EloquentRecipe(new App\Models\Recipe);
$returnedRecipe = $recipeRepository->create([
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$recipe = new App\Models\Recipe;
$createdRecipe = $recipe->find($returnedRecipe->id);
$this->assertEquals('Recipe 1', $createdRecipe->name);
$this->assertEquals('', $createdRecipe->description);
$this->assertEquals('', $createdRecipe->body);
}
public function test_Should_UpdateExistingRecipe()
{
$arrangedRecipe = Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$recipeRepository = new EloquentRecipe(new App\Models\Recipe);
$recipeRepository->update([
'id' => $arrangedRecipe->id,
'name' => 'Recipe 2',
'description' => 'Description',
'body' => 'find($arrangedRecipe->id);
$this->assertEquals('Recipe 2', $updatedRecipe->name);
$this->assertEquals('Description', $updatedRecipe->description);
$this->assertEquals('body);
}
public function test_Should_DeleteExistingRecipe()
{
$arrangedRecipe = Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$recipeRepository = new EloquentRecipe(new App\Models\Recipe);
$recipeRepository->delete($arrangedRecipe->id);
$recipe = new App\Models\Recipe;
$deletedRecipe = $recipe->find($arrangedRecipe->id);
$this->assertNull($deletedRecipe);
}
}
================================================
FILE: tests/Repositories/Role/EloquentRoleTest.php
================================================
'Role 1',
'slug' => 'role_1',
'description' => '',
]);
$serverRepository = new EloquentRole(new Kodeine\Acl\Models\Eloquent\Role);
$foundRole = $serverRepository->byId($arrangedRole->id);
$this->assertEquals('Role 1', $foundRole->name);
$this->assertEquals('role_1', $foundRole->slug);
$this->assertEquals('', $foundRole->description);
}
public function test_Should_GetRolesByPage()
{
Factory::createList('Kodeine\Acl\Models\Eloquent\Role', [
['name' => 'Role 1', 'slug' => 'role_1', 'description' => ''],
['name' => 'Role 2', 'slug' => 'role_2', 'description' => ''],
['name' => 'Role 3', 'slug' => 'role_3', 'description' => ''],
['name' => 'Role 4', 'slug' => 'role_4', 'description' => ''],
['name' => 'Role 5', 'slug' => 'role_5', 'description' => ''],
]);
$serverRepository = new EloquentRole(new Kodeine\Acl\Models\Eloquent\Role);
$foundRoles = $serverRepository->byPage();
$this->assertCount(5, $foundRoles->items());
}
public function test_Should_CreateNewRole()
{
$serverRepository = new EloquentRole(new Kodeine\Acl\Models\Eloquent\Role);
$returnedRole = $serverRepository->create([
'name' => 'Role 1',
'slug' => 'role_1',
'description' => '',
]);
$server = new Kodeine\Acl\Models\Eloquent\Role;
$createdRole = $server->find($returnedRole->id);
$this->assertEquals('Role 1', $createdRole->name);
$this->assertEquals('role_1', $createdRole->slug);
$this->assertEquals('', $createdRole->description);
}
public function test_Should_UpdateExistingRole()
{
$arrangedRole = Factory::create('Kodeine\Acl\Models\Eloquent\Role', [
'name' => 'Role 1',
'slug' => 'role_1',
'description' => '',
]);
$serverRepository = new EloquentRole(new Kodeine\Acl\Models\Eloquent\Role);
$serverRepository->update([
'id' => $arrangedRole->id,
'name' => 'Role 2',
'slug' => 'role_2',
'description' => 'Role 2.',
]);
$server = new Kodeine\Acl\Models\Eloquent\Role;
$updatedRole = $server->find($arrangedRole->id);
$this->assertEquals('Role 2', $updatedRole->name);
$this->assertEquals('role_2', $updatedRole->slug);
$this->assertEquals('Role 2.', $updatedRole->description);
}
public function test_Should_DeleteExistingRole()
{
$arrangedRole = Factory::create('Kodeine\Acl\Models\Eloquent\Role', [
'name' => 'Role 1',
'slug' => 'role_1',
'description' => '',
]);
$serverRepository = new EloquentRole(new Kodeine\Acl\Models\Eloquent\Role);
$serverRepository->delete($arrangedRole->id);
$server = new Kodeine\Acl\Models\Eloquent\Role;
$deletedRole = $server->find($arrangedRole->id);
$this->assertNull($deletedRole);
}
}
================================================
FILE: tests/Repositories/Server/EloquentServerTest.php
================================================
'Server 1',
'description' => '',
'body' => '',
]);
$serverRepository = new EloquentServer(new App\Models\Server);
$foundServer = $serverRepository->byId($arrangedServer->id);
$this->assertEquals('Server 1', $foundServer->name);
$this->assertEquals('', $foundServer->description);
$this->assertEquals('', $foundServer->body);
}
public function test_Should_GetServersByPage()
{
Factory::createList('App\Models\Server', [
['name' => 'Server 1', 'description' => '', 'body' => ''],
['name' => 'Server 2', 'description' => '', 'body' => ''],
['name' => 'Server 3', 'description' => '', 'body' => ''],
['name' => 'Server 4', 'description' => '', 'body' => ''],
['name' => 'Server 5', 'description' => '', 'body' => ''],
]);
$serverRepository = new EloquentServer(new App\Models\Server);
$foundServers = $serverRepository->byPage();
$this->assertCount(5, $foundServers->items());
}
public function test_Should_CreateNewServer()
{
$serverRepository = new EloquentServer(new App\Models\Server);
$returnedServer = $serverRepository->create([
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$server = new App\Models\Server;
$createdServer = $server->find($returnedServer->id);
$this->assertEquals('Server 1', $createdServer->name);
$this->assertEquals('', $createdServer->description);
$this->assertEquals('', $createdServer->body);
}
public function test_Should_UpdateExistingServer()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$serverRepository = new EloquentServer(new App\Models\Server);
$serverRepository->update([
'id' => $arrangedServer->id,
'name' => 'Server 2',
'description' => 'Description',
'body' => 'find($arrangedServer->id);
$this->assertEquals('Server 2', $updatedServer->name);
$this->assertEquals('Description', $updatedServer->description);
$this->assertEquals('body);
}
public function test_Should_DeleteExistingServer()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$serverRepository = new EloquentServer(new App\Models\Server);
$serverRepository->delete($arrangedServer->id);
$server = new App\Models\Server;
$deletedServer = $server->find($arrangedServer->id);
$this->assertNull($deletedServer);
}
}
================================================
FILE: tests/Repositories/Setting/ConfigAppSettingTest.php
================================================
rootDir = vfsStream::setup('rootDir');
}
public function test_Should_GetAllAppSettings()
{
$config = <<at($this->rootDir)->setContent($config);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$configAppSettingRepository = new ConfigAppSetting(
$dotenvReader,
$dotenvWriter
);
$appSettings = $configAppSettingRepository->all();
$this->assertEquals('http://example.com', $appSettings->getUrl());
}
public function test_Should_UpdateExistingAppSettings()
{
vfsStream::newFile('.env')->at($this->rootDir);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$configAppSettingRepository = new ConfigAppSetting(
$dotenvReader,
$dotenvWriter
);
$configAppSettingRepository->update([
'url' => 'http://example.com',
]);
$this->assertEquals('http://example.com', $dotenvReader->getConfig('APP_URL'));
}
}
================================================
FILE: tests/Repositories/Setting/ConfigDbSettingTest.php
================================================
rootDir = vfsStream::setup('rootDir');
}
public function test_Should_GetAllDbSettings()
{
$config = <<at($this->rootDir)->setContent($config);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$configDbSettingRepository = new ConfigDbSetting(
$dotenvReader,
$dotenvWriter
);
$dbSettings = $configDbSettingRepository->all();
$this->assertEquals('mysql', $dbSettings->getDriver());
$this->assertEquals('localhost', $dbSettings->getHost());
$this->assertEquals('database', $dbSettings->getDatabase());
$this->assertEquals('username', $dbSettings->getUsername());
$this->assertEquals('password', $dbSettings->getPassword());
}
public function test_Should_UpdateExistingDbSettings()
{
vfsStream::newFile('.env')->at($this->rootDir);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$configDbSettingRepository = new ConfigDbSetting(
$dotenvReader,
$dotenvWriter
);
$configDbSettingRepository->update([
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'username',
'password' => 'password',
]);
$this->assertEquals('mysql', $dotenvReader->getConfig('DB_DRIVER'));
$this->assertEquals('localhost', $dotenvReader->getConfig('DB_HOST'));
$this->assertEquals('database', $dotenvReader->getConfig('DB_DATABASE'));
$this->assertEquals('username', $dotenvReader->getConfig('DB_USERNAME'));
$this->assertEquals('password', $dotenvReader->getConfig('DB_PASSWORD'));
}
}
================================================
FILE: tests/Repositories/Setting/ConfigMailSettingTest.php
================================================
rootDir = vfsStream::setup('rootDir');
}
public function test_Should_GetAllMailSettings()
{
$config = <<at($this->rootDir)->setContent($config);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$configMailSettingRepository = new ConfigMailSetting(
$dotenvReader,
$dotenvWriter
);
$mailSettings = $configMailSettingRepository->all();
$this->assertEquals('smtp', $mailSettings->getDriver());
$this->assertEquals('from_address@example.com', $mailSettings->getFrom()['address']);
$this->assertEquals('from_name', $mailSettings->getFrom()['name']);
$this->assertEquals('localhost', $mailSettings->getSmtpHost());
$this->assertEquals(587, $mailSettings->getSmtpPort());
$this->assertEquals('tls', $mailSettings->getSmtpEncryption());
$this->assertEquals('username@example.com', $mailSettings->getSmtpUsername());
$this->assertEquals('password', $mailSettings->getSmtpPassword());
$this->assertEquals('/usr/sbin/sendmail -bs', $mailSettings->getSendmailPath());
}
public function test_Should_UpdateExistingMailSettings()
{
vfsStream::newFile('.env')->at($this->rootDir);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$configMailSettingRepository = new ConfigMailSetting(
$dotenvReader,
$dotenvWriter
);
$configMailSettingRepository->update([
'driver' => 'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
]);
$this->assertEquals('smtp', $dotenvReader->getConfig('MAIL_DRIVER'));
$this->assertEquals('from_address@example.com', $dotenvReader->getConfig('MAIL_FROM_ADDRESS'));
$this->assertEquals('from_name', $dotenvReader->getConfig('MAIL_FROM_NAME'));
$this->assertEquals('localhost', $dotenvReader->getConfig('MAIL_HOST'));
$this->assertEquals(587, $dotenvReader->getConfig('MAIL_PORT'));
$this->assertEquals('tls', $dotenvReader->getConfig('MAIL_ENCRYPTION'));
$this->assertEquals('username@example.com', $dotenvReader->getConfig('MAIL_USERNAME'));
$this->assertEquals('password', $dotenvReader->getConfig('MAIL_PASSWORD'));
$this->assertEquals('/usr/sbin/sendmail -bs', $dotenvReader->getConfig('MAIL_SENDMAIL'));
}
}
================================================
FILE: tests/Repositories/User/EloquentUserTest.php
================================================
role = new Role;
}
public function test_Should_GetUserById()
{
$arrangedUser = Factory::create('App\Models\User', [
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'api_token' => '12345678',
]);
$userRepository = new EloquentUser(new App\Models\User);
$foundUser = $userRepository->byId($arrangedUser->id);
$this->assertEquals('User 1', $foundUser->name);
$this->assertEquals('user1@example.com', $foundUser->email);
$this->assertEquals('12345678', $foundUser->password);
$this->assertEquals('12345678', $foundUser->api_token);
}
public function test_Should_GetUsersByPage()
{
Factory::createList('App\Models\User', [
['name' => 'User 1', 'email' => 'user1@example.com', 'password' => '12345678', 'api_token' => '12345678'],
['name' => 'User 2', 'email' => 'user2@example.com', 'password' => '23456789', 'api_token' => '23456789'],
['name' => 'User 3', 'email' => 'user3@example.com', 'password' => '34567890', 'api_token' => '34567890'],
['name' => 'User 4', 'email' => 'user4@example.com', 'password' => '4567890a', 'api_token' => '45678901'],
['name' => 'User 5', 'email' => 'user5@example.com', 'password' => '567890ab', 'api_token' => '56789012'],
]);
$userRepository = new EloquentUser(new App\Models\User);
$foundUsers = $userRepository->byPage();
$this->assertCount(5, $foundUsers->items());
}
public function test_Should_CreateNewUser()
{
$userRepository = new EloquentUser(new App\Models\User);
$returnedUser = $userRepository->create([
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'api_token' => '12345678',
]);
$user = new App\Models\User;
$createdUser = $user->find($returnedUser->id);
$this->assertEquals('User 1', $createdUser->name);
$this->assertEquals('user1@example.com', $createdUser->email);
$this->assertEquals('12345678', $createdUser->password);
$this->assertEquals('12345678', $createdUser->api_token);
}
public function test_Should_UpdateExistingUser()
{
$arrangedUser = Factory::create('App\Models\User', [
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'api_token' => '12345678',
]);
$userRepository = new EloquentUser(new App\Models\User);
$userRepository->update([
'id' => $arrangedUser->id,
'name' => 'User 2',
'email' => 'user2@example.com',
'password' => '23456789',
'api_token' => '23456789',
]);
$user = new App\Models\User;
$updatedUser = $user->find($arrangedUser->id);
$this->assertEquals('User 2', $updatedUser->name);
$this->assertEquals('user2@example.com', $updatedUser->email);
$this->assertEquals('23456789', $updatedUser->password);
$this->assertEquals('23456789', $updatedUser->api_token);
}
public function test_Should_UpdateExistingUser_When_RoleIsSpecified()
{
$role = $this->role->create([
'name' => 'Role 1',
'slug' => 'role1',
]);
$arrangedUser = Factory::create('App\Models\User', [
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'api_token' => '12345678',
]);
$arrangedUser->assignRole('role1');
$userRepository = new EloquentUser(new App\Models\User);
$userRepository->update([
'id' => $arrangedUser->id,
'name' => 'User 2',
'email' => 'user2@example.com',
'password' => '23456789',
'api_token' => '23456789',
]);
$user = new App\Models\User;
$updatedUser = $user->find($arrangedUser->id);
$this->assertEquals('User 2', $updatedUser->name);
$this->assertEquals('user2@example.com', $updatedUser->email);
$this->assertEquals('23456789', $updatedUser->password);
$this->assertEquals('23456789', $updatedUser->api_token);
$this->assertEquals('role1', $updatedUser->getRoles()[$role->id]);
}
public function test_Should_UpdateExistingUser_When_RoleIsEmpty()
{
$role = $this->role->create([
'name' => 'Role 1',
'slug' => 'role1',
]);
$arrangedUser = Factory::create('App\Models\User', [
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'api_token' => '12345678',
]);
$arrangedUser->assignRole('role1');
$userRepository = new EloquentUser(new App\Models\User);
$userRepository->update([
'id' => $arrangedUser->id,
'name' => 'User 2',
'email' => 'user2@example.com',
'password' => '23456789',
'api_token' => '23456789',
]);
$user = new App\Models\User;
$updatedUser = $user->find($arrangedUser->id);
$this->assertEquals('User 2', $updatedUser->name);
$this->assertEquals('user2@example.com', $updatedUser->email);
$this->assertEquals('23456789', $updatedUser->password);
$this->assertEquals('23456789', $updatedUser->api_token);
$this->assertEquals('role1', $updatedUser->getRoles()[$role->id]);
}
public function test_Should_DeleteExistingUser()
{
$arrangedUser = Factory::create('App\Models\User', [
'name' => 'User 1',
'email' => 'user1@example.com',
'password' => '12345678',
'api_token' => '12345678',
]);
$userRepository = new EloquentUser(new App\Models\User);
$userRepository->delete($arrangedUser->id);
$user = new App\Models\User;
$deletedUser = $user->find($arrangedUser->id);
$this->assertNull($deletedUser);
}
}
================================================
FILE: tests/Services/Api/JsonRpcTest.php
================================================
mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockDeploymentForm = $this->mock('App\Services\Form\Deployment\DeploymentForm');
$this->mockAuthGuard = $this->mock('Illuminate\Contracts\Auth\Guard');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
}
public function test_Should_NotThrowWException_When_DeployProcedureSucceeds()
{
try {
$this->mockAuthGuard
->shouldReceive('user')
->andReturn(new App\Models\User);
Auth::shouldReceive('guard')
->andReturn($this->mockAuthGuard);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->mockProjectModel
->shouldReceive('getLastDeployment');
$this->mockProjectRepository
->shouldReceive('byId')
->andReturn($this->mockProjectModel);
$jsonRpc = new JsonRpc(
$this->mockProjectRepository,
$this->mockDeploymentForm
);
$jsonRpc->deploy(1);
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail($e->getMessage());
}
}
/**
* @expectedException InvalidArgumentException
*/
public function test_Should_ThrowWException_When_DeployProcedureFails()
{
$this->mockAuthGuard
->shouldReceive('user')
->andReturn(new App\Models\User);
Auth::shouldReceive('guard')
->andReturn($this->mockAuthGuard);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockDeploymentForm
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$jsonRpc = new JsonRpc(
$this->mockProjectRepository,
$this->mockDeploymentForm
);
$jsonRpc->deploy(1);
}
public function test_Should_NotThrowWException_When_RollbackProcedureSucceeds()
{
try {
$this->mockAuthGuard
->shouldReceive('user')
->andReturn(new App\Models\User);
Auth::shouldReceive('guard')
->andReturn($this->mockAuthGuard);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(true);
$this->mockProjectModel
->shouldReceive('getLastDeployment');
$this->mockProjectRepository
->shouldReceive('byId')
->andReturn($this->mockProjectModel);
$jsonRpc = new JsonRpc(
$this->mockProjectRepository,
$this->mockDeploymentForm
);
$jsonRpc->deploy(1);
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail($e->getMessage());
}
}
/**
* @expectedException InvalidArgumentException
*/
public function test_Should_ThrowWException_When_RollbackProcedureFails()
{
$this->mockAuthGuard
->shouldReceive('user')
->andReturn(new App\Models\User);
Auth::shouldReceive('guard')
->andReturn($this->mockAuthGuard);
$this->mockDeploymentForm
->shouldReceive('save')
->once()
->andReturn(false);
$this->mockDeploymentForm
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$jsonRpc = new JsonRpc(
$this->mockProjectRepository,
$this->mockDeploymentForm
);
$jsonRpc->rollback(1);
}
}
================================================
FILE: tests/Services/Config/DotenvReaderTest.php
================================================
rootDir = vfsStream::setup('rootDir');
}
public function test_Should_GetConfigValue_When_ConfigExistsAndValueIsNotEmpty()
{
$contents = <<at($this->rootDir)->setContent($contents);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$value = $dotenvReader->getConfig('NAME1');
$this->assertEquals('value1', $value);
}
public function test_Should_GetConfigValue_When_ConfigExistsAndValueIsSingleQuoted()
{
$contents = <<at($this->rootDir)->setContent($contents);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$value = $dotenvReader->getConfig('NAME2');
$this->assertEquals("'value2'", $value);
}
public function test_Should_GetConfigValue_When_ConfigExistsAndValueHasWhitespaces()
{
$contents = <<at($this->rootDir)->setContent($contents);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$value = $dotenvReader->getConfig('NAME3');
$this->assertEquals(' v a l u e 3 ', $value);
}
public function test_Should_GetNull_When_ConfigExistsAndValueIsEmpty()
{
$contents = <<at($this->rootDir)->setContent($contents);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$value = $dotenvReader->getConfig('NAME4');
$this->assertNull($value);
}
public function test_Should_GetNull_When_ConfigDoesNotExist()
{
$contents = <<at($this->rootDir)->setContent($contents);
$dotenvReader = new DotenvReader(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$value = $dotenvReader->getConfig('NAME5');
$this->assertNull($value);
}
}
================================================
FILE: tests/Services/Config/DotenvWriterTest.php
================================================
rootDir = vfsStream::setup('rootDir');
}
public function test_Should_UpdateExistingConfig_When_ConfigExists()
{
$contentsBefore = <<at($this->rootDir)->setContent($contentsBefore);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter->setConfig('NAME1', 'value1a');
$this->assertEquals($contentsAfter, $dotenv->getContent());
}
public function test_Should_AddNewConfig_When_ConfigDoesNotExist()
{
$contentsBefore = <<at($this->rootDir)->setContent($contentsBefore);
$dotenvWriter = new DotenvWriter(
new LaravelFilesystem($this->app['files']),
vfsStream::url('rootDir/.env')
);
$dotenvWriter->setConfig('NAME3', 'value3');
$this->assertEquals($contentsAfter, $dotenv->getContent());
}
}
================================================
FILE: tests/Services/Deployment/DeployerDeploymentFileBuilderTest.php
================================================
mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockFilesystem = $this->mock('App\Services\Filesystem\FilesystemInterface');
$this->mockRecipeFile = $this->mock('App\Services\Deployment\DeployerFile');
$this->mockServerListFile = $this->mock('App\Services\Deployment\DeployerFile');
}
public function test_Should_BuildDeployerDeploymentFile()
{
$this->mockFilesystem
->shouldReceive('delete')
->once();
$this->mockFilesystem
->shouldReceive('put')
->once();
$mockRecipeFile = $this->mockRecipeFile
->shouldReceive('getFullPath')
->once()
->mock();
$mockRecipeFiles = [$mockRecipeFile];
$mockServerListFile = $this->mockServerListFile
->shouldReceive('getFullPath')
->once()
->mock();
$deploymentFileBuilder = new DeployerDeploymentFileBuilder(
$this->mockFilesystem,
new DeployerFile
);
$deploymentFileBuilder->setProject($this->mockProjectModel)
->setServerListFile($mockServerListFile)
->setRecipeFile($mockRecipeFiles);
$result = $deploymentFileBuilder
->pathInfo()
->put()
->getResult();
$this->assertStringMatchesFormat('deploy_%x.php', $result->getBaseName());
$this->assertStringMatchesFormat(storage_path("app/deploy_%x.php"), $result->getFullPath());
}
}
================================================
FILE: tests/Services/Deployment/DeployerRecipeFileBuilderTest.php
================================================
mockRecipeModel = $this->mockPartial('App\Models\Recipe');
$this->mockFilesystem = $this->mock('App\Services\Filesystem\FilesystemInterface');
}
public function test_Should_BuildDeployerRecipeFile()
{
$this->mockFilesystem
->shouldReceive('delete')
->once();
$this->mockFilesystem
->shouldReceive('put')
->once();
$recipeFileBuilder = new DeployerRecipeFileBuilder(
$this->mockFilesystem,
new DeployerFile
);
$recipeFileBuilder->setRecipe($this->mockRecipeModel);
$result = $recipeFileBuilder
->pathInfo()
->put()
->getResult();
$this->assertStringMatchesFormat('recipe_%x.php', $result->getBaseName());
$this->assertStringMatchesFormat(storage_path("app/recipe_%x.php"), $result->getFullPath());
}
}
================================================
FILE: tests/Services/Deployment/DeployerServerListFileBuilderTest.php
================================================
mockProjectModel = $this->mockPartial('App\Models\Project');
$this->mockProjectAttributeEntity = $this->mock('App\Entities\ProjectAttribute\ProjectAttributeEntity');
$this->mockServerModel = $this->mockPartial('App\Models\Server');
$this->mockFilesystem = $this->mock('App\Services\Filesystem\FilesystemInterface');
$this->mockYamlParser = $this->mock('Symfony\Component\Yaml\Parser');
$this->mockYamlDumper = $this->mock('Symfony\Component\Yaml\Dumper');
$this->mockDeployerFile = $this->mock('App\Services\Deployment\DeployerFile');
$this->rootDir = vfsStream::setup('rootDir');
}
public function test_Should_BuildDeployerServerListFile()
{
$this->mockProjectModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockProjectAttributeEntity);
$this->mockFilesystem
->shouldReceive('delete')
->once();
$this->mockFilesystem
->shouldReceive('put')
->once();
$this->mockYamlParser
->shouldReceive('parse')
->once()
->andReturn([]);
$this->mockYamlDumper
->shouldReceive('dump')
->once()
->andReturn('');
$serverListFileBuilder = new DeployerServerListFileBuilder(
$this->mockFilesystem,
new DeployerFile,
$this->mockYamlParser,
$this->mockYamlDumper
);
$serverListFileBuilder->setServer($this->mockServerModel)
->setProject($this->mockProjectModel);
$result = $serverListFileBuilder
->pathInfo()
->put()
->getResult();
$this->assertStringMatchesFormat('server_%x.yml', $result->getBaseName());
$this->assertStringMatchesFormat(storage_path("app/server_%x.yml"), $result->getFullPath());
}
public function test_Should_OverrideAttributeInDeployerServerListFile_When_ProjectAttributeIsSpecified()
{
$path = vfsStream::url('rootDir/server.yml');
$this->mockProjectAttributeEntity
->shouldReceive('getDeployPath')
->twice()
->andReturn('/home/www/deploy2');
$this->mockProjectModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockProjectAttributeEntity);
$this->mockDeployerFile
->shouldReceive('setBaseName')
->once();
$this->mockDeployerFile
->shouldReceive('setFullPath')
->once();
$this->mockDeployerFile
->shouldReceive('getFullPath')
->andReturn($path);
$serverListFileBuilder = new DeployerServerListFileBuilder(
new LaravelFilesystem($this->app['files']),
$this->mockDeployerFile,
new Parser,
new Dumper
);
$this->mockServerModel->body = <<setServer($this->mockServerModel)
->setProject($this->mockProjectModel);
$result = $serverListFileBuilder
->pathInfo()
->put()
->getResult();
$serverListFile = Yaml::parse(file_get_contents($path));
$this->assertEquals('/home/www/deploy2', $serverListFile['test']['deploy_path']);
}
public function test_Should_OverrideAttributeInDeployerServerListFile_When_ProjectAttributeIsNotSpecified()
{
$path = vfsStream::url('rootDir/server.yml');
$this->mockProjectAttributeEntity
->shouldReceive('getDeployPath')
->twice()
->andReturn('/home/www/deploy2');
$this->mockProjectModel
->shouldReceive('getAttribute')
->with('attributes')
->andReturn($this->mockProjectAttributeEntity);
$this->mockDeployerFile
->shouldReceive('setBaseName')
->once();
$this->mockDeployerFile
->shouldReceive('setFullPath')
->once();
$this->mockDeployerFile
->shouldReceive('getFullPath')
->andReturn($path);
$serverListFileBuilder = new DeployerServerListFileBuilder(
new LaravelFilesystem($this->app['files']),
$this->mockDeployerFile,
new Parser,
new Dumper
);
$this->mockServerModel->body = <<setServer($this->mockServerModel)
->setProject($this->mockProjectModel);
$result = $serverListFileBuilder
->pathInfo()
->put()
->getResult();
$serverListFile = Yaml::parse(file_get_contents($path));
$this->assertEquals('/home/www/deploy2', $serverListFile['test']['deploy_path']);
}
}
================================================
FILE: tests/Services/Deployment/StorageDeployCommanderTest.php
================================================
once()
->andReturn(1);
$deployCommander = new StorageDeployCommander;
$result = $deployCommander->deploy(new App\Models\Deployment);
$this->assertTrue($result, 'Expected deploy command to succeed.');
}
public function test_Should_ReturnFalse_When_DeployCommandFails()
{
Storage::shouldReceive('put')
->once()
->andReturn(0);
$deployCommander = new StorageDeployCommander;
$result = $deployCommander->deploy(new App\Models\Deployment);
$this->assertFalse($result, 'Expected deploy command to fail.');
}
public function test_Should_ReturnTrue_When_RollbackCommandSucceeds()
{
Storage::shouldReceive('put')
->once()
->andReturn(1);
$deployCommander = new StorageDeployCommander;
$result = $deployCommander->rollback(new App\Models\Deployment);
$this->assertTrue($result, 'Expected rollback command to succeed.');
}
public function test_Should_ReturnFalse_When_RollbackCommandFails()
{
Storage::shouldReceive('put')
->once()
->andReturn(0);
$deployCommander = new StorageDeployCommander;
$result = $deployCommander->rollback(new App\Models\Deployment);
$this->assertFalse($result, 'Expected rollback command to fail.');
}
}
================================================
FILE: tests/Services/Filesystem/LaravelFilesystemTest.php
================================================
rootDir = vfsStream::setup('rootDir');
}
public function test_Should_WriteFile()
{
$fs = new LaravelFilesystem($this->app['files']);
$fs->put(vfsStream::url('rootDir/file'), 'contents');
$putFile = $this->rootDir->getChild('file')->getContent();
$this->assertEquals('contents', $putFile);
}
public function test_Should_ReadFile()
{
$file = vfsStream::newFile('file')->at($this->rootDir)->setContent('contents');
$fs = new LaravelFilesystem($this->app['files']);
$getFile = $fs->get(vfsStream::url('rootDir/file'));
$this->assertEquals('contents', $getFile);
}
public function test_Should_DeleteFile()
{
$file = vfsStream::newFile('file')->at($this->rootDir);
$fs = new LaravelFilesystem($this->app['files']);
$fs->delete(vfsStream::url('rootDir/file'));
$this->assertFileNotExists(vfsStream::url('rootDir/file'));
}
}
================================================
FILE: tests/Services/Form/Deployment/DeploymentFormLaravelValidatorTest.php
================================================
'user@example.com',
'password' => '0123456789',
'api_token' => '0123456789',
]);
$input = [
'task' => 'deploy',
'user_id' => 1,
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_ProjectIdFieldIsInvalid()
{
Factory::create('App\Models\User', [
'email' => 'user@example.com',
'password' => '0123456789',
'api_token' => '0123456789',
]);
$input = [
'project_id' => 1,
'task' => 'deploy',
'user_id' => 1,
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_TaskFieldIsMissing()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
Factory::create('App\Models\User', [
'email' => 'user@example.com',
'password' => '0123456789',
'api_token' => '0123456789',
]);
$input = [
'project_id' => 1,
'user_id' => 1,
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_TaskFieldIsInvalid()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
Factory::create('App\Models\User', [
'email' => 'user@example.com',
'password' => '0123456789',
'api_token' => '0123456789',
]);
$input = [
'project_id' => 1,
'task' => 'invalid_task',
'user_id' => 1,
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_UserIdFieldIsMissing()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
$input = [
'project_id' => 1,
'task' => 'deploy',
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_UserIdFieldIsInvalid()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
$input = [
'project_id' => 1,
'task' => 'deploy',
'user_id' => 1,
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_ProjectIdFieldAndTaskFieldAndUserIdFieldAreValid()
{
$arrangedServer = Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Project', [
'name' => 'Project 1',
'server_id' => $arrangedServer->id,
'stage' => 'staging',
]);
Factory::create('App\Models\User', [
'email' => 'user@example.com',
'password' => '0123456789',
'api_token' => '0123456789',
]);
$input = [
'project_id' => 1,
'task' => 'deploy',
'user_id' => 1,
];
$form = new DeploymentFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
}
================================================
FILE: tests/Services/Form/Deployment/DeploymentFormTest.php
================================================
mockValidator = $this->mock('App\Services\Validation\ValidableInterface');
$this->mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockDeployCommander = $this->mock('App\Services\Deployment\DeployCommanderInterface');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
}
public function test_Should_SucceedToSave_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel;
$maxDeployment = Factory::build('App\Models\MaxDeployment', [
'id' => 1,
'project_id' => $project->id,
'number' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$project->shouldReceive('getMaxDeployment')
->once()
->andReturn($maxDeployment)
->shouldReceive('addDeployment')
->once()
->shouldReceive('updateMaxDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn(true)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockDeployCommander
->shouldReceive('deploy')
->once()
->andReturn(true);
$form = new DeploymentForm(
$this->mockValidator,
$this->mockProjectRepository,
$this->mockDeployCommander
);
$result = $form->save([
'project_id' => $project->id,
'task' => 'deploy'
]);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_SucceedToSave_When_ValidationPassesAndSaveToDatabaseSucceeds()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel;
$maxDeployment = Factory::build('App\Models\MaxDeployment', [
'id' => 1,
'project_id' => $project->id,
'number' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$project->shouldReceive('getMaxDeployment')
->once()
->andReturn($maxDeployment)
->shouldReceive('addDeployment')
->once()
->shouldReceive('updateMaxDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn(true)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockDeployCommander
->shouldReceive('deploy')
->once()
->andReturn(true);
$form = new DeploymentForm(
$this->mockValidator,
$this->mockProjectRepository,
$this->mockDeployCommander
);
$result = $form->save([
'project_id' => $project->id,
'task' => 'deploy'
]);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_FailToSave_When_ValidationPassesAndSaveToDatabaseFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel;
$maxDeployment = Factory::build('App\Models\MaxDeployment', [
'id' => 1,
'project_id' => $project->id,
'number' => 1,
'created_at' => new Carbon\Carbon,
'updated_at' => new Carbon\Carbon,
]);
$project->shouldReceive('getMaxDeployment')
->once()
->andReturn($maxDeployment)
->shouldReceive('addDeployment')
->once()
->shouldReceive('updateMaxDeployment')
->once()
->shouldReceive('getDeploymentByNumber')
->once()
->andReturn(false)
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$form = new DeploymentForm(
$this->mockValidator,
$this->mockProjectRepository,
$this->mockDeployCommander
);
$result = $form->save([
'project_id' => $project->id,
'task' => 'deploy'
]);
$this->assertFalse($result, 'Expected save to fail.');
}
public function test_Should_FailToSave_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new DeploymentForm(
$this->mockValidator,
$this->mockProjectRepository,
$this->mockDeployCommander
);
$result = $form->save([]);
$this->assertFalse($result, 'Expected save to fail.');
}
public function test_Should_GetValidationErrors()
{
$this->mockValidator
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$form = new DeploymentForm(
$this->mockValidator,
$this->mockProjectRepository,
$this->mockDeployCommander
);
$result = $form->errors();
$this->assertEmpty($result);
}
}
================================================
FILE: tests/Services/Form/Project/ProjectFormLaravelValidatorTest.php
================================================
'Server 1',
'description' => '',
'body' => '',
]);
$input = [
'name' => 'Project 1',
'server_id' => 1,
'repository' => 'http://example.com',
'stage' => 'staging',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_NameFieldIsMissing()
{
Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$input = [
'recipe_id' => [1],
'server_id' => 1,
'repository' => 'http://example.com',
'stage' => 'staging',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_ServerIdFieldIsMissing()
{
Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
$input = [
'name' => 'Project 1',
'recipe_id' => [1],
'repository' => 'http://example.com',
'stage' => 'staging',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_RepositoryFieldIsMissing()
{
Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$input = [
'name' => 'Project 1',
'recipe_id' => [1],
'server_id' => 1,
'stage' => 'staging',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_RepositoryFieldIsInvalidUrl()
{
// HACK Laravel 5.2 URL validation doesn't work with PHP 7.3 due to preg_match() error.
if (version_compare(phpversion(), '7.3.0', '>=')) {
$this->markTestIncomplete("Laravel 5.2 URL validation doesn't work with PHP 7.3 due to preg_match() error.");
}
Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$input = [
'name' => 'Project 1',
'recipe_id' => [1],
'server_id' => 1,
'repository' => 'invalid_url',
'stage' => 'staging',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_StageFieldIsMissing()
{
Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$input = [
'name' => 'Project 1',
'recipe_id' => [1],
'server_id' => 1,
'repository' => 'http://example.com',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_NameFieldAndRecipeIdFieldAndServerIdFieldAndRepositoryFieldAndStageFieldAreValid()
{
Factory::create('App\Models\Recipe', [
'name' => 'Recipe 1',
'description' => '',
'body' => '',
]);
Factory::create('App\Models\Server', [
'name' => 'Server 1',
'description' => '',
'body' => '',
]);
$input = [
'name' => 'Project 1',
'recipe_id' => [1],
'server_id' => 1,
'repository' => 'http://example.com',
'stage' => 'staging',
];
$form = new ProjectFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
}
================================================
FILE: tests/Services/Form/Project/ProjectFormTest.php
================================================
mockValidator = $this->mock('App\Services\Validation\ValidableInterface');
$this->mockProjectRepository = $this->mock('App\Repositories\Project\ProjectInterface');
$this->mockProjectModel = $this->mockPartial('App\Models\Project');
}
public function test_Should_SucceedToSaveAndNotAddProjectAttribute_When_ValidationPassesAndDeployPathFieldIsNotSpecified()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel
->shouldReceive('addMaxDeployment')
->once()
->shouldReceive('syncRecipes')
->once()
->mock();
$this->mockProjectRepository
->shouldReceive('create')
->once()
->andReturn($project);
$input = [
'recipe_id_order' => '3,1,2',
'deploy_path' => '',
];
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->save($input);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_SucceedToSaveAndAddProjectAttribute_When_ValidationPassesAndDeployPathFieldIsSpecified()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel
->shouldReceive('addMaxDeployment')
->once()
->shouldReceive('syncRecipes')
->once()
->mock();
$this->mockProjectRepository
->shouldReceive('create')
->once()
->andReturn($project);
$input = [
'recipe_id_order' => '3,1,2',
'deploy_path' => '/home/www',
];
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->save($input);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_FailToSave_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$input = [
'recipe_id_order' => '3,1,2',
'deploy_path' => '',
];
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->save($input);
$this->assertFalse($result, 'Expected save to fail.');
}
public function test_Should_SucceedToUpdateAndNotAddProjectAttribute_When_ValidationPassesAndDeployPathFieldIsNotSpecified()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel
->shouldReceive('syncRecipes')
->once()
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockProjectRepository
->shouldReceive('update')
->once()
->andReturn(true);
$input = [
'id' => $project->id,
'recipe_id_order' => '3,1,2',
'deploy_path' => '',
];
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->update($input);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_SucceedToUpdateAndAddProjectAttribute_When_ValidationPassesAndDeployPathFieldIsSpecified()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$project = $this->mockProjectModel
->shouldReceive('syncRecipes')
->once()
->mock();
$this->mockProjectRepository
->shouldReceive('byId')
->once()
->andReturn($project);
$this->mockProjectRepository
->shouldReceive('update')
->once()
->andReturn(true);
$input = [
'id' => $project->id,
'recipe_id_order' => '3,1,2',
'deploy_path' => '/home/www',
];
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->update($input);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdate_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$input = [
'recipe_id_order' => '3,1,2',
'deploy_path' => '',
];
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->update($input);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_GetValidationErrors()
{
$this->mockValidator
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$form = new ProjectForm($this->mockValidator, $this->mockProjectRepository);
$result = $form->errors();
$this->assertEmpty($result);
}
}
================================================
FILE: tests/Services/Form/Recipe/RecipeFormLaravelValidatorTest.php
================================================
'',
'body' => 'app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_BodyFieldIsMissing()
{
$input = [
'name' => 'Recipe 1',
'description' => '',
];
$form = new RecipeFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_NameFieldAndBodyFieldAreValid()
{
$input = [
'name' => 'Recipe 1',
'description' => '',
'body' => 'app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
}
================================================
FILE: tests/Services/Form/Recipe/RecipeFormTest.php
================================================
mockValidator = $this->mock('App\Services\Validation\ValidableInterface');
$this->mockRecipeRepository = $this->mock('App\Repositories\Recipe\RecipeInterface');
}
public function test_Should_SucceedToSave_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockRecipeRepository
->shouldReceive('create')
->once()
->andReturn(true);
$form = new RecipeForm($this->mockValidator, $this->mockRecipeRepository);
$result = $form->save([]);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_FailToSave_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new RecipeForm($this->mockValidator, $this->mockRecipeRepository);
$result = $form->save([]);
$this->assertFalse($result, 'Expected save to fail.');
}
public function test_Should_SucceedToUpdate_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockRecipeRepository
->shouldReceive('update')
->once()
->andReturn(true);
$form = new RecipeForm($this->mockValidator, $this->mockRecipeRepository);
$result = $form->update([]);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdate_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new RecipeForm($this->mockValidator, $this->mockRecipeRepository);
$result = $form->update([]);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_GetValidationErrors()
{
$this->mockValidator
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$form = new RecipeForm($this->mockValidator, $this->mockRecipeRepository);
$result = $form->errors();
$this->assertEmpty($result);
}
}
================================================
FILE: tests/Services/Form/Server/ServerFormLaravelValidatorTest.php
================================================
'',
'body' => 'app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_BodyFieldIsMissing()
{
$input = [
'name' => 'Server 1',
'description' => '',
];
$form = new ServerFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_NameFieldAndBodyFieldAreValid()
{
$input = [
'name' => 'Server 1',
'description' => '',
'body' => 'app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
}
================================================
FILE: tests/Services/Form/Server/ServerFormTest.php
================================================
mockValidator = $this->mock('App\Services\Validation\ValidableInterface');
$this->mockServerRepository = $this->mock('App\Repositories\Server\ServerInterface');
}
public function test_Should_SucceedToSave_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockServerRepository
->shouldReceive('create')
->once()
->andReturn(true);
$form = new ServerForm($this->mockValidator, $this->mockServerRepository);
$result = $form->save([]);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_FailToSave_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new ServerForm($this->mockValidator, $this->mockServerRepository);
$result = $form->save([]);
$this->assertFalse($result, 'Expected save to fail.');
}
public function test_Should_SucceedToUpdate_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockServerRepository
->shouldReceive('update')
->once()
->andReturn(true);
$form = new ServerForm($this->mockValidator, $this->mockServerRepository);
$result = $form->update([]);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdate_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new ServerForm($this->mockValidator, $this->mockServerRepository);
$result = $form->update([]);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_GetValidationErrors()
{
$this->mockValidator
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$form = new ServerForm($this->mockValidator, $this->mockServerRepository);
$result = $form->errors();
$this->assertEmpty($result);
}
}
================================================
FILE: tests/Services/Form/Setting/MailSettingFormLaravelValidatorTest.php
================================================
'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_FailToValidate_When_DriverFieldIsMissing()
{
$input = [
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_DriverFieldIsInvalid()
{
$input = [
'driver' => 'invalid',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_FromAddressFieldIsMissing()
{
$input = [
'driver' => 'smtp',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_FromAddressFieldIsInvalid()
{
$input = [
'driver' => 'smtp',
'from_address' => 'invalid',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_SmtpPortFieldIsEqualToMin()
{
$input = [
'driver' => 'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 0,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_PassToValidate_When_SmtpPortFieldIsEqualToMax()
{
$input = [
'driver' => 'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 65535,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_FailToValidate_When_SmtpPortFieldIsLessThanMin()
{
$input = [
'driver' => 'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => -1,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_SmtpPortFieldIsGreaterThanMax()
{
$input = [
'driver' => 'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 65536,
'smtp_encryption' => 'tls',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_SmtpEncryptionFieldIsInvalid()
{
$input = [
'driver' => 'smtp',
'from_address' => 'from_address@example.com',
'from_name' => 'from_name',
'smtp_host' => 'localhost',
'smtp_port' => 587,
'smtp_encryption' => 'invalid',
'smtp_username' => 'username@example.com',
'smtp_password' => 'password',
'sendmail_path' => '/usr/sbin/sendmail -bs',
];
$form = new MailSettingFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
}
================================================
FILE: tests/Services/Form/Setting/MailSettingFormTest.php
================================================
mockValidator = $this->mock('App\Services\Validation\ValidableInterface');
$this->mockSettingRepository = $this->mock('App\Repositories\Setting\SettingInterface');
}
public function test_Should_SucceedToUpdate_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockSettingRepository
->shouldReceive('updateByType')
->once()
->andReturn(true);
$form = new MailSettingForm($this->mockValidator, $this->mockSettingRepository);
$result = $form->update([
'driver' => '',
'from_address' => '',
'from_name' => '',
'smtp_host' => '',
'smtp_port' => '',
'smtp_encryption' => '',
'smtp_username' => '',
'smtp_password' => '',
'sendmail_path' => '',
]);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdate_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new MailSettingForm($this->mockValidator, $this->mockSettingRepository);
$result = $form->update([]);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_GetValidationErrors()
{
$this->mockValidator
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$form = new MailSettingForm($this->mockValidator, $this->mockSettingRepository);
$result = $form->errors();
$this->assertEmpty($result);
}
}
================================================
FILE: tests/Services/Form/User/UserFormLaravelValidatorTest.php
================================================
'User 1',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_PassToValidate_When_EmailFieldIsValid()
{
$input = [
'email' => 'user1@example.com',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_FailToValidate_When_EmailFieldIsInvalid()
{
$input = [
'email' => 'invalid',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_PasswordFieldAndPasswordConfirmationFieldAreValid()
{
$input = [
'password' => '12345678',
'password_confirmation' => '12345678',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_FailToValidate_When_PasswordFieldAndPasswordConfirmationFieldAreInvalid()
{
$input = [
'password' => '1234567',
'password_confirmation' => '1234567',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_PasswordFieldAndPasswordConfirmationFieldAreDifferent()
{
$input = [
'password' => '12345678',
'password_confirmation' => '23456789',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_RoleFieldIsValid()
{
Factory::create('Kodeine\Acl\Models\Eloquent\Role', [
'name' => 'Role 1',
'slug' => 'role_1',
'description' => '',
]);
Factory::create('Kodeine\Acl\Models\Eloquent\Role', [
'name' => 'Role 2',
'slug' => 'role_2',
'description' => '',
]);
$input = [
'role' => [1, 2],
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
public function test_Should_FailToValidate_When_RoleFieldIsInvalid()
{
$input = [
'role' => [1],
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_FailToValidate_When_EmailFieldIsNotUniqueAndIdFieldIsNotSpecified()
{
Factory::create('App\Models\User', [
'email' => 'user1@example.com',
]);
$input = [
'email' => 'user1@example.com',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertFalse($result, 'Expected validation to fail.');
$this->assertInstanceOf('Illuminate\Support\MessageBag', $errors);
}
public function test_Should_PassToValidate_When_EmailFieldIsNotUniqueAndIdFieldIsSpecified()
{
$arrangedUser = Factory::create('App\Models\User', [
'email' => 'user1@example.com',
]);
$input = [
'id' => $arrangedUser->id,
'email' => 'user1@example.com',
];
$form = new UserFormLaravelValidator($this->app['validator']);
$result = $form->with($input)->passes();
$errors = $form->errors();
$this->assertTrue($result, 'Expected validation to succeed.');
$this->assertEmpty($errors);
}
}
================================================
FILE: tests/Services/Form/User/UserFormTest.php
================================================
mockValidator = $this->mock('App\Services\Validation\ValidableInterface');
$this->mockUserRepository = $this->mock('App\Repositories\User\UserInterface');
$this->mockUserModel = $this->mockPartial('App\Models\User');
}
public function test_Should_SucceedToSave_When_ValidationPassesAndRoleFieldIsNotSpecified()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockUserRepository
->shouldReceive('create')
->once();
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->save([]);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_SucceedToSave_When_ValidationPassesAndRoleFieldIsSpecified()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$user = $this->mockUserModel
->shouldReceive('assignRole')
->once()
->mock();
$this->mockUserRepository
->shouldReceive('create')
->once()
->andReturn($user);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->save(['role' => []]);
$this->assertTrue($result, 'Expected save to succeed.');
}
public function test_Should_FailToSave_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->save([]);
$this->assertFalse($result, 'Expected save to fail.');
}
public function test_Should_SucceedToUpdate_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockUserRepository
->shouldReceive('update')
->once()
->andReturn(true);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->update([]);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdate_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->update([]);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_SucceedToUpdatePassword_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockUserRepository
->shouldReceive('update')
->once()
->andReturn(true);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->update([]);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdatePassword_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->update([]);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_SucceedToUpdateRole_When_ValidationPasses()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(true);
$this->mockUserRepository
->shouldReceive('update')
->once()
->andReturn(true);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->update([]);
$this->assertTrue($result, 'Expected update to succeed.');
}
public function test_Should_FailToUpdateRole_When_ValidationFails()
{
$this->mockValidator
->shouldReceive('with')
->once()
->andReturn($this->mockValidator);
$this->mockValidator
->shouldReceive('passes')
->once()
->andReturn(false);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->update([]);
$this->assertFalse($result, 'Expected update to fail.');
}
public function test_Should_GetValidationErrors()
{
$this->mockValidator
->shouldReceive('errors')
->once()
->andReturn(new Illuminate\Support\MessageBag);
$form = new UserForm($this->mockValidator, $this->mockUserRepository);
$result = $form->errors();
$this->assertEmpty($result);
}
}
================================================
FILE: tests/Services/Notification/MailNotifierTest.php
================================================
from('from@example.com');
$this->assertEquals($notifier, $result);
}
public function test_Should_SetToAddressAndReturnThis()
{
$notifier = new MailNotifier;
$result = $notifier->to('to@example.com');
$this->assertEquals($notifier, $result);
}
public function test_Should_SendEmailNotification_When_ToAddressIsSet()
{
$mockSwiftMailer = $this->mock('Swift_Mailer');
$mockSwiftMailTransport = $this->mockPartial('Swift_MailTransport');
$mockSwiftMailer->shouldReceive('send');
$mockSwiftMailer->shouldReceive('getTransport')
->andReturn($mockSwiftMailTransport);
$this->app['mailer']->setSwiftMailer($mockSwiftMailer);
$notifier = new MailNotifier;
$notifier->to('to@example.com')->notify('Subject', 'Message');
}
}
================================================
FILE: tests/Specifications/DeploymentSpecificationTest.php
================================================
mockProjectModel = $this->mockPartial('App\Models\Project');
}
public function test_Should_GetSatisfyingElements()
{
$spec = new DeploymentSpecification;
$deployment1 = $this->mockPartial('App\Models\Deployment');
$deployment2 = $this->mockPartial('App\Models\Deployment');
$deployment3 = $this->mockPartial('App\Models\Deployment');
$deployment4 = $this->mockPartial('App\Models\Deployment');
$deployments = collect([
$deployment4,
$deployment3,
$deployment2,
$deployment1,
]);
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEquals($deployment4, $oldDeployments[0]);
$this->assertEquals($deployment3, $oldDeployments[1]);
$this->assertEquals($deployment2, $oldDeployments[2]);
$this->assertEquals($deployment1, $oldDeployments[3]);
}
}
================================================
FILE: tests/Specifications/OldDeploymentSpecificationTest.php
================================================
mockProjectModel = $this->mockPartial('App\Models\Project');
}
public function test_Should_GetSatisfyingElements_When_DaysToKeepDeploymentsIsSetAndKeepLastDeploymentIsFalseAndMaxNumberDeploymentsToKeepIsSet()
{
$date = new DateTime;
$spec = new OldDeploymentSpecification($date);
$deployment1 = $this->mockPartial('App\Models\Deployment');
$deployment2 = $this->mockPartial('App\Models\Deployment');
$deployment3 = $this->mockPartial('App\Models\Deployment');
$deployment4 = $this->mockPartial('App\Models\Deployment');
$deployment1->number = 1;
$deployment2->number = 2;
$deployment3->number = 3;
$deployment4->number = 4;
$deployments = collect([
$deployment4,
$deployment3,
$deployment2,
$deployment1,
]);
$pastDaysToKeepDeployments = collect([
$deployment2,
$deployment1,
]);
$pastNumToKeepDeployments = collect([
$deployment3,
$deployment2,
$deployment1,
]);
$this->mockProjectModel->days_to_keep_deployments = 1;
$this->mockProjectModel->keep_last_deployment = 0;
$this->mockProjectModel->max_number_of_deployments_to_keep = 1;
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments)
->shouldReceive('getDeploymentsWhereCreatedAtBefore')
->once()
->andReturn($pastDaysToKeepDeployments)
->shouldReceive('getDeploymentsWhereNumberBefore')
->once()
->andReturn($pastNumToKeepDeployments)
->shouldReceive('getLastDeployment')
->once()
->andReturn($deployment4);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEquals($deployment3, $oldDeployments[0]);
$this->assertEquals($deployment2, $oldDeployments[1]);
$this->assertEquals($deployment1, $oldDeployments[2]);
}
public function test_Should_GetSatisfyingElements_When_DaysToKeepDeploymentsIsNotSetAndKeepLastDeploymentIsFalseAndMaxNumberDeploymentsToKeepIsSet()
{
$date = new DateTime;
$spec = new OldDeploymentSpecification($date);
$deployment1 = $this->mockPartial('App\Models\Deployment');
$deployment2 = $this->mockPartial('App\Models\Deployment');
$deployment3 = $this->mockPartial('App\Models\Deployment');
$deployment4 = $this->mockPartial('App\Models\Deployment');
$deployment1->number = 1;
$deployment2->number = 2;
$deployment3->number = 3;
$deployment4->number = 4;
$deployments = collect([
$deployment4,
$deployment3,
$deployment2,
$deployment1,
]);
$pastNumToKeepDeployments = collect([
$deployment3,
$deployment2,
$deployment1,
]);
$this->mockProjectModel->days_to_keep_deployments = null;
$this->mockProjectModel->keep_last_deployment = 0;
$this->mockProjectModel->max_number_of_deployments_to_keep = 1;
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments)
->shouldReceive('getDeploymentsWhereNumberBefore')
->once()
->andReturn($pastNumToKeepDeployments)
->shouldReceive('getLastDeployment')
->once()
->andReturn($deployment4);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEquals($deployment3, $oldDeployments[0]);
$this->assertEquals($deployment2, $oldDeployments[1]);
$this->assertEquals($deployment1, $oldDeployments[2]);
}
public function test_Should_GetSatisfyingElements_When_DaysToKeepDeploymentsIsSetAndKeepLastDeploymentIsFalseAndMaxNumberDeploymentsToKeepIsNotSet()
{
$date = new DateTime;
$spec = new OldDeploymentSpecification($date);
$deployment1 = $this->mockPartial('App\Models\Deployment');
$deployment2 = $this->mockPartial('App\Models\Deployment');
$deployment1->number = 1;
$deployment2->number = 2;
$deployments = collect([
$deployment2,
$deployment1,
]);
$pastDaysToKeepDeployments = collect([
$deployment2,
$deployment1,
]);
$this->mockProjectModel->days_to_keep_deployments = 1;
$this->mockProjectModel->keep_last_deployment = 0;
$this->mockProjectModel->max_number_of_deployments_to_keep = null;
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments)
->shouldReceive('getDeploymentsWhereCreatedAtBefore')
->once()
->andReturn($pastDaysToKeepDeployments);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEquals($deployment2, $oldDeployments[0]);
$this->assertEquals($deployment1, $oldDeployments[1]);
}
public function test_Should_GetSatisfyingElements_When_DaysToKeepDeploymentsIsSetAndKeepLastDeploymentIsTrueMaxNumberDeploymentsToKeepIsNotSet()
{
$date = new DateTime;
$spec = new OldDeploymentSpecification($date);
$deployment1 = $this->mockPartial('App\Models\Deployment');
$deployment2 = $this->mockPartial('App\Models\Deployment');
$deployment1->number = 1;
$deployment2->number = 2;
$deployments = collect([
$deployment2,
$deployment1,
]);
$pastDaysToKeepDeployments = collect([
$deployment2,
$deployment1,
]);
$this->mockProjectModel->days_to_keep_deployments = 1;
$this->mockProjectModel->keep_last_deployment = 1;
$this->mockProjectModel->max_number_of_deployments_to_keep = null;
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments)
->shouldReceive('getDeploymentsWhereCreatedAtBefore')
->once()
->andReturn($pastDaysToKeepDeployments)
->shouldReceive('getLastDeployment')
->once()
->andReturn($deployment2);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEquals($deployment1, $oldDeployments[0]);
}
public function test_Should_GetSatisfyingElements_When_DaysToKeepDeploymentsIsNotSetAndKeepLastDeploymentIsFalseAndMaxNumberDeploymentsToKeepIsNotSet()
{
$date = new DateTime;
$spec = new OldDeploymentSpecification($date);
$deployment1 = $this->mockPartial('App\Models\Deployment');
$deployment2 = $this->mockPartial('App\Models\Deployment');
$deployment1->number = 1;
$deployment2->number = 2;
$deployments = collect([
$deployment2,
$deployment1,
]);
$this->mockProjectModel->days_to_keep_deployments = null;
$this->mockProjectModel->keep_last_deployment = 0;
$this->mockProjectModel->max_number_of_deployments_to_keep = null;
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEmpty($oldDeployments);
}
public function test_Should_GetSatisfyingElements_When_DeploymentsDoNotExists()
{
$date = new DateTime;
$spec = new OldDeploymentSpecification($date);
$deployments = collect([]);
$this->mockProjectModel
->shouldReceive('getDeployments')
->once()
->andReturn($deployments);
$oldDeployments = $spec->satisfyingElementsFrom($this->mockProjectModel);
$this->assertEmpty($oldDeployments);
}
}
================================================
FILE: tests/TestCase.php
================================================
make('Illuminate\Contracts\Console\Kernel')->bootstrap();
return $app;
}
public function setUp()
{
parent::setUp();
if ($this->useDatabase) {
Artisan::call('migrate');
}
}
public function tearDown()
{
if ($this->useDatabase) {
Artisan::call('migrate:reset');
}
parent::tearDown();
}
}
================================================
FILE: tests/_helpers/ConsoleCommandTestHelper.php
================================================
setLaravel($this->app);
$tester = new CommandTester($command);
return $tester->execute($arguments, $options);
}
}
================================================
FILE: tests/_helpers/ControllerTestHelper.php
================================================
Session::token()]);
parent::post($uri, $data, $headers);
return $this;
}
public function put($uri, array $data = [], array $headers = [])
{
$data = array_merge($data, ['_token' => Session::token()]);
parent::put($uri, $data, $headers);
return $this;
}
public function delete($uri, array $data = [], array $headers = [])
{
$data = array_merge($data, ['_token' => Session::token()]);
parent::delete($uri, $data, $headers);
return $this;
}
protected function auth($obj = null, $data = [])
{
if (isset($obj)) {
$user = $obj;
} else {
$user = new \App\Models\User;
}
foreach ($data as $key => $val) {
$user->$key = $val;
}
$this->be($user);
}
}
================================================
FILE: tests/_helpers/DummyMiddleware.php
================================================
getInstance($class, $data);
}
public static function create($class, $data = [])
{
$instance = static::build($class, $data);
$instance->save();
return $instance->find($instance->id);
}
public static function buildList($class, $dataList = [])
{
foreach ($dataList as $data) {
$instanceList[] = static::build($class, $data);
}
return $instanceList;
}
public static function createList($class, $dataList = [])
{
foreach ($dataList as $data) {
$instanceList[] = static::create($class, $data);
}
return $instanceList;
}
protected function getInstance($class, $data = [])
{
$instance = new $class;
foreach ($data as $key => $val) {
$instance->$key = $val;
}
return $instance;
}
}
================================================
FILE: tests/_helpers/MockeryHelper.php
================================================
app->instance($class, $mock);
return $mock;
}
protected function mockPartial($class)
{
$mock = m::mock($class)->makePartial();
$this->app->instance($class, $mock);
return $mock;
}
}
|